Re: [sqlalchemy] Conditional onupdate

2019-05-22 Thread Tony Cao
o_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? On Thursday, May 16, 2019 at 2:49:56 PM UTC-7, Mike Bayer wrote: > > On Thu, May 16, 2019 at 4:26 PM Tony Cao > wrote: > > > > Ohh I see

Re: [sqlalchemy] Conditional onupdate

2019-05-16 Thread Tony Cao
> > On Wed, May 15, 2019 at 6:10 PM Tony Cao > wrote: > > > > I mean query.update(). > > > > Ah our goal was to make it so the update in question happened > automatically without the developer having to explicitly specify it - in > that case both obj

Re: [sqlalchemy] Conditional onupdate

2019-05-15 Thread Tony Cao
the VALUES clause, so you know from your own > data what the UPDATE statement will be. > > > > On Wed, May 15, 2019 at 4:14 PM Tony Cao > wrote: > > > > Ah but it also looks like the before_update event isn't triggered when > doing bulk query updates,

Re: [sqlalchemy] Conditional onupdate

2019-05-15 Thread Tony Cao
t > inspect(obj).attrs['some_attr'].history > > > https://docs.sqlalchemy.org/en/13/orm/internals.html#sqlalchemy.orm.state.AttributeState > > > > On Wed, May 15, 2019 at 1:14 PM Tony Cao > wrote: > > > > Hi, > > > > Thanks for the res

Re: [sqlalchemy] Conditional onupdate

2019-05-15 Thread Tony Cao
-db-update) that suggests looking at the history of the attribute state - is there a better way? On Wednesday, May 15, 2019 at 7:55:44 AM UTC-7, Mike Bayer wrote: > > On Mon, May 13, 2019 at 4:18 PM Tony Cao > wrote: > > > > Hi all, > > > > Is there way to

[sqlalchemy] Conditional onupdate

2019-05-13 Thread Tony Cao
Hi all, Is there way to use Column.onupdate conditionally? For example, say I have: class A(Base): foo = Column(String) bar = Column(String) foo_updated = Column(DateTime, onupdate=update_fn) # Should only update when foo is updated def update_fn(context): if ...: # How can I ch