/SQLAlchemy-0.7.8/test/dialect/test_access.py
Python | 31 lines | 24 code | 7 blank | 0 comment | 1 complexity | 80bdedcae8799780b3f6c9e8fdbba73f MD5 | raw file
1from sqlalchemy import *
2from sqlalchemy import sql
3from sqlalchemy.databases import access
4from test.lib import *
5
6
7class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
8 __dialect__ = access.dialect()
9
10 def test_extract(self):
11 t = sql.table('t', sql.column('col1'))
12
13 mapping = {
14 'month': 'm',
15 'day': 'd',
16 'year': 'yyyy',
17 'second': 's',
18 'hour': 'h',
19 'doy': 'y',
20 'minute': 'n',
21 'quarter': 'q',
22 'dow': 'w',
23 'week': 'ww'
24 }
25
26 for field, subst in mapping.items():
27 self.assert_compile(
28 select([extract(field, t.c.col1)]),
29 'SELECT DATEPART("%s", t.col1) AS anon_1 FROM t' % subst)
30
31