2 messages in com.googlegroups.sqlalchemy[sqlalchemy] SQL function on session....
FromSent OnAttachments
Denis Shaposhnikov28 Dec 2006 03:02 
Michael Bayer28 Dec 2006 08:56 
Subject:[sqlalchemy] SQL function on session.flush()
From:Denis Shaposhnikov (ds@vlink.ru)
Date:12/28/2006 03:02:38 AM
List:com.googlegroups.sqlalchemy

Hi!

I have a table like this

>>> t1 = Table('t1', metadata, ... Column('id', Integer, primary_key=True), ... Column('num', Integer, nullable=False), ... Column('change', DateTime, nullable=False, ... default=func.current_timestamp()))

and a class mapped to this table:

>>> class T1(object): pass >>> mapper(T1, t1)

Is SA able to execute

UPDATE t1 SET change=CURRENT_TIMESTAMP() WHERE t1.id = ? ['2006-12-28 10:21:50', 1]

on session.flush() instead of

UPDATE t1 SET change=? WHERE t1.id = ? ['2006-12-28 10:21:50', 1]

?

My target is to set "change" field to time of UPDATE query executing not when "change" propery was changed. And I know about "onupdate" keyword of "Column()" but I need to update "change" field only if I change mapped "change" property to any value.

Thank you!