MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_joinedload_on_double

Method test_joinedload_on_double

test/orm/test_manytomany.py:227–285  ·  view source on GitHub ↗

test that a mapper can have two eager relationships to the same table, via two different association tables. aliases are required.

(self)

Source from the content-addressed store, hash-verified

225 assert p2 in p1.parent_places
226
227 def test_joinedload_on_double(self):
228 """test that a mapper can have two eager relationships to the same
229 table, via two different association tables. aliases are required.
230 """
231
232 (
233 place_input,
234 transition,
235 Transition,
236 PlaceThingy,
237 place,
238 place_thingy,
239 Place,
240 place_output,
241 ) = (
242 self.tables.place_input,
243 self.tables.transition,
244 self.classes.Transition,
245 self.classes.PlaceThingy,
246 self.tables.place,
247 self.tables.place_thingy,
248 self.classes.Place,
249 self.tables.place_output,
250 )
251
252 self.mapper_registry.map_imperatively(PlaceThingy, place_thingy)
253 self.mapper_registry.map_imperatively(
254 Place,
255 place,
256 properties={"thingies": relationship(PlaceThingy, lazy="joined")},
257 )
258
259 self.mapper_registry.map_imperatively(
260 Transition,
261 transition,
262 properties=dict(
263 inputs=relationship(Place, place_output, lazy="joined"),
264 outputs=relationship(Place, place_input, lazy="joined"),
265 ),
266 )
267
268 tran = Transition("transition1")
269 tran.inputs.append(Place("place1"))
270 tran.outputs.append(Place("place2"))
271 tran.outputs.append(Place("place3"))
272 sess = fixture_session()
273 sess.add(tran)
274 sess.commit()
275
276 r = sess.query(Transition).all()
277 self.assert_unordered_result(
278 r,
279 Transition,
280 {
281 "name": "transition1",
282 "inputs": (Place, [{"name": "place1"}]),
283 "outputs": (Place, [{"name": "place2"}, {"name": "place3"}]),
284 },

Callers

nothing calls this directly

Calls 11

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
TransitionClass · 0.85
PlaceClass · 0.85
map_imperativelyMethod · 0.80
appendMethod · 0.45
addMethod · 0.45
commitMethod · 0.45
allMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected