diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2021-03-18 18:44:24 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-03-18 18:44:24 +0000 |
| commit | b728ff1601336459840a7dcdab7697fa3535dbf5 (patch) | |
| tree | 42753364bbb573c6a97ff1dc8ebec1ae115e2baf /test/sql | |
| parent | becf996e1d71b0778c1294fccc1b090b2f39a263 (diff) | |
| parent | dfce8c35d3f95c401957f4d0ddaf8c7f49f52ece (diff) | |
| download | sqlalchemy-b728ff1601336459840a7dcdab7697fa3535dbf5.tar.gz | |
Merge "Raise at Core / ORM concrete inh level for label overlap"
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_selectable.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 762146a3d..458b8f782 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -49,6 +49,7 @@ from sqlalchemy.testing import in_ from sqlalchemy.testing import is_ from sqlalchemy.testing import is_not from sqlalchemy.testing import ne_ +from sqlalchemy.testing.assertions import expect_raises_message metadata = MetaData() @@ -208,6 +209,36 @@ class SelectableTest( checkparams={"param_1": 5}, ) + @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 + # to render this right now. + stmt = select( + table1.c.col1, + table1.c.col2, + literal_column("col2").label(None if use_anon else "col2"), + ).select_from(table1) + + if use_anon: + self.assert_compile( + select(stmt.subquery()), + "SELECT anon_1.col1, anon_1.col2, anon_1.col2_1 FROM " + "(SELECT table1.col1 AS col1, table1.col2 AS col2, " + "col2 AS col2_1 FROM table1) AS anon_1", + ) + else: + # the keys here are not critical as they are not what was + # requested anyway, maybe should raise here also. + eq_(stmt.selected_columns.keys(), ["col1", "col2", "col2_1"]) + with expect_raises_message( + exc.InvalidRequestError, + "Label name col2 is being renamed to an anonymous " + "label due to " + "disambiguation which is not supported right now. Please use " + "unique names for explicit labels.", + ): + select(stmt.subquery()).compile() + def test_select_label_grouped_still_corresponds(self): label = select(table1.c.col1).label("foo") label2 = label.self_group() |
