mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-02 22:10:15 -04:00
added a test for #1349
This commit is contained in:
@@ -742,6 +742,28 @@ class M2MCascadeTest(_base.MappedTest):
|
||||
assert b.count().scalar() == 0
|
||||
assert a.count().scalar() == 1
|
||||
|
||||
@testing.resolve_artifact_names
|
||||
def test_delete_orphan_dynamic(self):
|
||||
mapper(A, a, properties={
|
||||
# if no backref here, delete-orphan failed until [ticket:427] was
|
||||
# fixed
|
||||
'bs': relation(B, secondary=atob,
|
||||
cascade="all, delete-orphan", single_parent=True,lazy="dynamic")
|
||||
})
|
||||
mapper(B, b)
|
||||
|
||||
sess = create_session()
|
||||
b1 = B(data='b1')
|
||||
a1 = A(data='a1', bs=[b1])
|
||||
sess.add(a1)
|
||||
sess.flush()
|
||||
|
||||
a1.bs.remove(b1)
|
||||
sess.flush()
|
||||
assert atob.count().scalar() ==0
|
||||
assert b.count().scalar() == 0
|
||||
assert a.count().scalar() == 1
|
||||
|
||||
@testing.resolve_artifact_names
|
||||
def test_delete_orphan_cascades(self):
|
||||
mapper(A, a, properties={
|
||||
|
||||
Reference in New Issue
Block a user