summaryrefslogtreecommitdiff
path: root/test/sql/test_text.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-08-25 15:26:02 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-08-25 16:53:49 -0400
commit2392ae1900f112c44ed966783d1dedfb88f13353 (patch)
tree405791ed1dacde958b0e5be9f4a36bd66190345e /test/sql/test_text.py
parent887fb3ebaad20847edc752f5fcf072ace947d56a (diff)
downloadsqlalchemy-2392ae1900f112c44ed966783d1dedfb88f13353.tar.gz
Apply percent sign escaping to literal binds, comments
Fixed bug in new percent-sign support (e.g. :ticket:`3740`) where a bound parameter rendered with literal_binds would fail to escape percent-signs for relevant dialects. In addition, ensured new table / column comment support feature also fully makes use of literal-rendered parameters so that this percent sign support takes place with table / column comment DDL as well, allowing percent sign support for the mysql / psycopg2 backends that require escaping of percent signs. Change-Id: Ia4136a300933e9bc6a01a7b9afd5c7b9a3fee4e3 Fixes: #4054 Fixes: #4052
Diffstat (limited to 'test/sql/test_text.py')
-rw-r--r--test/sql/test_text.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/sql/test_text.py b/test/sql/test_text.py
index ca4d10702..c31c22853 100644
--- a/test/sql/test_text.py
+++ b/test/sql/test_text.py
@@ -4,7 +4,7 @@ from sqlalchemy.testing import fixtures, AssertsCompiledSQL, eq_, \
assert_raises_message, expect_warnings, assert_warnings
from sqlalchemy import text, select, Integer, String, Float, \
bindparam, and_, func, literal_column, exc, MetaData, Table, Column,\
- asc, func, desc, union
+ asc, func, desc, union, literal
from sqlalchemy.types import NullType
from sqlalchemy.sql import table, column, util as sql_util
from sqlalchemy import util
@@ -331,6 +331,23 @@ class BindParamTest(fixtures.TestBase, AssertsCompiledSQL):
dialect="mysql"
)
+ def test_percent_signs_literal_binds(self):
+ stmt = select([literal("percent % signs %%")])
+ self.assert_compile(
+ stmt,
+ "SELECT 'percent % signs %%' AS anon_1",
+ dialect="sqlite",
+ literal_binds=True
+ )
+
+ self.assert_compile(
+ stmt,
+ "SELECT 'percent %% signs %%%%' AS anon_1",
+ dialect="mysql",
+ literal_binds=True
+ )
+
+
class AsFromTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'