MCPcopy Create free account
hub / github.com/zzzeek/sqlalchemy / test_basic

Method test_basic

test/orm/test_eager_relations.py:5071–5103  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5069 )
5070
5071 def test_basic(self):
5072 widget, widget_rel = self.tables.widget, self.tables.widget_rel
5073
5074 class Widget(ComparableEntity):
5075 pass
5076
5077 self.mapper_registry.map_imperatively(
5078 Widget,
5079 widget,
5080 properties={
5081 "children": relationship(
5082 Widget,
5083 secondary=widget_rel,
5084 primaryjoin=widget_rel.c.parent_id == widget.c.id,
5085 secondaryjoin=widget_rel.c.child_id == widget.c.id,
5086 lazy="joined",
5087 join_depth=1,
5088 )
5089 },
5090 )
5091
5092 sess = fixture_session()
5093 w1 = Widget(name="w1")
5094 w2 = Widget(name="w2")
5095 w1.children.append(w2)
5096 sess.add(w1)
5097 sess.flush()
5098 sess.expunge_all()
5099
5100 eq_(
5101 [Widget(name="w1", children=[Widget(name="w2")])],
5102 sess.query(Widget).filter(Widget.name == "w1").all(),
5103 )
5104
5105
5106class MixedEntitiesTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL):

Callers

nothing calls this directly

Calls 12

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
eq_Function · 0.90
map_imperativelyMethod · 0.80
WidgetClass · 0.70
appendMethod · 0.45
addMethod · 0.45
flushMethod · 0.45
expunge_allMethod · 0.45
allMethod · 0.45
filterMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected