- changed status to resolved
post_update does not honor many-to-one assign to None w/o active history
Issue #3599
resolved
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
a_id = Column(ForeignKey('a.id'))
a = relationship(
"A",
# no UPDATE is emitted at the end unless this is
# commented out
post_update=True
)
e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)
s = Session(e)
s.add(B(a=A()))
s.commit()
b1 = s.query(B).first()
b1.a = None
s.commit()
b1 = s.query(B).first()
assert b1.a is None
Comments (2)
-
reporter -
reporter - Fixed issue where post_update on a many-to-one relationship would
fail to emit an UPDATE in the case where the attribute were set to
None and not previously loaded.
fixes
#3599
(cherry picked from commit 935bc34dc50d5e4bdf181a8287d6e4cdbde073d0)
→ <<cset 74fcb4b86719>>
- Fixed issue where post_update on a many-to-one relationship would
fail to emit an UPDATE in the case where the attribute were set to
None and not previously loaded.
fixes
- Log in to comment
#3599→ <<cset 935bc34dc50d>>