Adrian von Bidder wrote:
> Heyho!
>
> [multi-column primary key where one column is autoincrement int]
>
> On Wednesday 16 December 2009 05.29:54 Daniel Falk wrote:
>> 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.
>
> Hmm.
>
> Closer inspection shows that
>  * sqlite doesn't even support the scenario I want (autoincrement on one
> column with multi column primary key) and
>  * sqlalchemy doesn't notice this and just creates a two column primary
> key
> without autoincrement at all.
>
> Is there any hope that sqlalchemy will start to simulate the feature on
> sqlite? (I'm using the python-pysqlite2 2.5.5-3 / libsqlite3-0 3.6.20-1 /
> python-sqlalchemy 0.5.6-1 packages from Debian squeeze, btw)
>
> I've opened #1642 now.

Sorry, I've closed it.  SQLite doesn't support autoincrement on composite
PKs and theres no one-size-fits-all way to "simulate" this, so its up to
the user.  You need to either use the "default" keyword and specify a
function or SQL expression that will generate new identifiers, or just set
up the PK attributes on your new objects before adding them to the
session.

>
> PostgreSQL handles this in just the way I was expecting (no surprise since
> my expectation on autoincrement columns is derived from the way pg builds
> its serial data type :-), so I'll have to test if sqlalchemy will do the
> right thing here.  Then I can at least use pg (I was planning to do so in
> production anyway; sqlite is convenient for development though.)

absolutely, PG uses sequences and has no issue here.  the
no-autoincrement-sqlite thing is an only-sqlite issue and we also have
some unit tests that specifically skip sqlite for this reason.


>
>
> cheers
> -- vbi
>
> --
> featured product: GNU Privacy Guard - http://gnupg.org
>

--

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