On 1/1/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
well theres one fairly significant problem with this which has to do with my usage of SERIAL with postgres.  This is because " cursor.lastrowid" only returns the OID of the last row inserted, despite user pleas that it return something more reasonable, such as the last SERIAL value generated ( http://initd.org/tracker/psycopg/ticket/29).  With the deprecation of OID, instead of saying "hey yeah, I guess I was wrong and lastrowid should really return the sequence value", he now proposes that cursor.lastrowid is essentially useless (http://initd.org/tracker/psycopg/wiki/PsycopgTwoFaq):

 
Additional: Postgres is going to drop OIDs in the long run (within 8.1 "WITHOUT OID" is default). Using OIDs as primary key is not recommended anymore, especially because of the rather rough effects on dump and restore. So sometime in the futer .lastrowid will be rather meaningless. 

 
So with OID's gone and psycopg essentially dropping support for cursor.lastrowid,  I have no way to get back an identifier to a newly INSERTed row if I just rely upon SERIAL.   So I pretty much have to be aware of the sequence name, and I'll just call the sequence explicitly beforehand....if no "Sequence" is defined on the table, it will assume the sequence "<tablename>_<colname>_seq" exists since that is the name generated by SERIAL.
 
Makes sense.

also the version I am running here is 8.0.4....I'll try to commit "dont use OIDs with postgres" support today or tomorrow.  until then you're going to get pretty poor results unless you explicitly define a Sequence for primary key columns and add "order_by=None" within all mapper() and relation() calls.  
 
Great.  (Actually I have a fairly weird-ass schema going on; I get my PKs from a function manually which works fine.  I just need it to stop adding order by oid to everything. :)
 
-J

 

Reply via email to