Adrian von Bidder wrote:
> Heyho!
>
> My small blog-style web site should support article versioning, so:
>
> class Entry(DeclarativeBase):
>       id = Column(Integer, autoincrement=True, primary_key=True)
>       version = Column(Integer, primary_key=True, default=0)
>       ... and more stuff (content, author, ...)
>
> it seems autoincrement is not supported in this case.
>
> (I'm working in a TurboGears 2 environment with SQLite; final deployment 
> will probably be with PostgreSQL)
>
> At least, when trying to populate a db from TurboGear's "pasteer set-up", I 
> get an IntegrityError ("id may not be NULL") and see that id is not set in 
> the INSERT statement.  Just removing the version column from the Entry class 
> suffices to let it work as before.
>   
Sorry to be so late in responding to this, but hey.  Maybe better late 
than never.  Anyway, I've had the same problem.  The true problem here 
is with sqlite, which tries to make a "smart" choice about whether to 
autoincrement or not.  And it gets it wrong.  SQLAlchemy is correct to 
not specify the id field in the INSERT statement.  That's the cue to the 
db that it needs to supply that value on its own.

--

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


Reply via email to