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

Method setup_mappers

test/orm/test_composites.py:1405–1433  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

1403
1404 @classmethod
1405 def setup_mappers(cls):
1406 a, b = cls.tables.a, cls.tables.b
1407
1408 class A(cls.Comparable):
1409 pass
1410
1411 class B(cls.Comparable):
1412 pass
1413
1414 class C(cls.Comparable):
1415 def __init__(self, b1, b2):
1416 self.b1, self.b2 = b1, b2
1417
1418 def __composite_values__(self):
1419 return self.b1, self.b2
1420
1421 def __eq__(self, other):
1422 return (
1423 isinstance(other, C)
1424 and other.b1 == self.b1
1425 and other.b2 == self.b2
1426 )
1427
1428 cls.mapper_registry.map_imperatively(
1429 A,
1430 a,
1431 properties={"b2": relationship(B), "c": composite(C, "b1", "b2")},
1432 )
1433 cls.mapper_registry.map_imperatively(B, b)
1434
1435 def test_early_configure(self):
1436 # test [ticket:2935], that we can call a composite

Callers

nothing calls this directly

Calls 3

relationshipFunction · 0.90
compositeFunction · 0.90
map_imperativelyMethod · 0.80

Tested by

no test coverage detected