def _condition_as_sql(self, qn, connection):
def escape(value):<EOL><INDENT>if isinstance(value, bool):<EOL><INDENT>value = str(int(value))<EOL><DEDENT>if isinstance(value, six.string_types):<EOL><INDENT>if '<STR_LIT:%>' in value:<EOL><INDENT>value = value.replace('<STR_LIT:%>', '<STR_LIT>')<EOL><DEDENT>if "<STR_LIT:'>" in value:<EOL><INDENT>value = value.replace("<STR_LIT:'>", "<STR_LIT>")<EOL><DEDENT>value = "<STR_LIT:'>" + value + "<STR_LIT:'>"<EOL><DEDENT>return value<EOL><DEDENT>sql, param = self.condition.query.where.as_sql(qn, connection)<EOL>param = map(escape, param)<EOL>return sql % tuple(param)<EOL>
Return sql for condition.