mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-10 10:50:37 -04:00
68a350d462
- move testing.TestBase to test.lib.fixtures - massive search and replace
32 lines
786 B
Python
32 lines
786 B
Python
from sqlalchemy import *
|
|
from sqlalchemy import sql
|
|
from sqlalchemy.databases import access
|
|
from test.lib import *
|
|
|
|
|
|
class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
|
|
__dialect__ = access.dialect()
|
|
|
|
def test_extract(self):
|
|
t = sql.table('t', sql.column('col1'))
|
|
|
|
mapping = {
|
|
'month': 'm',
|
|
'day': 'd',
|
|
'year': 'yyyy',
|
|
'second': 's',
|
|
'hour': 'h',
|
|
'doy': 'y',
|
|
'minute': 'n',
|
|
'quarter': 'q',
|
|
'dow': 'w',
|
|
'week': 'ww'
|
|
}
|
|
|
|
for field, subst in mapping.items():
|
|
self.assert_compile(
|
|
select([extract(field, t.c.col1)]),
|
|
'SELECT DATEPART("%s", t.col1) AS anon_1 FROM t' % subst)
|
|
|
|
|