[Sqlalchemy-tickets] Issue #3472: run _postfetch() for post_update to expire onupdates (zzzeek/sqla
Brought to you by:
zzzeek
|
From: Mike B. <iss...@bi...> - 2015-07-02 15:31:54
|
New issue 3472: run _postfetch() for post_update to expire onupdates https://bitbucket.org/zzzeek/sqlalchemy/issue/3472/run-_postfetch-for-post_update-to-expire Mike Bayer: right now onupdates aren't caught ``` #!python 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 |