summaryrefslogtreecommitdiff
path: root/test/dialect/test_mysql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-02-10 14:17:08 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-02-10 14:17:08 -0500
commit3f9a343d725eea883aba2145de4cbb7b84f9d08c (patch)
treef55e890195c76543e689c3b939b84df15cd80a3e /test/dialect/test_mysql.py
parenta6d54d18c1ddac30940affaa940edaad59e5d63f (diff)
downloadsqlalchemy-3f9a343d725eea883aba2145de4cbb7b84f9d08c.tar.gz
- Query.distinct() now accepts column expressions
as *args, interpreted by the Postgresql dialect as DISTINCT ON (<expr>). [ticket:1069] - select.distinct() now accepts column expressions as *args, interpreted by the Postgresql dialect as DISTINCT ON (<expr>). Note this was already available via passing a list to the `distinct` keyword argument to select(). [ticket:1069] - select.prefix_with() accepts multiple expressions (i.e. *expr), 'prefix' keyword argument to select() accepts a list or tuple. - Passing a string to the `distinct` keyword argument of `select()` for the purpose of emitting special MySQL keywords (DISTINCTROW etc.) is deprecated - use `prefix_with()` for this. - put kw arguments to select() in order - restore docs for _SelectBase, renamed from _SelectBaseMixin
Diffstat (limited to 'test/dialect/test_mysql.py')
-rw-r--r--test/dialect/test_mysql.py36
1 files changed, 29 insertions, 7 deletions
diff --git a/test/dialect/test_mysql.py b/test/dialect/test_mysql.py
index fd7a15e5b..9b92ddb09 100644
--- a/test/dialect/test_mysql.py
+++ b/test/dialect/test_mysql.py
@@ -1023,25 +1023,47 @@ class SQLTest(TestBase, AssertsCompiledSQL):
eq_(gen(None), 'SELECT q')
eq_(gen(True), 'SELECT DISTINCT q')
- eq_(gen(1), 'SELECT DISTINCT q')
- eq_(gen('diSTInct'), 'SELECT DISTINCT q')
- eq_(gen('DISTINCT'), 'SELECT DISTINCT q')
- # Standard SQL
- eq_(gen('all'), 'SELECT ALL q')
- eq_(gen('distinctrow'), 'SELECT DISTINCTROW q')
+ assert_raises(
+ exc.SADeprecationWarning,
+ gen, 'DISTINCT'
+ )
+
+ eq_(gen(prefixes=['ALL']), 'SELECT ALL q')
+ eq_(gen(prefixes=['DISTINCTROW']),
+ 'SELECT DISTINCTROW q')
# Interaction with MySQL prefix extensions
eq_(
gen(None, ['straight_join']),
'SELECT straight_join q')
eq_(
- gen('all', ['HIGH_PRIORITY SQL_SMALL_RESULT']),
+ gen(False, ['HIGH_PRIORITY', 'SQL_SMALL_RESULT', 'ALL']),
'SELECT HIGH_PRIORITY SQL_SMALL_RESULT ALL q')
eq_(
gen(True, ['high_priority', sql.text('sql_cache')]),
'SELECT high_priority sql_cache DISTINCT q')
+ @testing.uses_deprecated
+ def test_deprecated_distinct(self):
+ dialect = self.__dialect__
+
+ self.assert_compile(
+ select(['q'], distinct='ALL'),
+ 'SELECT ALL q',
+ )
+
+ self.assert_compile(
+ select(['q'], distinct='distinctROW'),
+ 'SELECT DISTINCTROW q',
+ )
+
+ self.assert_compile(
+ select(['q'], distinct='ALL',
+ prefixes=['HIGH_PRIORITY', 'SQL_SMALL_RESULT']),
+ 'SELECT HIGH_PRIORITY SQL_SMALL_RESULT ALL q'
+ )
+
def test_backslash_escaping(self):
self.assert_compile(
sql.column('foo').like('bar', escape='\\'),