From 534cf5fdbd05e2049ab9feceabf3926a5ab6380c Mon Sep 17 00:00:00 2001 From: Jason Kirtland Date: Sat, 18 Aug 2007 18:15:11 +0000 Subject: - fixed prefixes= argument to select() - mysql can now generate DISTINCT or ALL for queries, select(..., distinct='ALL') - documented 'prefixes' arg to select() - rearranged doc order for select args to mirror that of a generated statement - went nutty and fixed wrapping and line length on most docstrings in sql.py --- test/dialect/mysql.py | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'test/dialect/mysql.py') diff --git a/test/dialect/mysql.py b/test/dialect/mysql.py index ab3e49f93..46e0a7137 100644 --- a/test/dialect/mysql.py +++ b/test/dialect/mysql.py @@ -667,7 +667,44 @@ class TypesTest(AssertMixin): print "Expected %s" % wanted print "Found %s" % got self.assertEqual(got, wanted) - + + +class SQLTest(AssertMixin): + """Tests MySQL-dialect specific compilation.""" + + @testing.supported('mysql') + def test_precolumns(self): + dialect = testbase.db.dialect + + def gen(distinct=None, prefixes=None): + kw = {} + if distinct is not None: + kw['distinct'] = distinct + if prefixes is not None: + kw['prefixes'] = prefixes + return str(select(['q'], **kw).compile(dialect=dialect)) + + self.assertEqual(gen(None), 'SELECT q') + self.assertEqual(gen(True), 'SELECT DISTINCT q') + self.assertEqual(gen(1), 'SELECT DISTINCT q') + self.assertEqual(gen('diSTInct'), 'SELECT DISTINCT q') + self.assertEqual(gen('DISTINCT'), 'SELECT DISTINCT q') + + # Standard SQL + self.assertEqual(gen('all'), 'SELECT ALL q') + self.assertEqual(gen('distinctrow'), 'SELECT DISTINCTROW q') + + # Interaction with MySQL prefix extensions + self.assertEqual( + gen(None, ['straight_join']), + 'SELECT straight_join q') + self.assertEqual( + gen('all', ['HIGH_PRIORITY SQL_SMALL_RESULT']), + 'SELECT HIGH_PRIORITY SQL_SMALL_RESULT ALL q') + self.assertEqual( + gen(True, ['high_priority', sql.text('sql_cache')]), + 'SELECT high_priority sql_cache DISTINCT q') + def colspec(c): return testbase.db.dialect.schemagenerator( -- cgit v1.2.1