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

Method test_extract_expression

test/sql/test_functions.py:1340–1357  ·  view source on GitHub ↗
(self, connection)

Source from the content-addressed store, hash-verified

1338
1339 @testing.provide_metadata
1340 def test_extract_expression(self, connection):
1341 meta = self.metadata
1342 table = Table("test", meta, Column("dt", DateTime), Column("d", Date))
1343 meta.create_all(connection)
1344 connection.execute(
1345 table.insert(),
1346 {
1347 "dt": datetime.datetime(2010, 5, 1, 12, 11, 10),
1348 "d": datetime.date(2010, 5, 1),
1349 },
1350 )
1351 rs = connection.execute(
1352 select(extract("year", table.c.dt), extract("month", table.c.d))
1353 )
1354 row = rs.first()
1355 assert row[0] == 2010
1356 assert row[1] == 5
1357 rs.close()
1358
1359
1360class RegisterTest(fixtures.TestBase, AssertsCompiledSQL):

Callers

nothing calls this directly

Calls 11

TableClass · 0.90
ColumnClass · 0.90
selectFunction · 0.90
extractFunction · 0.90
create_allMethod · 0.80
executeMethod · 0.45
insertMethod · 0.45
datetimeMethod · 0.45
dateMethod · 0.45
firstMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected