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

Method test_compile

test/sql/test_functions.py:75–102  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

73 functions._registry = self._registry
74
75 def test_compile(self):
76 for dialect in all_dialects():
77 bindtemplate = BIND_TEMPLATES[dialect.paramstyle]
78 self.assert_compile(
79 func.current_timestamp(), "CURRENT_TIMESTAMP", dialect=dialect
80 )
81 self.assert_compile(func.localtime(), "LOCALTIME", dialect=dialect)
82 self.assert_compile(
83 func.nosuchfunction(), "nosuchfunction()", dialect=dialect
84 )
85
86 # test generic function compile
87 class fake_func(GenericFunction):
88 inherit_cache = True
89 __return_type__ = sqltypes.Integer
90
91 def __init__(self, arg, **kwargs):
92 GenericFunction.__init__(self, arg, **kwargs)
93
94 self.assert_compile(
95 fake_func("foo"),
96 "fake_func(%s)"
97 % bindtemplate
98 % {"name": "fake_func_1", "position": 1},
99 dialect=dialect,
100 )
101
102 functions._registry["_default"].pop("fake_func")
103
104 @testing.combinations(
105 (operators.in_op, [1, 2, 3], "myfunc() IN (1, 2, 3)"),

Callers

nothing calls this directly

Calls 6

all_dialectsFunction · 0.90
fake_funcClass · 0.85
assert_compileMethod · 0.80
current_timestampMethod · 0.80
localtimeMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected