Code Monkey home page Code Monkey logo

Comments (11)

maxpert avatar maxpert commented on May 28, 2024

If I am understanding the question correctly. This particular case is for the tables when table doesn't have any primary key. So the IsPrimaryKey is the meta information for the column information stored in tableInfo. In case there are multiple primary keys, tableInfo will have multiple ColumnInfo with IsPrimaryKey set to true.

from marmot.

disarticulate avatar disarticulate commented on May 28, 2024

I think the error is assuming that IsPrimaryKey: true, can be converted to a boolean when SELECT name, type, notnull, dflt_value, pk FROM pragma_table_info(?) returns for pk a integer which can be interpreted as 0 for no pk, 1 for 1 pk (true) or 2+ for the number of primary keys. I did not look at how isPrimary key is used, but I would suspect there's logic that tracks the pk and if there's multiple pk one would need to account for that in the design.

from marmot.

maxpert avatar maxpert commented on May 28, 2024

I might need a detailed repro or side-effect this is causing. Can you help me do that?

from marmot.

disarticulate avatar disarticulate commented on May 28, 2024

if you have docker compose, you should be able to just build this: https://github.com/disarticulate/marmot/tree/master/example/single-leader

That should pull the latest source. and the sqlite file is there.

from marmot.

thetooth avatar thetooth commented on May 28, 2024

I managed to hit this on the first attempt at using marmot. The issue comes up when a table is configured with multiple primary keys or the primary key is not the first column. According to this pragma_table_info's pk value is a index of the column containing the primary key not a boolean. The following schema will cause the error and prevent marmot from starting:

CREATE TABLE "playlist_track" (
	"PlaylistId"	INTEGER NOT NULL,
	"TrackId"	INTEGER NOT NULL,
	FOREIGN KEY("PlaylistId") REFERENCES "playlists"("PlaylistId") ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY("TrackId") REFERENCES "tracks"("TrackId") ON DELETE NO ACTION ON UPDATE NO ACTION,
	CONSTRAINT "PK_PlaylistTrack" PRIMARY KEY("PlaylistId","TrackId")
);

I tested changing the type to an int and doing >0 checks. This seems to be sufficient to workaround the crash but someone who has used this software for more than a few hours should probably have a closer look.

from marmot.

maxpert avatar maxpert commented on May 28, 2024

Perfect I will try it locally, and try to get fix out.

from marmot.

maxpert avatar maxpert commented on May 28, 2024

I see how SQLite is putting index numbers instead of booleans, and I can reproduce it already. I have got a fix in place that should fix it let me put that up once a beta build once I've tested it locally.

from marmot.

maxpert avatar maxpert commented on May 28, 2024

I have a build ready to test these changes out here. @thetooth can you try it and let me know if the changes fix the issue. I tried on my side and it works.

from marmot.

maxpert avatar maxpert commented on May 28, 2024

@thetooth did you get a chance to test it on your side? I've been able to get it up and running without any issues.

from marmot.

thetooth avatar thetooth commented on May 28, 2024

@maxpert not yet but changes look identical to my local branch, should be ready to go as I've not encountered any problems so far. Will resync onto tagged release next week and let you know if any problems come up.

from marmot.

maxpert avatar maxpert commented on May 28, 2024

@thetooth the latest master has the changes now, feel free to use binaries from build or compile yourself and try.

from marmot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.