2 messages in com.googlegroups.sqlalchemy[sqlalchemy] SQL function on session....| From | Sent On | Attachments |
|---|---|---|
| Denis Shaposhnikov | 28 Dec 2006 03:02 | |
| Michael Bayer | 28 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!
-- DSS5-RIPE DSS-RIPN 2:550/5068@fidonet 2:550/5069@fidonet xmpp:ds...@vlink.ru mailto:ds...@vlink.ru http://neva.vlink.ru/~dsh/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




