def _get_compiled_expression(statement):
"""Returns the statement in a form where any placeholders have been filled in."""
if isinstance(statement, TextClause):
return statement.text
dialect = statement._from_objects[0].bind.dialect
compiler = statement._compiler(dialect)
# Adapted from http://stackoverflow.com/a/5698357/242021
class LiteralCompiler(compiler.__class__):
def visit_bindparam(self, bindparam, within_columns_clause=False, literal_binds=False, **kwargs):
return super(LiteralCompiler, self).render_literal_bindparam(
bindparam, within_columns_clause=within_columns_clause,
literal_binds=literal_binds, **kwargs
)
compiler = LiteralCompiler(dialect, statement)
return compiler.process(statement)
评论列表
文章目录