thats a bug.   seems like there would normally be a primary key constraint 
there which is being concealed due to the autoincrement keyword, yet the comma 
joining the (invisible) pk and fk constraints remains.  ticket 1812.


On May 22, 2010, at 8:17 PM, ratufa wrote:

> This is using SQLAlchemy version 0.6.0, Python 2.6.5.
> 
> The following program:
> 
> from sqlalchemy import Table, Column, Integer, String, MetaData
> from sqlalchemy import ForeignKey, create_engine
> 
> metadata = MetaData()
> 
> table1 = Table('table1', metadata,
>    Column('id', Integer, primary_key = True),
>    Column('fid', Integer, ForeignKey('table2.id')),
> sqlite_autoincrement = True)
> 
> table2 = Table('table2', metadata,
>    Column('id', Integer, primary_key = True),
>    Column('stuff', String), sqlite_autoincrement = True)
> 
> engine = create_engine('sqlite://', echo = True)
> 
> metadata.create_all(engine)
> 
> Generates the following commands:
> 
> CREATE TABLE table2 (
>        id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
>        stuff VARCHAR
> )
> 
> CREATE TABLE table1 (
>        id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
>        fid INTEGER,
>        ,
>        FOREIGN KEY(fid) REFERENCES table2 (id)
> )
> 
> The extra comma in the Table1 creation causes a syntax error.  This
> seems to be a function of declaring a foreign key when also setting
> sqlite_autoincrement = True. What am I doing wrong?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to