Re: lastrowid and INSERT ... RETURNING

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <[email protected]>
Il giorno lun, 04/08/2008 alle 09.58 -0400, James Henstridge ha scritto:
> > RETURNING can return anything so does it make sense to hack some magic
> > to automatically populate .lastrowid when the query is an INSERT and the
> > value returned is a long (like the OID were) or is better to simply
> > accept that PostgreSQL does not support row ids and put the .fetchone()
> > in the code?
> 
> If someone issues an "INSERT ... RETURNING" query, they probably know
> what they're doing and will check the result set themselves.  As it
> won't necessarily be a primary key value, using it for lastrowid will
> just make it lastrowid less reliable.
> 
> 
> > I am for the second but I can hack .lastrowid if enough people need it
> > to transition from old backends with automatic OIDs to the new ones
> > where OIDs are not geneated by default.
> 
> If people are using higher level systems (e.g. ORMs like SQLObject,
> Storm, etc), then this is a non-issue.  If they are doing lower level
> stuff, then couldn't they continue to use tables with OIDs if that is
> what they need?

I pretty much agree with you here. It is just that I found that old
email and I wanted to clear things up. I suppose we can just
mark .lastrowid as "working only if PostgreSQL is configured with OIDs"
and done with it.

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
                                   God is in the rain... -- Evey Hammond

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkiXH8IACgkQvcCgrgZGjevnqgCfSjvd2Y1gteJSommUH85UPms8
pLMAn0kw8p3saeM08Q/Scs7zTQxuCZSI
=JJN0
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.