summaryrefslogtreecommitdiff
path: root/test
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
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')
-rw-r--r--test/dialect/mysql/test_reflection.py6
-rw-r--r--test/sql/test_text.py19
2 files changed, 22 insertions, 3 deletions
diff --git a/test/dialect/mysql/test_reflection.py b/test/dialect/mysql/test_reflection.py
index dc088223d..9437631d7 100644
--- a/test/dialect/mysql/test_reflection.py
+++ b/test/dialect/mysql/test_reflection.py
@@ -263,7 +263,7 @@ class ReflectionTest(fixtures.TestBase, AssertsExecutionResults):
'mysql_def', MetaData(testing.db),
Column('c1', Integer()),
mysql_engine='MEMORY',
- mysql_comment=comment,
+ comment=comment,
mysql_default_charset='utf8',
mysql_auto_increment='5',
mysql_avg_row_length='3',
@@ -280,7 +280,7 @@ class ReflectionTest(fixtures.TestBase, AssertsExecutionResults):
def_table.drop()
assert def_table.kwargs['mysql_engine'] == 'MEMORY'
- assert def_table.kwargs['mysql_comment'] == comment
+ assert def_table.comment == comment
assert def_table.kwargs['mysql_default_charset'] == 'utf8'
assert def_table.kwargs['mysql_auto_increment'] == '5'
assert def_table.kwargs['mysql_avg_row_length'] == '3'
@@ -288,6 +288,8 @@ class ReflectionTest(fixtures.TestBase, AssertsExecutionResults):
assert def_table.kwargs['mysql_connection'] == 'fish'
assert reflected.kwargs['mysql_engine'] == 'MEMORY'
+
+ assert reflected.comment == comment
assert reflected.kwargs['mysql_comment'] == comment
assert reflected.kwargs['mysql_default charset'] == 'utf8'
assert reflected.kwargs['mysql_avg_row_length'] == '3'
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'