MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_delete

Method test_delete

test/orm/test_cascade.py:478–510  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

476 assert o1 not in sess
477
478 def test_delete(self):
479 User, users, orders, Order = (
480 self.classes.User,
481 self.tables.users,
482 self.tables.orders,
483 self.classes.Order,
484 )
485
486 with fixture_session() as sess:
487 u = User(
488 name="jack",
489 orders=[
490 Order(description="someorder"),
491 Order(description="someotherorder"),
492 ],
493 )
494 sess.add(u)
495 sess.flush()
496
497 sess.delete(u)
498 sess.flush()
499 eq_(
500 sess.execute(
501 select(func.count("*")).select_from(users)
502 ).scalar(),
503 0,
504 )
505 eq_(
506 sess.execute(
507 select(func.count("*")).select_from(orders)
508 ).scalar(),
509 0,
510 )
511
512 def test_delete_unloaded_collections(self):
513 """Unloaded collections are still included in a delete-cascade

Callers

nothing calls this directly

Calls 12

fixture_sessionFunction · 0.90
eq_Function · 0.90
selectFunction · 0.90
UserClass · 0.70
OrderClass · 0.70
addMethod · 0.45
flushMethod · 0.45
deleteMethod · 0.45
scalarMethod · 0.45
executeMethod · 0.45
select_fromMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected