MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_mapping_to_outerjoin

Method test_mapping_to_outerjoin

test/orm/test_mapper.py:1703–1732  ·  view source on GitHub ↗

Mapping to an outer join with a nullable composite primary key.

(self)

Source from the content-addressed store, hash-verified

1701 )
1702
1703 def test_mapping_to_outerjoin(self):
1704 """Mapping to an outer join with a nullable composite primary key."""
1705
1706 users, addresses, User = (
1707 self.tables.users,
1708 self.tables.addresses,
1709 self.classes.User,
1710 )
1711
1712 self.mapper(
1713 User,
1714 users.outerjoin(addresses),
1715 primary_key=[users.c.id, addresses.c.id],
1716 properties=dict(address_id=addresses.c.id),
1717 )
1718
1719 session = fixture_session()
1720 result = session.query(User).order_by(User.id, User.address_id).all()
1721
1722 eq_(
1723 result,
1724 [
1725 User(id=7, address_id=1),
1726 User(id=8, address_id=2),
1727 User(id=8, address_id=3),
1728 User(id=8, address_id=4),
1729 User(id=9, address_id=5),
1730 User(id=10, address_id=None),
1731 ],
1732 )
1733
1734 def test_mapping_to_outerjoin_no_partial_pks(self):
1735 """test the allow_partial_pks=False flag."""

Callers

nothing calls this directly

Calls 8

fixture_sessionFunction · 0.90
eq_Function · 0.90
UserClass · 0.70
mapperMethod · 0.45
outerjoinMethod · 0.45
allMethod · 0.45
order_byMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected