summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-02-03 10:42:08 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-02-03 10:42:08 -0500
commit52728f7052e643e9890da75ef2c756d4bead41f0 (patch)
tree8bfe8a805028563213209322056618f7d34aedbc /test/sql
parenta7eeac60cae28bb553327d317a88adb22c799ef3 (diff)
downloadsqlalchemy-52728f7052e643e9890da75ef2c756d4bead41f0.tar.gz
Add coercions to literal()
To prevent literal() from receiving a ClauseElement which then leads to confusing results, add a new LiteralValueRole coercion that does an _is_literal() check and implement for literal(). Fixes: #5639 Change-Id: Ibd686544af2d7c013765278f984baf237de88caf
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_roles.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/sql/test_roles.py b/test/sql/test_roles.py
index 0ef90e89e..4d905aca9 100644
--- a/test/sql/test_roles.py
+++ b/test/sql/test_roles.py
@@ -145,6 +145,19 @@ class RoleTest(fixtures.TestBase):
)
)
+ def test_no_clauseelement_in_bind(self):
+ with testing.expect_raises_message(
+ exc.ArgumentError,
+ r"Literal Python value expected, got BindParameter",
+ ):
+ literal(bindparam("x"))
+
+ with testing.expect_raises_message(
+ exc.ArgumentError,
+ r"Literal Python value expected, got .*ColumnClause",
+ ):
+ literal(column("q"))
+
def test_scalar_select_no_coercion(self):
with testing.expect_warnings(
"implicitly coercing SELECT object to scalar subquery"