quote(value, column = nil)
public
Show source
def quote(value, column = nil)
case value
when String
if column && column.type == :binary
"'#{quote_string(column.class.string_to_binary(value))}'"
elsif column && [:integer, :float].include?(column.type)
value.to_s
else
"'#{quote_string(value)}'"
end
when NilClass then "NULL"
when TrueClass then (column && column.type == :integer ? '1' : quoted_true)
when FalseClass then (column && column.type == :integer ? '0' : quoted_false)
when Float, Fixnum, Bignum then value.to_s
when Date then "'#{value.to_s}'"
when Time, DateTime then "'#{quoted_date(value)}'"
else "'#{quote_string(value.to_yaml)}'"
end
end