Test that an joinedload locates the correct "from" clause with which to attach to, when presented with a query that already has a complicated from clause.
(self)
| 245 | eq_(result_str, ["1 Some Category", "3 Some Category"]) |
| 246 | |
| 247 | def test_withjoinedload(self): |
| 248 | """ |
| 249 | Test that an joinedload locates the correct "from" clause with which to |
| 250 | attach to, when presented with a query that already has a complicated |
| 251 | from clause. |
| 252 | |
| 253 | """ |
| 254 | |
| 255 | Thing, tests, options = ( |
| 256 | self.classes.Thing, |
| 257 | self.tables.tests, |
| 258 | self.tables.options, |
| 259 | ) |
| 260 | |
| 261 | s = fixture_session() |
| 262 | q = s.query(Thing).options(sa.orm.joinedload(Thing.category)) |
| 263 | |
| 264 | result = q.select_from( |
| 265 | tests.outerjoin( |
| 266 | options, |
| 267 | sa.and_( |
| 268 | tests.c.id == options.c.test_id, |
| 269 | tests.c.owner_id == options.c.owner_id, |
| 270 | ), |
| 271 | ) |
| 272 | ).filter( |
| 273 | sa.and_( |
| 274 | tests.c.owner_id == 1, |
| 275 | sa.or_( |
| 276 | options.c.someoption == None, |
| 277 | options.c.someoption == False, # noqa |
| 278 | ), |
| 279 | ) |
| 280 | ) |
| 281 | |
| 282 | result_str = ["%d %s" % (t.id, t.category.name) for t in result] |
| 283 | eq_(result_str, ["1 Some Category", "3 Some Category"]) |
| 284 | |
| 285 | def test_dslish(self): |
| 286 | """test the same as withjoinedload except using generative""" |
nothing calls this directly
no test coverage detected