def sanitize(value)
      case value

      when Integer
        value.to_s

      when Numeric, String
        connection.quote value

      when Array
        raise BadValue.new(value, "an empty array") if value.empty?
        raise BadValue.new(value, "a nested array") if value.any? { |v| v.is_a? Array }

        "(" + value.map { |v| sanitize v }.join(", ") + ")"

      when Literal
        value.value

      when Rows # rows for insertion
        value.values.map { |v| sanitize v }.join(", ")

      when Class
        connection.quote value.name

      when DateTime, Time, Date
        enforce_timezone do
          connection.quote value.to_s(:db)
        end

      when true
        connection.quoted_true

      when false
        connection.quoted_false

      when Symbol
        connection.quote value.to_s

      else
        raise BadValue, value
      end
    end
def sanitize(value)
      case value

      when Integer
        value.to_s

      when Numeric, String
        connection.quote value

      when Array
        raise BadValue.new(value, "an empty array") if value.empty?
        raise BadValue.new(value, "a nested array") if value.any? { |v| v.is_a? Array }

        "(" + value.map { |v| sanitize v }.join(", ") + ")"

      when Literal
        value.value

      when Rows # rows for insertion
        value.values.map { |v| sanitize v }.join(", ")

      when Class
        connection.quote value.name

      when DateTime, Time, Date
        enforce_timezone do
          connection.quote value.to_s(:db)
        end

      when true
        connection.quoted_true

      when false
        connection.quoted_false

      when Symbol
        connection.quote value.to_s

      else
        raise BadValue, value
      end
    end
Internal: Make `value` database-safe. Ish.