--- /dev/null
+.. change::
+ :tags: bug, orm
+ :tickets: 4187
+ :versions: 1.2.3
+
+ Fixed issue in post_update feature where an UPDATE is emitted
+ when the parent object has been deleted but the dependent object
+ is not. This issue has existed for a long time however
+ since 1.2 now asserts rows matched for post_update, this
+ was raising an error.
(before_delete, parent_pre_updates),
(parent_pre_updates, child_deletes),
+ (parent_pre_updates, parent_deletes),
])
else:
uow.dependencies.update([
sess.add(p)
sess.flush()
+ def test_post_update_m2o_no_cascade(self):
+ person, ball, Ball, Person = (self.tables.person,
+ self.tables.ball,
+ self.classes.Ball,
+ self.classes.Person)
+
+ mapper(Ball, ball)
+ mapper(Person, person, properties=dict(
+ favorite=relationship(
+ Ball, primaryjoin=person.c.favorite_ball_id == ball.c.id,
+ post_update=True)))
+ b = Ball(data='some data')
+ p = Person(data='some data')
+ p.favorite = b
+ sess = create_session()
+ sess.add(b)
+ sess.add(p)
+ sess.flush()
+
+ sess.delete(p)
+ self.assert_sql_execution(
+ testing.db,
+ sess.flush,
+ CompiledSQL("UPDATE person SET favorite_ball_id=:favorite_ball_id "
+ "WHERE person.id = :person_id",
+ lambda ctx: {
+ 'favorite_ball_id': None,
+ 'person_id': p.id}
+ ),
+ CompiledSQL("DELETE FROM person WHERE person.id = :id",
+ lambda ctx: {'id': p.id}
+ ),
+ )
+
def test_post_update_m2o(self):
"""A cycle between two rows, with a post_update on the many-to-one"""