Ahh yes, I use autoflush almost exclusively and forget that you can separate
the flush() and commit().

-- 
Mike Conley



On Tue, May 5, 2009 at 6:31 PM, Michael Bayer <mike...@zzzcomputing.com>wrote:

>
> Mike Conley wrote:
> > Does the idea of last_inserted_ids exist for ORM?
> >
> > I do
> >       session.add(someobj)
> >       session.commit()
> > and then want the id of the newly inserted object.
> >
> > I can reference
> >       someobj.id
> > but this generates a select call to the database
>
> get the id before you call commit().   the same thing would apply with SQL
> expressions, as the cursor is gone when the transaction is closed.   you
> can call session.flush() to force a flush.
>
> alternatively, set "expire_on_commit=False" on your Session.
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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