diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-12-15 10:22:36 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-12-15 10:34:23 -0500 |
| commit | e06ef2154210ce1a5ced6f58330a258f7adfaa55 (patch) | |
| tree | 5e2d1be6d890ba6586ea4d290e88415ce05dea6e /test/sql | |
| parent | 0f5b3040a419fad404d3e2ea8abfb781be228066 (diff) | |
| download | sqlalchemy-e06ef2154210ce1a5ced6f58330a258f7adfaa55.tar.gz | |
implement literal_binds with expanding + bind_expression
Fixed bug where SQL compilation would fail to make use of
:meth:`_types.TypeEngine.bind_expression` on a given type when used in the
context of an "expanding" (i.e. "IN") parameter with the ``literal_binds``
compiler parameter in use.
Fixes: #8989
Change-Id: Ic9fd27b46381b488117295ea5a492d8fc158e39f
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_type_expressions.py | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/test/sql/test_type_expressions.py b/test/sql/test_type_expressions.py index 6c717123b..c2ecd46e2 100644 --- a/test/sql/test_type_expressions.py +++ b/test/sql/test_type_expressions.py @@ -183,28 +183,40 @@ class SelectTest(_ExprFixture, fixtures.TestBase, AssertsCompiledSQL): "test_table WHERE test_table.y = lower(:y_1)", ) - def test_in_binds(self): + @testing.variation( + "compile_opt", ["plain", "postcompile", "literal_binds"] + ) + def test_in_binds(self, compile_opt): table = self._fixture() - self.assert_compile( - select(table).where( - table.c.y.in_(["hi", "there", "some", "expr"]) - ), - "SELECT test_table.x, lower(test_table.y) AS y FROM " - "test_table WHERE test_table.y IN " - "(__[POSTCOMPILE_y_1~~lower(~~REPL~~)~~])", - render_postcompile=False, + stmt = select(table).where( + table.c.y.in_(["hi", "there", "some", "expr"]) ) - self.assert_compile( - select(table).where( - table.c.y.in_(["hi", "there", "some", "expr"]) - ), - "SELECT test_table.x, lower(test_table.y) AS y FROM " - "test_table WHERE test_table.y IN " - "(lower(:y_1_1), lower(:y_1_2), lower(:y_1_3), lower(:y_1_4))", - render_postcompile=True, - ) + if compile_opt.plain: + self.assert_compile( + stmt, + "SELECT test_table.x, lower(test_table.y) AS y FROM " + "test_table WHERE test_table.y IN " + "(__[POSTCOMPILE_y_1~~lower(~~REPL~~)~~])", + render_postcompile=False, + ) + elif compile_opt.postcompile: + self.assert_compile( + stmt, + "SELECT test_table.x, lower(test_table.y) AS y FROM " + "test_table WHERE test_table.y IN " + "(lower(:y_1_1), lower(:y_1_2), lower(:y_1_3), lower(:y_1_4))", + render_postcompile=True, + ) + elif compile_opt.literal_binds: + self.assert_compile( + stmt, + "SELECT test_table.x, lower(test_table.y) AS y FROM " + "test_table WHERE test_table.y IN " + "(lower('hi'), lower('there'), lower('some'), lower('expr'))", + literal_binds=True, + ) def test_dialect(self): table = self._fixture() |
