summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-09-23 15:17:57 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-09-23 17:17:02 -0400
commit57b400f07951f0ae8651ca38338ec5be1d222c7e (patch)
tree53139ead8ae3ba89a039d790431e056555b3b3d7 /test/sql
parent9ae645d5d1a8cc7732a6d335be6205d0b21e31b1 (diff)
downloadsqlalchemy-57b400f07951f0ae8651ca38338ec5be1d222c7e.tar.gz
remove should_nest behavior for contains_eager()
Fixed regression for 1.4 in :func:`_orm.contains_eager` where the "wrap in subquery" logic of :func:`_orm.joinedload` would be inadvertently triggered for use of the :func:`_orm.contains_eager` function with similar statements (e.g. those that use ``distinct()``, ``limit()`` or ``offset()``). This is not appropriate for :func:`_orm.contains_eager` which has always had the contract that the user-defined SQL statement is unmodified with the exception of adding the appropriate columns. Also includes an adjustment to the assertion in Label._make_proxy() which was there to prevent a fixed label name from being anonymized; if the label is already anonymous, the change should proceed. This logic was being hit before the contains_eager behavior was adjusted. With the adjustment, this code is not used. Fixes: #8569 Change-Id: I161e65041c0162fd2b83cbef40f57a50fcfaf0fd
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_selectable.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index 3ecbfca27..64ff2e421 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -404,8 +404,10 @@ class SelectableTest(
@testing.combinations((True,), (False,))
def test_broken_select_same_named_explicit_cols(self, use_anon):
- # this is issue #6090. the query is "wrong" and we dont know how
+ """test for #6090. the query is "wrong" and we dont know how
# to render this right now.
+
+ """
stmt = select(
table1.c.col1,
table1.c.col2,
@@ -432,6 +434,24 @@ class SelectableTest(
):
select(stmt.subquery()).compile()
+ def test_same_anon_named_explicit_cols(self):
+ """test for #8569. This adjusts the change in #6090 to not apply
+ to anonymous labels.
+
+ """
+ lc = literal_column("col2").label(None)
+
+ subq1 = select(lc).subquery()
+
+ stmt2 = select(subq1, lc).subquery()
+
+ self.assert_compile(
+ select(stmt2),
+ "SELECT anon_1.col2_1, anon_1.col2_1_1 FROM "
+ "(SELECT anon_2.col2_1 AS col2_1, col2 AS col2_1 FROM "
+ "(SELECT col2 AS col2_1) AS anon_2) AS anon_1",
+ )
+
def test_correlate_none_arg_error(self):
stmt = select(table1)
with expect_raises_message(