diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-03 21:26:44 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-11-03 21:34:32 -0400 |
commit | 77a17797ecc08736ea942e29f79df4f96bd74e0c (patch) | |
tree | 80c641bb03d4fdbd703c86b1ee8caf08397cb5fb /test/sql/test_text.py | |
parent | 245a6ce87dbf0abf25d71074b8597bb2a0f8d5fe (diff) | |
download | sqlalchemy-77a17797ecc08736ea942e29f79df4f96bd74e0c.tar.gz |
use ExpressionElementRole for case targets in case()
Fixed regression where the :func:`_sql.text` construct would no longer be
accepted as a target case in the "whens" list within a :func:`_sql.case`
construct. The regression appears related to an attempt to guard against
some forms of literal values that were considered to be ambiguous when
passed here; however, there's no reason the target cases shouldn't be
interpreted as open-ended SQL expressions just like anywhere else, and a
literal string or tuple will be converted to a bound parameter as would be
the case elsewhere.
Fixes: #7287
Change-Id: I75478adfa115f3292cb1362cc5b2fdf152b0ed6f
Diffstat (limited to 'test/sql/test_text.py')
-rw-r--r-- | test/sql/test_text.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/sql/test_text.py b/test/sql/test_text.py index 15f6f6048..4fff0ed7e 100644 --- a/test/sql/test_text.py +++ b/test/sql/test_text.py @@ -6,6 +6,7 @@ from sqlalchemy import bindparam from sqlalchemy import Column from sqlalchemy import desc from sqlalchemy import exc +from sqlalchemy import extract from sqlalchemy import Float from sqlalchemy import func from sqlalchemy import Integer @@ -182,6 +183,14 @@ class SelectCompositionTest(fixtures.TestBase, AssertsCompiledSQL): "(select f from bar where lala=heyhey) foo WHERE foo.f = t.id", ) + def test_expression_element_role(self): + """test #7287""" + + self.assert_compile( + extract("year", text("some_date + :param")), + "EXTRACT(year FROM some_date + :param)", + ) + @testing.combinations( ( None, |