mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-25 01:52:03 -04:00
1e278de4cc
Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
from sqlalchemy import extract
|
|
from sqlalchemy import select
|
|
from sqlalchemy import sql
|
|
from sqlalchemy.databases import sybase
|
|
from sqlalchemy.testing import assert_raises_message
|
|
from sqlalchemy.testing import AssertsCompiledSQL
|
|
from sqlalchemy.testing import fixtures
|
|
|
|
|
|
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__,
|
|
)
|
|
|
|
def test_delete_extra_froms(self):
|
|
t1 = sql.table("t1", sql.column("c1"))
|
|
t2 = sql.table("t2", sql.column("c1"))
|
|
q = sql.delete(t1).where(t1.c.c1 == t2.c.c1)
|
|
self.assert_compile(
|
|
q, "DELETE FROM t1 FROM t1, t2 WHERE t1.c1 = t2.c1"
|
|
)
|
|
|
|
def test_delete_extra_froms_alias(self):
|
|
a1 = sql.table("t1", sql.column("c1")).alias("a1")
|
|
t2 = sql.table("t2", sql.column("c1"))
|
|
q = sql.delete(a1).where(a1.c.c1 == t2.c.c1)
|
|
self.assert_compile(
|
|
q, "DELETE FROM a1 FROM t1 AS a1, t2 WHERE a1.c1 = t2.c1"
|
|
)
|
|
self.assert_compile(sql.delete(a1), "DELETE FROM t1 AS a1")
|