summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_operators.py48
-rw-r--r--test/sql/test_quote.py12
-rw-r--r--test/sql/test_text.py13
3 files changed, 43 insertions, 30 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py
index 7c3ce1389..217af4337 100644
--- a/test/sql/test_operators.py
+++ b/test/sql/test_operators.py
@@ -2258,56 +2258,56 @@ class ComposedLikeOperatorsTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_contains(self):
self.assert_compile(
column('x').contains('y'),
- "x LIKE '%%' || :x_1 || '%%'",
+ "x LIKE '%' || :x_1 || '%'",
checkparams={'x_1': 'y'}
)
def test_contains_escape(self):
self.assert_compile(
column('x').contains('a%b_c', escape='\\'),
- "x LIKE '%%' || :x_1 || '%%' ESCAPE '\\'",
+ "x LIKE '%' || :x_1 || '%' ESCAPE '\\'",
checkparams={'x_1': 'a%b_c'}
)
def test_contains_autoescape(self):
self.assert_compile(
column('x').contains('a%b_c', autoescape='\\'),
- "x LIKE '%%' || :x_1 || '%%' ESCAPE '\\'",
+ "x LIKE '%' || :x_1 || '%' ESCAPE '\\'",
checkparams={'x_1': 'a\\%b\\_c'}
)
def test_contains_literal(self):
self.assert_compile(
column('x').contains(literal_column('y')),
- "x LIKE '%%' || y || '%%'",
+ "x LIKE '%' || y || '%'",
checkparams={}
)
def test_contains_text(self):
self.assert_compile(
column('x').contains(text('y')),
- "x LIKE '%%' || y || '%%'",
+ "x LIKE '%' || y || '%'",
checkparams={}
)
def test_not_contains(self):
self.assert_compile(
~column('x').contains('y'),
- "x NOT LIKE '%%' || :x_1 || '%%'",
+ "x NOT LIKE '%' || :x_1 || '%'",
checkparams={'x_1': 'y'}
)
def test_not_contains_escape(self):
self.assert_compile(
~column('x').contains('a%b_c', escape='\\'),
- "x NOT LIKE '%%' || :x_1 || '%%' ESCAPE '\\'",
+ "x NOT LIKE '%' || :x_1 || '%' ESCAPE '\\'",
checkparams={'x_1': 'a%b_c'}
)
def test_not_contains_autoescape(self):
self.assert_compile(
~column('x').contains('a%b_c', autoescape='\\'),
- "x NOT LIKE '%%' || :x_1 || '%%' ESCAPE '\\'",
+ "x NOT LIKE '%' || :x_1 || '%' ESCAPE '\\'",
checkparams={'x_1': 'a\\%b\\_c'}
)
@@ -2402,56 +2402,56 @@ class ComposedLikeOperatorsTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_startswith(self):
self.assert_compile(
column('x').startswith('y'),
- "x LIKE :x_1 || '%%'",
+ "x LIKE :x_1 || '%'",
checkparams={'x_1': 'y'}
)
def test_startswith_escape(self):
self.assert_compile(
column('x').startswith('a%b_c', escape='\\'),
- "x LIKE :x_1 || '%%' ESCAPE '\\'",
+ "x LIKE :x_1 || '%' ESCAPE '\\'",
checkparams={'x_1': 'a%b_c'}
)
def test_startswith_autoescape(self):
self.assert_compile(
column('x').startswith('a%b_c', autoescape='\\'),
- "x LIKE :x_1 || '%%' ESCAPE '\\'",
+ "x LIKE :x_1 || '%' ESCAPE '\\'",
checkparams={'x_1': 'a\\%b\\_c'}
)
def test_not_startswith(self):
self.assert_compile(
~column('x').startswith('y'),
- "x NOT LIKE :x_1 || '%%'",
+ "x NOT LIKE :x_1 || '%'",
checkparams={'x_1': 'y'}
)
def test_not_startswith_escape(self):
self.assert_compile(
~column('x').startswith('a%b_c', escape='\\'),
- "x NOT LIKE :x_1 || '%%' ESCAPE '\\'",
+ "x NOT LIKE :x_1 || '%' ESCAPE '\\'",
checkparams={'x_1': 'a%b_c'}
)
def test_not_startswith_autoescape(self):
self.assert_compile(
~column('x').startswith('a%b_c', autoescape='\\'),
- "x NOT LIKE :x_1 || '%%' ESCAPE '\\'",
+ "x NOT LIKE :x_1 || '%' ESCAPE '\\'",
checkparams={'x_1': 'a\\%b\\_c'}
)
def test_startswith_literal(self):
self.assert_compile(
column('x').startswith(literal_column('y')),
- "x LIKE y || '%%'",
+ "x LIKE y || '%'",
checkparams={}
)
def test_startswith_text(self):
self.assert_compile(
column('x').startswith(text('y')),
- "x LIKE y || '%%'",
+ "x LIKE y || '%'",
checkparams={}
)
@@ -2506,56 +2506,56 @@ class ComposedLikeOperatorsTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def test_endswith(self):
self.assert_compile(
column('x').endswith('y'),
- "x LIKE '%%' || :x_1",
+ "x LIKE '%' || :x_1",
checkparams={'x_1': 'y'}
)
def test_endswith_escape(self):
self.assert_compile(
column('x').endswith('a%b_c', escape='\\'),
- "x LIKE '%%' || :x_1 ESCAPE '\\'",
+ "x LIKE '%' || :x_1 ESCAPE '\\'",
checkparams={'x_1': 'a%b_c'}
)
def test_endswith_autoescape(self):
self.assert_compile(
column('x').endswith('a%b_c', autoescape='\\'),
- "x LIKE '%%' || :x_1 ESCAPE '\\'",
+ "x LIKE '%' || :x_1 ESCAPE '\\'",
checkparams={'x_1': 'a\\%b\\_c'}
)
def test_not_endswith(self):
self.assert_compile(
~column('x').endswith('y'),
- "x NOT LIKE '%%' || :x_1",
+ "x NOT LIKE '%' || :x_1",
checkparams={'x_1': 'y'}
)
def test_not_endswith_escape(self):
self.assert_compile(
~column('x').endswith('a%b_c', escape='\\'),
- "x NOT LIKE '%%' || :x_1 ESCAPE '\\'",
+ "x NOT LIKE '%' || :x_1 ESCAPE '\\'",
checkparams={'x_1': 'a%b_c'}
)
def test_not_endswith_autoescape(self):
self.assert_compile(
~column('x').endswith('a%b_c', autoescape='\\'),
- "x NOT LIKE '%%' || :x_1 ESCAPE '\\'",
+ "x NOT LIKE '%' || :x_1 ESCAPE '\\'",
checkparams={'x_1': 'a\\%b\\_c'}
)
def test_endswith_literal(self):
self.assert_compile(
column('x').endswith(literal_column('y')),
- "x LIKE '%%' || y",
+ "x LIKE '%' || y",
checkparams={}
)
def test_endswith_text(self):
self.assert_compile(
column('x').endswith(text('y')),
- "x LIKE '%%' || y",
+ "x LIKE '%' || y",
checkparams={}
)
diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py
index a436dde67..477fca783 100644
--- a/test/sql/test_quote.py
+++ b/test/sql/test_quote.py
@@ -1,12 +1,12 @@
-from sqlalchemy import *
+from sqlalchemy import MetaData, Table, Column, Integer, select, \
+ ForeignKey, Index, CheckConstraint, inspect, column
from sqlalchemy import sql, schema
from sqlalchemy.sql import compiler
from sqlalchemy.testing import fixtures, AssertsCompiledSQL, eq_
from sqlalchemy import testing
-from sqlalchemy.sql.elements import (quoted_name,
- _truncated_label,
- _anonymous_label)
+from sqlalchemy.sql.elements import quoted_name, _anonymous_label
from sqlalchemy.testing.util import picklers
+from sqlalchemy.engine import default
class QuoteExecTest(fixtures.TestBase):
@@ -700,7 +700,7 @@ class PreparerTest(fixtures.TestBase):
"""Test the db-agnostic quoting services of IdentifierPreparer."""
def test_unformat(self):
- prep = compiler.IdentifierPreparer(None)
+ prep = compiler.IdentifierPreparer(default.DefaultDialect())
unformat = prep.unformat_identifiers
def a_eq(have, want):
@@ -732,7 +732,7 @@ class PreparerTest(fixtures.TestBase):
def _unescape_identifier(self, value):
return value.replace('``', '`')
- prep = Custom(None)
+ prep = Custom(default.DefaultDialect())
unformat = prep.unformat_identifiers
def a_eq(have, want):
diff --git a/test/sql/test_text.py b/test/sql/test_text.py
index 4a273e1ee..ca4d10702 100644
--- a/test/sql/test_text.py
+++ b/test/sql/test_text.py
@@ -317,6 +317,19 @@ class BindParamTest(fixtures.TestBase, AssertsCompiledSQL):
checkparams={'y': 6, 'x': 5, 'z': 7}
)
+ def test_escaping_percent_signs(self):
+ stmt = text("select '%' where foo like '%bar%'")
+ self.assert_compile(
+ stmt,
+ "select '%' where foo like '%bar%'",
+ dialect="sqlite"
+ )
+
+ self.assert_compile(
+ stmt,
+ "select '%%' where foo like '%%bar%%'",
+ dialect="mysql"
+ )
class AsFromTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'