deutschmarco / sqlautocode

Automatically exported from code.google.com/p/sqlautocode
Other
0 stars 0 forks source link

For an sqlite table with a primary key that is AUTOINCREMENTED sqlautocode will fail (sqlite_sequence issue) #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
 In sqlite, when you create an autoincremented key, a sqlite_sequence table is created automatically. The problem is that this table has no primary key making sqlalchmey and sqlautocode fail with "sqlalchemy.exc.ArgumentError: Mapper Mapper|Temporal|sqlite_sequence could not assemble any primary key columns for mapped table 'sqlite_sequence'".

 The bigger problem is, however, that when you're trying to generate a declarative model (using the -d flag), the table filtering option is not working - or more accurately is not even handled.

Simple schema:
CREATE TABLE builds (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            repository TEXT,
            revision TEXT,
        );

And try:
sqlautocode -d -t builds sqlite:///builds.db

I've attached a superficial fix for whoever needs it (python 2.6)

Original issue reported on code.google.com by catalin....@gmail.com on 26 Dec 2010 at 8:52

Attachments:

GoogleCodeExporter commented 9 years ago
patch file - added exclude option based on a regex expression - maybe a better 
implementation than the actual glob match used for the table filtering ?

Original comment by catalin....@gmail.com on 26 Dec 2010 at 11:06

Attachments:

GoogleCodeExporter commented 9 years ago
The attached patch from comment 1 is malformed (looks like it's been edited 
manually) - attached a corrected version that also doesn't have the minor line 
changes that are unrelated

Original comment by dav...@j5int.com on 5 Jan 2011 at 3:17

Attachments:

GoogleCodeExporter commented 9 years ago
A patch that also includes the error handling from issue 17

Original comment by dav...@j5int.com on 5 Jan 2011 at 3:20

Attachments: