MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_limit_4

Method test_limit_4

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

Source from the content-addressed store, hash-verified

1570 )
1571
1572 def test_limit_4(self):
1573 User, Order, addresses, users, orders = (
1574 self.classes.User,
1575 self.classes.Order,
1576 self.tables.addresses,
1577 self.tables.users,
1578 self.tables.orders,
1579 )
1580
1581 # tests the LIMIT/OFFSET aliasing on a mapper
1582 # against a select. original issue from ticket #904
1583 sel = (
1584 sa.select(users, addresses.c.email_address)
1585 .where(
1586 users.c.id == addresses.c.user_id,
1587 )
1588 .alias("useralias")
1589 )
1590 self.mapper_registry.map_imperatively(
1591 User,
1592 sel,
1593 properties={
1594 "orders": relationship(
1595 Order,
1596 primaryjoin=sel.c.id == orders.c.user_id,
1597 lazy="joined",
1598 order_by=orders.c.id,
1599 )
1600 },
1601 )
1602 self.mapper_registry.map_imperatively(Order, orders)
1603
1604 sess = fixture_session()
1605 eq_(
1606 sess.query(User).first(),
1607 User(
1608 name="jack",
1609 orders=[
1610 Order(
1611 address_id=1,
1612 description="order 1",
1613 isopen=0,
1614 user_id=7,
1615 id=1,
1616 ),
1617 Order(
1618 address_id=1,
1619 description="order 3",
1620 isopen=1,
1621 user_id=7,
1622 id=3,
1623 ),
1624 Order(
1625 address_id=None,
1626 description="order 5",
1627 isopen=0,
1628 user_id=7,
1629 id=5,

Callers

nothing calls this directly

Calls 11

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
eq_Function · 0.90
map_imperativelyMethod · 0.80
UserClass · 0.70
OrderClass · 0.70
aliasMethod · 0.45
whereMethod · 0.45
selectMethod · 0.45
firstMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected