.. changelog::
:version: 0.9.3
+ .. change::
+ :tags: bug, sql
+
+ Fixed bug where so-called "literal render" of :func:`.bindparam`
+ constructs would fail if the bind were constructed with a callable,
+ rather than a direct value. This prevented ORM expressions
+ from being rendered with the "literal_binds" compiler flag.
+
.. change::
:tags: bug, orm
:tickets: 2935
if literal_binds or \
(within_columns_clause and \
self.ansi_bind_rules):
- if bindparam.value is None:
+ if bindparam.value is None and bindparam.callable is None:
raise exc.CompileError("Bind parameter '%s' without a "
"renderable value not allowed here."
% bindparam.key)
return self.bindparam_string(name, **kwargs)
def render_literal_bindparam(self, bindparam, **kw):
- value = bindparam.value
+ value = bindparam.effective_value
return self.render_literal_value(value, bindparam.type)
def render_literal_value(self, value, type_):
dialect=dialect
)
+ # test callable
+ self.assert_compile(
+ select([table1.c.myid == bindparam("foo", callable_=lambda: 5)]),
+ "SELECT mytable.myid = 5 AS anon_1 FROM mytable",
+ dialect=dialect
+ )
+
assert_raises_message(
exc.CompileError,
"Bind parameter 'foo' without a renderable value not allowed here.",