MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_conn_execute

Method test_conn_execute

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

Source from the content-addressed store, hash-verified

1410 pass
1411
1412 def test_conn_execute(self, connection):
1413 from sqlalchemy.sql.expression import FunctionElement
1414 from sqlalchemy.ext.compiler import compiles
1415
1416 class myfunc(FunctionElement):
1417 inherit_cache = True
1418 type = Date()
1419
1420 @compiles(myfunc)
1421 def compile_(elem, compiler, **kw):
1422 return compiler.process(func.current_date())
1423
1424 x = connection.execute(func.current_date()).scalar()
1425 y = connection.execute(func.current_date().select()).scalar()
1426 z = connection.scalar(func.current_date())
1427 q = connection.scalar(myfunc())
1428
1429 assert (x == y == z == q) is True
1430
1431 def test_exec_options(self, connection):
1432 f = func.foo()

Callers

nothing calls this directly

Calls 5

current_dateMethod · 0.80
myfuncClass · 0.70
scalarMethod · 0.45
executeMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected