Sorry, I will clarify what I was asking. If I had my class example from above:
class A(Base):
foo = Column(String)
bar = Column(String)
foo_updated = Column(DateTime, onupdate=update_fn) # Should only update when foo is updated
Based on what information is in the context, sometimes I may not want to update the value. However, my understanding is that onupdate_fn *must* return a value always.
Given that we need to return a value from onupdate_fn, one idea I had was to return a value to emit:
UPDATE A SET bar="new value", foo_updated=A.foo_updated WHERE id = 1
If we can somehow specify "set foo_updated to whatever value it already is" in SQL land, then we should be set! However, I tried some variations of this:
- `return 'foo_updated'`
- `return '"foo_updated"'
- `return A.foo_updated`
- `return A.__table__.c.foo_updated`
and none of these ended up working. Do you know if there's a way to specify an onupdate function to return a SQL column?