diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2022-11-11 21:00:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-11-11 21:00:21 +0000 |
commit | 1dd0f23e8d74aa7edc8dd309093a95171e2e8f09 (patch) | |
tree | dda63840955464c225ecf0b09481275bbbf73ac9 /test/dialect/postgresql/test_compiler.py | |
parent | 604611e7e522269ee11b314fb6fb75873a465494 (diff) | |
parent | 8e91cfe529b9b0150c16e52e22e4590bfbbe79fd (diff) | |
download | sqlalchemy-1dd0f23e8d74aa7edc8dd309093a95171e2e8f09.tar.gz |
Merge "establish consistency for RETURNING column labels" into main
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r-- | test/dialect/postgresql/test_compiler.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 96a8e7d5a..338d0da4e 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -61,6 +61,7 @@ from sqlalchemy.testing.assertions import AssertsCompiledSQL from sqlalchemy.testing.assertions import eq_ignore_whitespace from sqlalchemy.testing.assertions import expect_warnings from sqlalchemy.testing.assertions import is_ +from sqlalchemy.types import TypeEngine from sqlalchemy.util import OrderedDict @@ -200,6 +201,35 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): dialect=dialect, ) + @testing.fixture + def column_expression_fixture(self): + class MyString(TypeEngine): + def column_expression(self, column): + return func.lower(column) + + return table( + "some_table", column("name", String), column("value", MyString) + ) + + @testing.combinations("columns", "table", argnames="use_columns") + def test_plain_returning_column_expression( + self, column_expression_fixture, use_columns + ): + """test #8770""" + table1 = column_expression_fixture + + if use_columns == "columns": + stmt = insert(table1).returning(table1) + else: + stmt = insert(table1).returning(table1.c.name, table1.c.value) + + self.assert_compile( + stmt, + "INSERT INTO some_table (name, value) " + "VALUES (%(name)s, %(value)s) RETURNING some_table.name, " + "lower(some_table.value) AS value", + ) + def test_create_drop_enum(self): # test escaping and unicode within CREATE TYPE for ENUM typ = postgresql.ENUM("val1", "val2", "val's 3", "méil", name="myname") |