On Jan 19, 2011, at 2:54 AM, Eric Lemoine wrote:

> On Tue, Jan 18, 2011 at 11:33 PM, Michael Bayer
> <mike...@zzzcomputing.com> wrote:
>> 
>> On Jan 18, 2011, at 4:47 PM, Eric Lemoine wrote:
>> 
>>> On Tuesday, January 18, 2011, Eric Lemoine <eric.lemo...@camptocamp.com> 
>>> wrote:
>>>> Hi
>>>> 
>>>> Probably a very simple question. I use the ORM for inserts, with
>>>> postgres 8.3. How can I get the ids resulting from my inserts'
>>>> RETURNING clauses? I haven't been able to find the information in the
>>>> doc.
>>> 
>>> Doing just_inserted_obj.id causes a "SELECT ... WHERE id=" query,
>>> which I'd like to avoid.
>> 
>> That sounds like you're calling commit() which is expiring all data, 
>> resulting in a re-fetch when you hit .id.  Just call session.flush(), then 
>> get the .id from your objects, before a commit() occurs.
> 
> I did not expect that obj.id (the primary key) would be expired, as
> doing "SELECT id WHERE id=" didn't make sense to me.

well the row could have been moved/deleted so thats why PK columns are part of 
that check.   (we of course have the "identity" of the object stored as well, 
that is separate from the primary key attributes...since they can diverge in 
this case).




> 
> Thanks.
> 
> 
> -- 
> Eric Lemoine
> 
> Camptocamp France SAS
> Savoie Technolac, BP 352
> 73377 Le Bourget du Lac, Cedex
> 
> Tel : 00 33 4 79 44 44 96
> Mail : eric.lemo...@camptocamp.com
> http://www.camptocamp.com
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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