mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-26 10:32:33 -04:00
772374735d
tested using pycodestyle version 2.2.0 Fixes: #3885 Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from sqlalchemy import extract, select
|
|
from sqlalchemy import sql
|
|
from sqlalchemy.databases import sybase
|
|
from sqlalchemy.testing import assert_raises_message, \
|
|
fixtures, AssertsCompiledSQL
|
|
|
|
|
|
class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
|
|
__dialect__ = sybase.dialect()
|
|
|
|
def test_extract(self):
|
|
t = sql.table('t', sql.column('col1'))
|
|
|
|
mapping = {
|
|
'day': 'day',
|
|
'doy': 'dayofyear',
|
|
'dow': 'weekday',
|
|
'milliseconds': 'millisecond',
|
|
'millisecond': 'millisecond',
|
|
'year': 'year',
|
|
}
|
|
|
|
for field, subst in list(mapping.items()):
|
|
self.assert_compile(
|
|
select([extract(field, t.c.col1)]),
|
|
'SELECT DATEPART("%s", t.col1) AS anon_1 FROM t' % subst)
|
|
|
|
def test_offset_not_supported(self):
|
|
stmt = select([1]).offset(10)
|
|
assert_raises_message(
|
|
NotImplementedError,
|
|
"Sybase ASE does not support OFFSET",
|
|
stmt.compile, dialect=self.__dialect__
|
|
)
|