diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-01-09 22:17:59 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-01-12 13:01:26 -0500 |
| commit | 7402987fd218c42ed2a909a5031186d2b702bb88 (patch) | |
| tree | a418897eb557bbdad09878aa7dcc2e2aab7dfb3a /test/sql | |
| parent | 127ead7452f326509cde38fcf7c9f38f69d9ae0a (diff) | |
| download | sqlalchemy-7402987fd218c42ed2a909a5031186d2b702bb88.tar.gz | |
Make column-level collation quoting dialect-specific
Fixed regression in 1.2 where newly repaired quoting
of collation names in :ticket:`3785` breaks SQL Server,
which explicitly does not understand a quoted collation
name. Whether or not mixed-case collation names are
quoted or not is now deferred down to a dialect-level
decision so that each dialect can prepare these identifiers
directly.
Change-Id: Iaf0a8123d9bf4711219e320896bb28c5d2649304
Fixes: #4154
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_compiler.py | 19 | ||||
| -rw-r--r-- | test/sql/test_quote.py | 11 |
2 files changed, 28 insertions, 2 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 988230ac5..25eb2b24b 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -1450,6 +1450,25 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): []).compile, dialect=empty_in_dialect) + def test_collate(self): + # columns clause + self.assert_compile( + select([column('x').collate('bar')]), + "SELECT x COLLATE bar AS anon_1" + ) + + # WHERE clause + self.assert_compile( + select([column('x')]).where(column('x').collate('bar') == 'foo'), + "SELECT x WHERE (x COLLATE bar) = :param_1" + ) + + # ORDER BY clause + self.assert_compile( + select([column('x')]).order_by(column('x').collate('bar')), + "SELECT x ORDER BY x COLLATE bar" + ) + def test_literal(self): self.assert_compile(select([literal('foo')]), diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index 477fca783..a51e14244 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -1,6 +1,6 @@ from sqlalchemy import MetaData, Table, Column, Integer, select, \ ForeignKey, Index, CheckConstraint, inspect, column -from sqlalchemy import sql, schema +from sqlalchemy import sql, schema, types as sqltypes from sqlalchemy.sql import compiler from sqlalchemy.testing import fixtures, AssertsCompiledSQL, eq_ from sqlalchemy import testing @@ -462,7 +462,8 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( column('foo').collate('fr_FR'), - 'foo COLLATE "fr_FR"' + 'foo COLLATE "fr_FR"', + dialect="postgresql" ) self.assert_compile( @@ -471,6 +472,12 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): dialect="mysql" ) + self.assert_compile( + column('foo').collate('SQL_Latin1_General_CP1_CI_AS'), + 'foo COLLATE SQL_Latin1_General_CP1_CI_AS', + dialect="mssql" + ) + def test_join(self): # Lower case names, should not quote metadata = MetaData() |
