summaryrefslogtreecommitdiff
path: root/test/sql/test_quote.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-07-18 17:40:58 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-07-18 17:40:58 -0400
commitbb5f4392a4ecbcbaf4e34886a65a8bba42e227d5 (patch)
tree06e392471bc5a7dd866975530333d5a9e74f0757 /test/sql/test_quote.py
parent0eb53b2e7936d2b0a17077a922ce1d97f102e38a (diff)
downloadsqlalchemy-bb5f4392a4ecbcbaf4e34886a65a8bba42e227d5.tar.gz
- update the flake8 rules again
- apply autopep8 + manual fixes to most of test/sql/
Diffstat (limited to 'test/sql/test_quote.py')
-rw-r--r--test/sql/test_quote.py463
1 files changed, 242 insertions, 221 deletions
diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py
index 6a8abde0b..6b0ab4ece 100644
--- a/test/sql/test_quote.py
+++ b/test/sql/test_quote.py
@@ -6,6 +6,7 @@ from sqlalchemy import testing
from sqlalchemy.sql.elements import quoted_name, _truncated_label, _anonymous_label
from sqlalchemy.testing.util import picklers
+
class QuoteExecTest(fixtures.TestBase):
__backend__ = True
@@ -19,14 +20,14 @@ class QuoteExecTest(fixtures.TestBase):
metadata = MetaData(testing.db)
table1 = Table('WorstCase1', metadata,
- Column('lowercase', Integer, primary_key=True),
- Column('UPPERCASE', Integer),
- Column('MixedCase', Integer),
- Column('ASC', Integer, key='a123'))
+ Column('lowercase', Integer, primary_key=True),
+ Column('UPPERCASE', Integer),
+ Column('MixedCase', Integer),
+ Column('ASC', Integer, key='a123'))
table2 = Table('WorstCase2', metadata,
- Column('desc', Integer, primary_key=True, key='d123'),
- Column('Union', Integer, key='u123'),
- Column('MixedCase', Integer))
+ Column('desc', Integer, primary_key=True, key='d123'),
+ Column('Union', Integer, key='u123'),
+ Column('MixedCase', Integer))
table1.create()
table2.create()
@@ -70,25 +71,25 @@ class QuoteExecTest(fixtures.TestBase):
else:
testing.db.execute("CREATE TABLE tab1 (id INTEGER)")
testing.db.execute('CREATE TABLE %s (id INTEGER)' %
- preparer.quote_identifier("tab2"))
+ preparer.quote_identifier("tab2"))
testing.db.execute('CREATE TABLE %s (id INTEGER)' %
- preparer.quote_identifier("TAB3"))
+ preparer.quote_identifier("TAB3"))
testing.db.execute('CREATE TABLE %s (id INTEGER)' %
- preparer.quote_identifier("TAB4"))
+ preparer.quote_identifier("TAB4"))
t1 = Table('tab1', self.metadata,
- Column('id', Integer, primary_key=True),
- )
+ Column('id', Integer, primary_key=True),
+ )
t2 = Table('tab2', self.metadata,
- Column('id', Integer, primary_key=True),
- quote=True
- )
+ Column('id', Integer, primary_key=True),
+ quote=True
+ )
t3 = Table('TAB3', self.metadata,
- Column('id', Integer, primary_key=True),
- )
+ Column('id', Integer, primary_key=True),
+ )
t4 = Table('TAB4', self.metadata,
- Column('id', Integer, primary_key=True),
- quote=True)
+ Column('id', Integer, primary_key=True),
+ quote=True)
insp = inspect(testing.db)
assert testing.db.has_table(t1.name)
@@ -103,8 +104,6 @@ class QuoteExecTest(fixtures.TestBase):
assert testing.db.has_table(t4.name)
eq_([c['name'] for c in insp.get_columns(t4.name)], ['id'])
-
-
def test_basic(self):
table1.insert().execute(
{'lowercase': 1, 'UPPERCASE': 2, 'MixedCase': 3, 'a123': 4},
@@ -159,6 +158,7 @@ class QuoteExecTest(fixtures.TestBase):
result = select(columns, use_labels=True).execute().fetchall()
assert(result == [(1, 2, 3), (2, 2, 3), (4, 3, 2)])
+
class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
@@ -172,14 +172,14 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
metadata = MetaData(testing.db)
table1 = Table('WorstCase1', metadata,
- Column('lowercase', Integer, primary_key=True),
- Column('UPPERCASE', Integer),
- Column('MixedCase', Integer),
- Column('ASC', Integer, key='a123'))
+ Column('lowercase', Integer, primary_key=True),
+ Column('UPPERCASE', Integer),
+ Column('MixedCase', Integer),
+ Column('ASC', Integer, key='a123'))
table2 = Table('WorstCase2', metadata,
- Column('desc', Integer, primary_key=True, key='d123'),
- Column('Union', Integer, key='u123'),
- Column('MixedCase', Integer))
+ Column('desc', Integer, primary_key=True, key='d123'),
+ Column('Union', Integer, key='u123'),
+ Column('MixedCase', Integer))
@testing.crashes('oracle', 'FIXME: unknown, verify not fails_on')
@testing.requires.subqueries
@@ -206,17 +206,17 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
self.assert_compile(
table1.select(distinct=True).alias('LaLa').select(),
'SELECT '
- '"LaLa".lowercase, '
- '"LaLa"."UPPERCASE", '
- '"LaLa"."MixedCase", '
- '"LaLa"."ASC" '
+ '"LaLa".lowercase, '
+ '"LaLa"."UPPERCASE", '
+ '"LaLa"."MixedCase", '
+ '"LaLa"."ASC" '
'FROM ('
- 'SELECT DISTINCT '
- '"WorstCase1".lowercase AS lowercase, '
- '"WorstCase1"."UPPERCASE" AS "UPPERCASE", '
- '"WorstCase1"."MixedCase" AS "MixedCase", '
- '"WorstCase1"."ASC" AS "ASC" '
- 'FROM "WorstCase1"'
+ 'SELECT DISTINCT '
+ '"WorstCase1".lowercase AS lowercase, '
+ '"WorstCase1"."UPPERCASE" AS "UPPERCASE", '
+ '"WorstCase1"."MixedCase" AS "MixedCase", '
+ '"WorstCase1"."ASC" AS "ASC" '
+ 'FROM "WorstCase1"'
') AS "LaLa"'
)
@@ -224,8 +224,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create table with quote defaults
metadata = MetaData()
t1 = Table('t1', metadata,
- Column('col1', Integer),
- schema='foo')
+ Column('col1', Integer),
+ schema='foo')
# Note that the names are not quoted b/c they are all lower case
result = 'CREATE TABLE foo.t1 (col1 INTEGER)'
@@ -234,8 +234,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create the same table with quotes set to True now
metadata = MetaData()
t1 = Table('t1', metadata,
- Column('col1', Integer, quote=True),
- schema='foo', quote=True, quote_schema=True)
+ Column('col1', Integer, quote=True),
+ schema='foo', quote=True, quote_schema=True)
# Note that the names are now quoted
result = 'CREATE TABLE "foo"."t1" ("col1" INTEGER)'
@@ -245,8 +245,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create table with quote defaults
metadata = MetaData()
t1 = Table('TABLE1', metadata,
- Column('COL1', Integer),
- schema='FOO')
+ Column('COL1', Integer),
+ schema='FOO')
# Note that the names are quoted b/c they are not all lower case
result = 'CREATE TABLE "FOO"."TABLE1" ("COL1" INTEGER)'
@@ -255,8 +255,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create the same table with quotes set to False now
metadata = MetaData()
t1 = Table('TABLE1', metadata,
- Column('COL1', Integer, quote=False),
- schema='FOO', quote=False, quote_schema=False)
+ Column('COL1', Integer, quote=False),
+ schema='FOO', quote=False, quote_schema=False)
# Note that the names are now unquoted
result = 'CREATE TABLE FOO.TABLE1 (COL1 INTEGER)'
@@ -266,8 +266,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create table with quote defaults
metadata = MetaData()
t1 = Table('Table1', metadata,
- Column('Col1', Integer),
- schema='Foo')
+ Column('Col1', Integer),
+ schema='Foo')
# Note that the names are quoted b/c they are not all lower case
result = 'CREATE TABLE "Foo"."Table1" ("Col1" INTEGER)'
@@ -276,8 +276,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create the same table with quotes set to False now
metadata = MetaData()
t1 = Table('Table1', metadata,
- Column('Col1', Integer, quote=False),
- schema='Foo', quote=False, quote_schema=False)
+ Column('Col1', Integer, quote=False),
+ schema='Foo', quote=False, quote_schema=False)
# Note that the names are now unquoted
result = 'CREATE TABLE Foo.Table1 (Col1 INTEGER)'
@@ -287,8 +287,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create table with quote defaults
metadata = MetaData()
t1 = Table('35table', metadata,
- Column('25column', Integer),
- schema='45schema')
+ Column('25column', Integer),
+ schema='45schema')
# Note that the names are quoted b/c the initial
# character is in ['$','0', '1' ... '9']
@@ -298,8 +298,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create the same table with quotes set to False now
metadata = MetaData()
t1 = Table('35table', metadata,
- Column('25column', Integer, quote=False),
- schema='45schema', quote=False, quote_schema=False)
+ Column('25column', Integer, quote=False),
+ schema='45schema', quote=False, quote_schema=False)
# Note that the names are now unquoted
result = 'CREATE TABLE 45schema.35table (25column INTEGER)'
@@ -309,8 +309,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create table with quote defaults
metadata = MetaData()
t1 = Table('$table', metadata,
- Column('$column', Integer),
- schema='$schema')
+ Column('$column', Integer),
+ schema='$schema')
# Note that the names are quoted b/c the initial
# character is in ['$','0', '1' ... '9']
@@ -320,8 +320,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create the same table with quotes set to False now
metadata = MetaData()
t1 = Table('$table', metadata,
- Column('$column', Integer, quote=False),
- schema='$schema', quote=False, quote_schema=False)
+ Column('$column', Integer, quote=False),
+ schema='$schema', quote=False, quote_schema=False)
# Note that the names are now unquoted
result = 'CREATE TABLE $schema.$table ($column INTEGER)'
@@ -331,117 +331,117 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Create table with quote defaults
metadata = MetaData()
table = Table('foreign', metadata,
- Column('col1', Integer),
- Column('from', Integer),
- Column('order', Integer),
- schema='create')
+ Column('col1', Integer),
+ Column('from', Integer),
+ Column('order', Integer),
+ schema='create')
# Note that the names are quoted b/c they are reserved words
x = select([table.c.col1, table.c['from'], table.c.order])
self.assert_compile(x,
- 'SELECT '
- '"create"."foreign".col1, '
- '"create"."foreign"."from", '
- '"create"."foreign"."order" '
- 'FROM "create"."foreign"'
- )
+ 'SELECT '
+ '"create"."foreign".col1, '
+ '"create"."foreign"."from", '
+ '"create"."foreign"."order" '
+ 'FROM "create"."foreign"'
+ )
# Create the same table with quotes set to False now
metadata = MetaData()
table = Table('foreign', metadata,
- Column('col1', Integer),
- Column('from', Integer, quote=False),
- Column('order', Integer, quote=False),
- schema='create', quote=False, quote_schema=False)
+ Column('col1', Integer),
+ Column('from', Integer, quote=False),
+ Column('order', Integer, quote=False),
+ schema='create', quote=False, quote_schema=False)
# Note that the names are now unquoted
x = select([table.c.col1, table.c['from'], table.c.order])
self.assert_compile(x,
- 'SELECT '
- 'create.foreign.col1, '
- 'create.foreign.from, '
- 'create.foreign.order '
- 'FROM create.foreign'
- )
+ 'SELECT '
+ 'create.foreign.col1, '
+ 'create.foreign.from, '
+ 'create.foreign.order '
+ 'FROM create.foreign'
+ )
def test_subquery_one(self):
# Lower case names, should not quote
metadata = MetaData()
t1 = Table('t1', metadata,
- Column('col1', Integer),
- schema='foo')
+ Column('col1', Integer),
+ schema='foo')
a = t1.select().alias('anon')
b = select([1], a.c.col1 == 2, from_obj=a)
self.assert_compile(b,
- 'SELECT 1 '
- 'FROM ('
- 'SELECT '
- 'foo.t1.col1 AS col1 '
- 'FROM '
- 'foo.t1'
- ') AS anon '
- 'WHERE anon.col1 = :col1_1'
- )
+ 'SELECT 1 '
+ 'FROM ('
+ 'SELECT '
+ 'foo.t1.col1 AS col1 '
+ 'FROM '
+ 'foo.t1'
+ ') AS anon '
+ 'WHERE anon.col1 = :col1_1'
+ )
def test_subquery_two(self):
# Lower case names, quotes on, should quote
metadata = MetaData()
t1 = Table('t1', metadata,
- Column('col1', Integer, quote=True),
- schema='foo', quote=True, quote_schema=True)
+ Column('col1', Integer, quote=True),
+ schema='foo', quote=True, quote_schema=True)
a = t1.select().alias('anon')
b = select([1], a.c.col1 == 2, from_obj=a)
self.assert_compile(b,
- 'SELECT 1 '
- 'FROM ('
- 'SELECT '
- '"foo"."t1"."col1" AS "col1" '
- 'FROM '
- '"foo"."t1"'
- ') AS anon '
- 'WHERE anon."col1" = :col1_1'
- )
+ 'SELECT 1 '
+ 'FROM ('
+ 'SELECT '
+ '"foo"."t1"."col1" AS "col1" '
+ 'FROM '
+ '"foo"."t1"'
+ ') AS anon '
+ 'WHERE anon."col1" = :col1_1'
+ )
def test_subquery_three(self):
# Not lower case names, should quote
metadata = MetaData()
t1 = Table('T1', metadata,
- Column('Col1', Integer),
- schema='Foo')
+ Column('Col1', Integer),
+ schema='Foo')
a = t1.select().alias('Anon')
b = select([1], a.c.Col1 == 2, from_obj=a)
self.assert_compile(b,
- 'SELECT 1 '
- 'FROM ('
- 'SELECT '
- '"Foo"."T1"."Col1" AS "Col1" '
- 'FROM '
- '"Foo"."T1"'
- ') AS "Anon" '
- 'WHERE '
- '"Anon"."Col1" = :Col1_1'
- )
+ 'SELECT 1 '
+ 'FROM ('
+ 'SELECT '
+ '"Foo"."T1"."Col1" AS "Col1" '
+ 'FROM '
+ '"Foo"."T1"'
+ ') AS "Anon" '
+ 'WHERE '
+ '"Anon"."Col1" = :Col1_1'
+ )
def test_subquery_four(self):
# Not lower case names, quotes off, should not quote
metadata = MetaData()
t1 = Table('T1', metadata,
- Column('Col1', Integer, quote=False),
- schema='Foo', quote=False, quote_schema=False)
+ Column('Col1', Integer, quote=False),
+ schema='Foo', quote=False, quote_schema=False)
a = t1.select().alias('Anon')
b = select([1], a.c.Col1 == 2, from_obj=a)
self.assert_compile(b,
- 'SELECT 1 '
- 'FROM ('
- 'SELECT '
- 'Foo.T1.Col1 AS Col1 '
- 'FROM '
- 'Foo.T1'
- ') AS "Anon" '
- 'WHERE '
- '"Anon".Col1 = :Col1_1'
- )
+ 'SELECT 1 '
+ 'FROM ('
+ 'SELECT '
+ 'Foo.T1.Col1 AS Col1 '
+ 'FROM '
+ 'Foo.T1'
+ ') AS "Anon" '
+ 'WHERE '
+ '"Anon".Col1 = :Col1_1'
+ )
def test_simple_order_by_label(self):
m = MetaData()
@@ -456,170 +456,188 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
# Lower case names, should not quote
metadata = MetaData()
t1 = Table('t1', metadata,
- Column('col1', Integer))
+ Column('col1', Integer))
t2 = Table('t2', metadata,
- Column('col1', Integer),
- Column('t1col1', Integer, ForeignKey('t1.col1')))
+ Column('col1', Integer),
+ Column('t1col1', Integer, ForeignKey('t1.col1')))
self.assert_compile(t2.join(t1).select(),
- 'SELECT '
- 't2.col1, t2.t1col1, t1.col1 '
- 'FROM '
- 't2 '
- 'JOIN '
- 't1 ON t1.col1 = t2.t1col1'
- )
+ 'SELECT '
+ 't2.col1, t2.t1col1, t1.col1 '
+ 'FROM '
+ 't2 '
+ 'JOIN '
+ 't1 ON t1.col1 = t2.t1col1'
+ )
# Lower case names, quotes on, should quote
metadata = MetaData()
t1 = Table('t1', metadata,
- Column('col1', Integer, quote=True),
- quote=True)
- t2 = Table('t2', metadata,
- Column('col1', Integer, quote=True),
- Column('t1col1', Integer, ForeignKey('t1.col1'), quote=True),
- quote=True)
+ Column('col1', Integer, quote=True),
+ quote=True)
+ t2 = Table(
+ 't2',
+ metadata,
+ Column(
+ 'col1',
+ Integer,
+ quote=True),
+ Column(
+ 't1col1',
+ Integer,
+ ForeignKey('t1.col1'),
+ quote=True),
+ quote=True)
self.assert_compile(t2.join(t1).select(),
- 'SELECT '
- '"t2"."col1", "t2"."t1col1", "t1"."col1" '
- 'FROM '
- '"t2" '
- 'JOIN '
- '"t1" ON "t1"."col1" = "t2"."t1col1"'
- )
+ 'SELECT '
+ '"t2"."col1", "t2"."t1col1", "t1"."col1" '
+ 'FROM '
+ '"t2" '
+ 'JOIN '
+ '"t1" ON "t1"."col1" = "t2"."t1col1"'
+ )
# Not lower case names, should quote
metadata = MetaData()
t1 = Table('T1', metadata,
- Column('Col1', Integer))
+ Column('Col1', Integer))
t2 = Table('T2', metadata,
- Column('Col1', Integer),
- Column('T1Col1', Integer, ForeignKey('T1.Col1')))
+ Column('Col1', Integer),
+ Column('T1Col1', Integer, ForeignKey('T1.Col1')))
self.assert_compile(t2.join(t1).select(),
- 'SELECT '
- '"T2"."Col1", "T2"."T1Col1", "T1"."Col1" '
- 'FROM '
- '"T2" '
- 'JOIN '
- '"T1" ON "T1"."Col1" = "T2"."T1Col1"'
- )
+ 'SELECT '
+ '"T2"."Col1", "T2"."T1Col1", "T1"."Col1" '
+ 'FROM '
+ '"T2" '
+ 'JOIN '
+ '"T1" ON "T1"."Col1" = "T2"."T1Col1"'
+ )
# Not lower case names, quotes off, should not quote
metadata = MetaData()
t1 = Table('T1', metadata,
- Column('Col1', Integer, quote=False),
- quote=False)
- t2 = Table('T2', metadata,
- Column('Col1', Integer, quote=False),
- Column('T1Col1', Integer, ForeignKey('T1.Col1'), quote=False),
- quote=False)
+ Column('Col1', Integer, quote=False),
+ quote=False)
+ t2 = Table(
+ 'T2',
+ metadata,
+ Column(
+ 'Col1',
+ Integer,
+ quote=False),
+ Column(
+ 'T1Col1',
+ Integer,
+ ForeignKey('T1.Col1'),
+ quote=False),
+ quote=False)
self.assert_compile(t2.join(t1).select(),
- 'SELECT '
- 'T2.Col1, T2.T1Col1, T1.Col1 '
- 'FROM '
- 'T2 '
- 'JOIN '
- 'T1 ON T1.Col1 = T2.T1Col1'
- )
+ 'SELECT '
+ 'T2.Col1, T2.T1Col1, T1.Col1 '
+ 'FROM '
+ 'T2 '
+ 'JOIN '
+ 'T1 ON T1.Col1 = T2.T1Col1'
+ )
def test_label_and_alias(self):
# Lower case names, should not quote
metadata = MetaData()
table = Table('t1', metadata,
- Column('col1', Integer))
+ Column('col1', Integer))
x = select([table.c.col1.label('label1')]).alias('alias1')
self.assert_compile(select([x.c.label1]),
- 'SELECT '
- 'alias1.label1 '
- 'FROM ('
- 'SELECT '
- 't1.col1 AS label1 '
- 'FROM t1'
- ') AS alias1'
- )
+ 'SELECT '
+ 'alias1.label1 '
+ 'FROM ('
+ 'SELECT '
+ 't1.col1 AS label1 '
+ 'FROM t1'
+ ') AS alias1'
+ )
# Not lower case names, should quote
metadata = MetaData()
table = Table('T1', metadata,
- Column('Col1', Integer))
+ Column('Col1', Integer))
x = select([table.c.Col1.label('Label1')]).alias('Alias1')
self.assert_compile(select([x.c.Label1]),
- 'SELECT '
- '"Alias1"."Label1" '
- 'FROM ('
- 'SELECT '
- '"T1"."Col1" AS "Label1" '
- 'FROM "T1"'
- ') AS "Alias1"'
- )
+ 'SELECT '
+ '"Alias1"."Label1" '
+ 'FROM ('
+ 'SELECT '
+ '"T1"."Col1" AS "Label1" '
+ 'FROM "T1"'
+ ') AS "Alias1"'
+ )
def test_literal_column_already_with_quotes(self):
# Lower case names
metadata = MetaData()
table = Table('t1', metadata,
- Column('col1', Integer))
+ Column('col1', Integer))
# Note that 'col1' is already quoted (literal_column)
columns = [sql.literal_column("'col1'").label('label1')]
x = select(columns, from_obj=[table]).alias('alias1')
x = x.select()
self.assert_compile(x,
- 'SELECT '
- 'alias1.label1 '
- 'FROM ('
- 'SELECT '
- '\'col1\' AS label1 '
- 'FROM t1'
- ') AS alias1'
- )
+ 'SELECT '
+ 'alias1.label1 '
+ 'FROM ('
+ 'SELECT '
+ '\'col1\' AS label1 '
+ 'FROM t1'
+ ') AS alias1'
+ )
# Not lower case names
metadata = MetaData()
table = Table('T1', metadata,
- Column('Col1', Integer))
+ Column('Col1', Integer))
# Note that 'Col1' is already quoted (literal_column)
columns = [sql.literal_column("'Col1'").label('Label1')]
x = select(columns, from_obj=[table]).alias('Alias1')
x = x.select()
self.assert_compile(x,
- 'SELECT '
- '"Alias1"."Label1" '
- 'FROM ('
- 'SELECT '
- '\'Col1\' AS "Label1" '
- 'FROM "T1"'
- ') AS "Alias1"'
- )
+ 'SELECT '
+ '"Alias1"."Label1" '
+ 'FROM ('
+ 'SELECT '
+ '\'Col1\' AS "Label1" '
+ 'FROM "T1"'
+ ') AS "Alias1"'
+ )
def test_apply_labels_should_quote(self):
# Not lower case names, should quote
metadata = MetaData()
t1 = Table('T1', metadata,
- Column('Col1', Integer),
- schema='Foo')
+ Column('Col1', Integer),
+ schema='Foo')
self.assert_compile(t1.select().apply_labels(),
- 'SELECT '
- '"Foo"."T1"."Col1" AS "Foo_T1_Col1" '
- 'FROM '
- '"Foo"."T1"'
- )
+ 'SELECT '
+ '"Foo"."T1"."Col1" AS "Foo_T1_Col1" '
+ 'FROM '
+ '"Foo"."T1"'
+ )
def test_apply_labels_shouldnt_quote(self):
# Not lower case names, quotes off
metadata = MetaData()
t1 = Table('T1', metadata,
- Column('Col1', Integer, quote=False),
- schema='Foo', quote=False, quote_schema=False)
+ Column('Col1', Integer, quote=False),
+ schema='Foo', quote=False, quote_schema=False)
# TODO: is this what we really want here ?
# what if table/schema *are* quoted?
self.assert_compile(t1.select().apply_labels(),
- 'SELECT '
- 'Foo.T1.Col1 AS Foo_T1_Col1 '
- 'FROM '
- 'Foo.T1'
- )
+ 'SELECT '
+ 'Foo.T1.Col1 AS Foo_T1_Col1 '
+ 'FROM '
+ 'Foo.T1'
+ )
def test_quote_flag_propagate_check_constraint(self):
m = MetaData()
@@ -657,7 +675,9 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
'SELECT "t2".x AS "t2_x" FROM "t2"'
)
+
class PreparerTest(fixtures.TestBase):
+
"""Test the db-agnostic quoting services of IdentifierPreparer."""
def test_unformat(self):
@@ -711,7 +731,9 @@ class PreparerTest(fixtures.TestBase):
a_eq(unformat('`foo`.bar'), ['foo', 'bar'])
a_eq(unformat('`foo`.`b``a``r`.`baz`'), ['foo', 'b`a`r', 'baz'])
+
class QuotedIdentTest(fixtures.TestBase):
+
def test_concat_quotetrue(self):
q1 = quoted_name("x", True)
self._assert_not_quoted("y" + q1)
@@ -802,4 +824,3 @@ class QuotedIdentTest(fixtures.TestBase):
def _assert_not_quoted(self, value):
assert not isinstance(value, quoted_name)
-