On 9/4/15 10:19 AM, Pavel S wrote:
Hi,
I have declarative Model with couple of columns, one of them is
lastAccess = Column('LastAccess', DateTime, nullable=False,
onupdate=datetime.datetime.utcnow)
I fetch the object from database like the following:
obj = ScopedSession.query(Model).get(something)
Later in code I commit the session as:
ScopedSession.commit()
I would like to have /lastAccess/ updated in database when issuing
/commit()/. However the column remains unchanged.
I do understand that /onupdate/ callback is called on update, but how
to trigger the update since I don't want to change any other column?
In other words, how can I mark the /obj/ as "dirty" so /onupdate/ will
take effect?
you'd only be able to just set that actual column to a new value, or
change the value of some other column. the ORM doesn't emit UPDATE
statements w/ no changes.
Alternatively, it might work if you were to say,
session.execute(Model.__table__.update()). though that might assume it
wants every value specified.
--
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 [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.