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

Method test_extract

test/sql/test_external_traversal.py:1137–1152  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1135 )
1136
1137 def test_extract(self):
1138 s = select(extract("foo", t1.c.col1).label("col1"))
1139 self.assert_compile(
1140 s, "SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1"
1141 )
1142
1143 s2 = CloningVisitor().traverse(s).alias()
1144 s3 = select(s2.c.col1)
1145 self.assert_compile(
1146 s, "SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1"
1147 )
1148 self.assert_compile(
1149 s3,
1150 "SELECT anon_1.col1 FROM (SELECT EXTRACT(foo FROM "
1151 "table1.col1) AS col1 FROM table1) AS anon_1",
1152 )
1153
1154 @testing.emits_warning(".*replaced by another column with the same key")
1155 def test_alias(self):

Callers

nothing calls this directly

Calls 6

selectFunction · 0.90
extractFunction · 0.90
assert_compileMethod · 0.80
labelMethod · 0.45
aliasMethod · 0.45
traverseMethod · 0.45

Tested by

no test coverage detected