MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_with_expr_four

Method test_with_expr_four

test/orm/test_core_compilation.py:1630–1657  ·  view source on GitHub ↗

test :ticket:`6259`

(self, query_expression_w_joinedload_fixture)

Source from the content-addressed store, hash-verified

1628 )
1629
1630 def test_with_expr_four(self, query_expression_w_joinedload_fixture):
1631 """test :ticket:`6259`"""
1632 User = query_expression_w_joinedload_fixture
1633
1634 stmt = (
1635 select(User)
1636 .options(
1637 with_expression(User.value, null()), joinedload(User.addresses)
1638 )
1639 .limit(1)
1640 )
1641
1642 # test that the outer IS NULL is rendered, not adapted
1643 # test that the inner query includes the NULL we asked for
1644
1645 # ironically, this statement would not actually fetch due to the NULL
1646 # not allowing adaption and therefore failing on the result set
1647 # matching, this was addressed in #7154.
1648 self.assert_compile(
1649 stmt,
1650 "SELECT anon_2.anon_1, anon_2.id, anon_2.name, "
1651 "addresses_1.id AS id_1, addresses_1.user_id, "
1652 "addresses_1.email_address FROM (SELECT NULL AS anon_1, "
1653 "users.id AS id, users.name AS name FROM users LIMIT :param_1) "
1654 "AS anon_2 LEFT OUTER JOIN addresses AS addresses_1 "
1655 "ON addresses_1.user_id = anon_2.id "
1656 "AND addresses_1.email_address IS NOT NULL",
1657 )
1658
1659 def test_joinedload_outermost(self, plain_fixture):
1660 User, Address = plain_fixture

Callers

nothing calls this directly

Calls 7

selectFunction · 0.90
with_expressionFunction · 0.90
nullFunction · 0.90
joinedloadFunction · 0.90
assert_compileMethod · 0.80
limitMethod · 0.45
optionsMethod · 0.45

Tested by

no test coverage detected