MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_no_false_hits

Method test_no_false_hits

test/orm/test_eager_relations.py:1260–1297  ·  view source on GitHub ↗

Eager loaders don't interpret main table columns as part of their eager load.

(self)

Source from the content-addressed store, hash-verified

1258 eq_(q.all(), self.static.address_user_result)
1259
1260 def test_no_false_hits(self):
1261 """Eager loaders don't interpret main table columns as
1262 part of their eager load."""
1263
1264 addresses, orders, User, Address, Order, users = (
1265 self.tables.addresses,
1266 self.tables.orders,
1267 self.classes.User,
1268 self.classes.Address,
1269 self.classes.Order,
1270 self.tables.users,
1271 )
1272
1273 self.mapper_registry.map_imperatively(
1274 User,
1275 users,
1276 properties={
1277 "addresses": relationship(Address, lazy="joined"),
1278 "orders": relationship(Order, lazy="joined"),
1279 },
1280 )
1281 self.mapper_registry.map_imperatively(Address, addresses)
1282 self.mapper_registry.map_imperatively(Order, orders)
1283
1284 self.allusers = fixture_session().query(User).all()
1285
1286 # using a textual select, the columns will be 'id' and 'name'. the
1287 # eager loaders have aliases which should not hit on those columns,
1288 # they should be required to locate only their aliased/fully table
1289 # qualified column name.
1290 noeagers = (
1291 fixture_session()
1292 .query(User)
1293 .from_statement(text("select * from users"))
1294 .all()
1295 )
1296 assert "orders" not in noeagers[0].__dict__
1297 assert "addresses" not in noeagers[0].__dict__
1298
1299 def test_limit(self):
1300 """Limit operations combined with lazy-load relationships."""

Callers

nothing calls this directly

Calls 7

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
textFunction · 0.90
map_imperativelyMethod · 0.80
allMethod · 0.45
queryMethod · 0.45
from_statementMethod · 0.45

Tested by

no test coverage detected