MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_extract

Method test_extract

test/dialect/sqlite/test_compiler.py:57–76  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

55 __dialect__ = sqlite.dialect()
56
57 def test_extract(self):
58 t = sql.table("t", sql.column("col1"))
59 mapping = {
60 "month": "%m",
61 "day": "%d",
62 "year": "%Y",
63 "second": "%S",
64 "hour": "%H",
65 "doy": "%j",
66 "minute": "%M",
67 "epoch": "%s",
68 "dow": "%w",
69 "week": "%W",
70 }
71 for field, subst in mapping.items():
72 self.assert_compile(
73 select(extract(field, t.c.col1)),
74 "SELECT CAST(STRFTIME('%s', t.col1) AS "
75 "INTEGER) AS anon_1 FROM t" % subst,
76 )
77
78 def test_plain_stringify_returning(self):
79 t = Table(

Callers

nothing calls this directly

Calls 6

selectFunction · 0.90
extractFunction · 0.90
assert_compileMethod · 0.80
tableMethod · 0.45
columnMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected