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.

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.  


On Dec 31, 2005, at 8:06 PM, Jonathan Ellis wrote:

I've got to run, but I'll be happy to try echo when I'm back.  In the meantime, WITH OID was finally turned off by default in 8.1 after much warning -- before then it was on by default for backwards compatibility, including in 8.0.  You're definitely running 8.1?
 
On 12/31/05, Michael Bayer <[EMAIL PROTECTED]> wrote:

On Dec 31, 2005, at 6:39 PM, Jonathan Ellis wrote:

>
> Foo.get(1)
>
> dies complaining of oid absence.  Seems strange that get doesn't
> use a known PK.


also that is weird because there are plenty of get()'s in the unit
tests which I run all the time against postgres, and also I am not
doing anything with that "WITH OID" clause that doc mentions.  is it
postgres giving you the error ?  Id be curious to see what its asking
the DB for, if you turn echo=True on the engine, and also you can add
the keyword argument "order_by=None" to all mapper() functions and it
should stop trying to use the oid.  ill look into a way to globally
disable the usage of all oids for ordering.



--
Jonathan Ellis
http://spyced.blogspot.com

Reply via email to