MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_extract_expression

Method test_extract_expression

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

Source from the content-addressed store, hash-verified

1673
1674 @testing.provide_metadata
1675 def test_extract_expression(self, connection):
1676 meta = self.metadata
1677 table = Table("test", meta, Column("dt", DateTime), Column("d", Date))
1678 meta.create_all(connection)
1679 connection.execute(
1680 table.insert(),
1681 {
1682 "dt": datetime.datetime(2010, 5, 1, 12, 11, 10),
1683 "d": datetime.date(2010, 5, 1),
1684 },
1685 )
1686 rs = connection.execute(
1687 select(extract("year", table.c.dt), extract("month", table.c.d))
1688 )
1689 row = rs.first()
1690 assert row[0] == 2010
1691 assert row[1] == 5
1692 rs.close()
1693
1694
1695class 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