]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Test double colons without escaping in text()
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 26 Mar 2019 17:29:57 +0000 (13:29 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 26 Mar 2019 17:29:57 +0000 (13:29 -0400)
Apparently the BIND_PARAMS regex passes over double colons,
it just doesn't accommodate for a bound parameter in that case.
add this use case to current tests as people can be relying upon it.

Change-Id: I6555621b1bb05d09b17428f4b4094ff7b219b460

test/sql/test_text.py

index bcaf905fe69512dcd27879aafc9f56be211ab01d..188ac3878caaa9d2acf78d67e17a11fcb53d860c 100644 (file)
@@ -331,6 +331,19 @@ class BindParamTest(fixtures.TestBase, AssertsCompiledSQL):
             dialect="postgresql",
         )
 
+    def test_double_colons_dont_actually_need_escaping(self):
+        # this is news to me. bound param won't work but you can put the
+        # double colons in
+        self.assert_compile(
+            text(
+                r"SELECT * FROM pg_attribute WHERE "
+                r"attrelid = foo::regclass"
+            ),
+            "SELECT * FROM pg_attribute WHERE " "attrelid = foo::regclass",
+            params={},
+            dialect="postgresql",
+        )
+
     def test_text_in_select_nonfrom(self):
 
         generate_series = text(