code: def _condition_as_sql(self, qn, connection):
          '''
          Return sql for condition.
          '''
          def escape(value):
              if isinstance(value, bool):
                  value = str(int(value))
              if isinstance(value, six.string_types):
                  # Escape params used with LIKE
                  if '%' in value:
                      value = value.replace('%', '%%')
                  # Escape single quotes
                  if "'" in value:
                      value = value.replace("'", "''")
                  # Add single quote to text values
                  value = "'" + value + "'"
              return value
  
          sql, param = self.condition.query.where.as_sql(qn, connection)
          param = map(escape, param)
  
          return sql % tuple(paramf _condition_as_sql(self, qn, connection):
          '''
          Return sql for condition.
          '''
          def escape(value):
              if isinstance(value, bool):
                  value = str(int(value))
              if isinstance(value, six.string_types):
                  # Escape params used with LIKE
                  if '%' in value:
                      value = value.replace('%', '%%')
                  # Escape single quotes
                  if "'" in value:
                      value = value.replace("'", "''")
                  # Add single quote to text values
                  value = "'" + value + "'"
              return value
  
          sql, param = self.condition.query.where.as_sql(qn, connection)
          param = map(escape, param)
  
          return sql % tuple(param)
docs: Return sql for condition.