MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_extract

Method test_extract

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

Source from the content-addressed store, hash-verified

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