(self)
| 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 | |
| 5106 | class MixedEntitiesTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): |
nothing calls this directly
no test coverage detected