run _postfetch() for post_update to expire onupdates
Issue #3472
resolved
right now onupdates aren't caught
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
from itertools import count
value = count()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
favorite_b_id = Column(ForeignKey('b.id'))
bs = relationship("B", primaryjoin="A.id == B.a_id")
favorite_b = relationship(
"B", primaryjoin="A.favorite_b_id == B.id", post_update=True)
updated = Column(Integer, onupdate=lambda: next(value))
class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
a_id = Column(ForeignKey('a.id'))
e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)
s = Session(e)
a1 = A()
b1 = B()
a1.bs.append(b1)
a1.favorite_b = b1
s.add(a1)
s.flush()
assert a1.updated == 0, a1.updated
this is definitely for 1.1 at earliest
Comments (5)
-
reporter -
reporter see also
#3496 -
reporter - changed milestone to 1.2
starting to wrap up scope for 1.1, remaining behavioral changes being pushed out
-
reporter -
reporter - changed status to resolved
Implement _postfetch_post_update to expire/refresh onupdates in post_update
Fixed bug involving the :paramref:
.relationship.post_update
feature where a column "onupdate" value would not result in expiration or refresh of the corresponding object attribute, if the UPDATE for the row were a result of the "post update" feature. Additionally, the :meth:.SessionEvents.refresh_flush
event is now emitted for these attributes when refreshed within the flush.Fixes:
#3472Change-Id: I5ee2d715e773a306ab1e8143e4382c228991ac78→ <<cset 9dee44ae2f8b>>
- Log in to comment
patch: