use the eager_defaults flag:
http://docs.sqlalchemy.org/en/rel_1_0/orm/mapping_api.html?highlight=eager_defaults#sqlalchemy.orm.mapper.params.eager_defaults
http://docs.sqlalchemy.org/en/rel_0_9/changelog/migration_09.html#orm-can-efficiently-fetch-just-generated-insert-update-defaults-using-returning
not sure if this works for the ad-hoc set up updated_at, try it out.
if it's a server_default on the Column, should definitely work.
On 4/28/15 7:35 PM, univerio wrote:
Suppose I have a PostgreSQL backend and I have the following class:
class Foo(Base):
id = Column(Integer, primary_key=True)
updated_at = Column(DateTime)
and I do
foo = Foo(updated_at=func.now())
session.add(foo)
session.flush()
foo.id # this is already loaded, no additional query emitted
foo.updated_at # this is not loaded, will cause an additional
query to be emitted
Is it possible to have the SQLAlchemy ORM fetch the actual value of
updated_at as part of the INSERT...RETURNING statement like it does
for id, instead of leaving it unloaded and having to issue a second
query when I access it?
Jack
--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.