MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_dynamic_on_backref

Method test_dynamic_on_backref

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

Source from the content-addressed store, hash-verified

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