MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_dynamic_on_backref

Method test_dynamic_on_backref

test/orm/test_dynamic.py:483–511  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

481 eq_(u.addresses.count(), 1)
482
483 def test_dynamic_on_backref(self):
484 users, Address, addresses, User = (
485 self.tables.users,
486 self.classes.Address,
487 self.tables.addresses,
488 self.classes.User,
489 )
490
491 self.mapper_registry.map_imperatively(
492 Address,
493 addresses,
494 properties={
495 "user": relationship(
496 User, backref=backref("addresses", lazy="dynamic")
497 )
498 },
499 )
500 self.mapper_registry.map_imperatively(User, users)
501
502 sess = fixture_session()
503 ad = sess.get(Address, 1)
504
505 def go():
506 ad.user = None
507
508 self.assert_sql_count(testing.db, go, 0)
509 sess.flush()
510 u = sess.get(User, 7)
511 assert ad not in u.addresses
512
513 def test_no_count(self, user_address_fixture):
514 User, Address = user_address_fixture()

Callers

nothing calls this directly

Calls 7

relationshipFunction · 0.90
backrefFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
assert_sql_countMethod · 0.80
getMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected