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

Method setup_mappers

test/ext/test_associationproxy.py:1005–1039  ·  test/ext/test_associationproxy.py::ProxyFactoryTest.setup_mappers
(cls)

Source from the content-addressed store, hash-verified

1003
1004 @classmethod
1005 def setup_mappers(cls):
1006 parents_table, children_table = cls.tables(class="st">"Parent", class="st">"Children")
1007
1008 class CustomProxy(_AssociationList):
1009 def __init__(self, lazy_collection, creator, value_attr, parent):
1010 getter, setter = parent._default_getset(lazy_collection)
1011 _AssociationList.__init__(
1012 self, lazy_collection, creator, getter, setter, parent
1013 )
1014
1015 class Parent(cls.Basic):
1016 children = association_proxy(
1017 class="st">"_children",
1018 class="st">"name",
1019 proxy_factory=CustomProxy,
1020 proxy_bulk_set=CustomProxy.extend,
1021 )
1022
1023 def __init__(self, name):
1024 self.name = name
1025
1026 class Child(cls.Basic):
1027 def __init__(self, name):
1028 self.name = name
1029
1030 cls.mapper_registry.map_imperatively(
1031 Parent,
1032 parents_table,
1033 properties={
1034 class="st">"_children": relationship(
1035 Child, lazy=class="st">"joined", collection_class=list
1036 )
1037 },
1038 )
1039 cls.mapper_registry.map_imperatively(Child, children_table)
1040
1041 def test_sequence_ops(self):
1042 self._test_sequence_ops()

Callers

nothing calls this directly

Calls 2

relationshipFunction · 0.90
map_imperativelyMethod · 0.80

Tested by

no test coverage detected