summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-02-09 18:05:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-02-09 18:05:40 -0500
commit29dcaa2b0ae2d26b36ec624be80f56e03ab9095e (patch)
treecf77c6d841eec6fcabac2e869560735332e33b46
parentff3be95620b6505943b2d7e4688abc29dca3e493 (diff)
downloadsqlalchemy-29dcaa2b0ae2d26b36ec624be80f56e03ab9095e.tar.gz
- Fixed bug in :func:`.expression.text` construct where a double-colon
expression would not escape properly, e.g. ``some\:\:expr``, as is most commonly required when rendering Postgresql-style CAST expressions. fixes #3644
-rw-r--r--doc/build/changelog/changelog_10.rst8
-rw-r--r--test/sql/test_text.py11
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst
index 6130fdcef..d607110aa 100644
--- a/doc/build/changelog/changelog_10.rst
+++ b/doc/build/changelog/changelog_10.rst
@@ -20,6 +20,14 @@
:released:
.. change::
+ :tags: bug, postgresql
+ :tickets: 3644
+
+ Fixed bug in :func:`.expression.text` construct where a double-colon
+ expression would not escape properly, e.g. ``some\:\:expr``, as is most
+ commonly required when rendering Postgresql-style CAST expressions.
+
+ .. change::
:tags: bug, sql
:tickets: 3643
:pullreq: github:232
diff --git a/test/sql/test_text.py b/test/sql/test_text.py
index 78c3282ac..20cb2a6fb 100644
--- a/test/sql/test_text.py
+++ b/test/sql/test_text.py
@@ -281,6 +281,17 @@ class BindParamTest(fixtures.TestBase, AssertsCompiledSQL):
dialect="postgresql"
)
+ def test_escaping_double_colons(self):
+ self.assert_compile(
+ text(
+ "SELECT * FROM pg_attribute WHERE "
+ "attrelid = :tab\:\:regclass"),
+ "SELECT * FROM pg_attribute WHERE "
+ "attrelid = %(tab)s::regclass",
+ params={'tab': None},
+ dialect="postgresql"
+ )
+
def test_text_in_select_nonfrom(self):
generate_series = text("generate_series(:x, :y, :z) as s(a)").\