diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-08-18 18:15:11 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-08-18 18:15:11 +0000 |
commit | 534cf5fdbd05e2049ab9feceabf3926a5ab6380c (patch) | |
tree | d14841a65b7fb3c5173aa7ca9653c75f134b6ae8 /test | |
parent | 820346549b7e50e927c519c9bc54934e9a440422 (diff) | |
download | sqlalchemy-534cf5fdbd05e2049ab9feceabf3926a5ab6380c.tar.gz |
- 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
Diffstat (limited to 'test')
-rw-r--r-- | test/dialect/mysql.py | 39 |
1 files changed, 38 insertions, 1 deletions
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( |