MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_compile

Method test_compile

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

Source from the content-addressed store, hash-verified

85 functions._registry = self._registry
86
87 def test_compile(self):
88 for dialect in all_dialects():
89 bindtemplate = BIND_TEMPLATES[dialect.paramstyle]
90 if dialect.driver == "psycopg":
91 bindtemplate += "::VARCHAR"
92 self.assert_compile(
93 func.current_timestamp(), "CURRENT_TIMESTAMP", dialect=dialect
94 )
95 self.assert_compile(func.localtime(), "LOCALTIME", dialect=dialect)
96 self.assert_compile(
97 func.nosuchfunction(), "nosuchfunction()", dialect=dialect
98 )
99
100 # test generic function compile
101 class fake_func(GenericFunction):
102 inherit_cache = True
103 __return_type__ = sqltypes.Integer
104
105 def __init__(self, arg, **kwargs):
106 GenericFunction.__init__(self, arg, **kwargs)
107
108 self.assert_compile(
109 fake_func("foo"),
110 "fake_func(%s)"
111 % bindtemplate
112 % {"name": "fake_func_1", "position": 1},
113 dialect=dialect,
114 )
115
116 functions._registry["_default"].pop("fake_func")
117
118 @testing.combinations(
119 (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