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

Method test_extract

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

Source from the content-addressed store, hash-verified

1119 )
1120
1121 def test_extract(self):
1122 s = select(extract("foo", t1.c.col1).label("col1"))
1123 self.assert_compile(
1124 s, "SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1"
1125 )
1126
1127 s2 = CloningVisitor().traverse(s).alias()
1128 s3 = select(s2.c.col1)
1129 self.assert_compile(
1130 s, "SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1"
1131 )
1132 self.assert_compile(
1133 s3,
1134 "SELECT anon_1.col1 FROM (SELECT EXTRACT(foo FROM "
1135 "table1.col1) AS col1 FROM table1) AS anon_1",
1136 )
1137
1138 @testing.emits_warning(".*replaced by another column with the same key")
1139 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