quote(value, column = nil)
public
Quotes PostgreSQL-specific data types for SQL input.
Show source
def quote(value, column = nil)
return super unless column
if value.kind_of?(String) && column.type == :binary
"'#{escape_bytea(value)}'"
elsif value.kind_of?(String) && column.sql_type == 'xml'
"xml '#{quote_string(value)}'"
elsif value.kind_of?(Numeric) && column.sql_type == 'money'
"'#{value}'"
elsif value.kind_of?(String) && column.sql_type =~ /^bit/
case value
when /^[01]*$/
"B'#{value}'"
when /^[0-9A-F]*$/i
"X'#{value}'"
end
else
super
end
end