MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / setup_mappers

Method setup_mappers

test/orm/test_composites.py:1406–1434  ·  test/orm/test_composites.py::ManyToOneTest.setup_mappers
(cls)

Source from the content-addressed store, hash-verified

1404
1405 @classmethod
1406 def setup_mappers(cls):
1407 a, b = cls.tables.a, cls.tables.b
1408
1409 class A(cls.Comparable):
1410 pass
1411
1412 class B(cls.Comparable):
1413 pass
1414
1415 class C(cls.Comparable):
1416 def __init__(self, b1, b2):
1417 self.b1, self.b2 = b1, b2
1418
1419 def __composite_values__(self):
1420 return self.b1, self.b2
1421
1422 def __eq__(self, other):
1423 return (
1424 isinstance(other, C)
1425 and other.b1 == self.b1
1426 and other.b2 == self.b2
1427 )
1428
1429 cls.mapper_registry.map_imperatively(
1430 A,
1431 a,
1432 properties={class="st">"b2": relationship(B), class="st">"c": composite(C, class="st">"b1", class="st">"b2")},
1433 )
1434 cls.mapper_registry.map_imperatively(B, b)
1435
1436 def test_early_configure(self):
1437 class="cm"># 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