mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #26630 from kamipo/quoted_binary
Extract `quoted_binary` and use it rather than override `_quote`
This commit is contained in:
commit
2f60a7525e
4 changed files with 17 additions and 20 deletions
|
@ -141,6 +141,10 @@ module ActiveRecord
|
|||
quoted_date(value).sub(/\A2000-01-01 /, "")
|
||||
end
|
||||
|
||||
def quoted_binary(value) # :nodoc:
|
||||
"'#{quote_string(value.to_s)}'"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def type_casted_binds(binds)
|
||||
|
@ -153,7 +157,7 @@ module ActiveRecord
|
|||
|
||||
def _quote(value)
|
||||
case value
|
||||
when String, ActiveSupport::Multibyte::Chars, Type::Binary::Data
|
||||
when String, ActiveSupport::Multibyte::Chars
|
||||
"'#{quote_string(value.to_s)}'"
|
||||
when true then quoted_true
|
||||
when false then quoted_false
|
||||
|
@ -161,6 +165,7 @@ module ActiveRecord
|
|||
# BigDecimals need to be put in a non-normalized form and quoted.
|
||||
when BigDecimal then value.to_s("F")
|
||||
when Numeric, ActiveSupport::Duration then value.to_s
|
||||
when Type::Binary::Data then quoted_binary(value)
|
||||
when Type::Time::Value then "'#{quoted_time(value)}'"
|
||||
when Date, Time then "'#{quoted_date(value)}'"
|
||||
when Symbol then "'#{quote_string(value.to_s)}'"
|
||||
|
|
|
@ -36,15 +36,9 @@ module ActiveRecord
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def _quote(value)
|
||||
if value.is_a?(Type::Binary::Data)
|
||||
"x'#{value.hex}'"
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
def quoted_binary(value)
|
||||
"x'#{value.hex}'"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,6 +55,10 @@ module ActiveRecord
|
|||
end
|
||||
end
|
||||
|
||||
def quoted_binary(value) # :nodoc:
|
||||
"'#{escape_bytea(value.to_s)}'"
|
||||
end
|
||||
|
||||
def quote_default_expression(value, column) # :nodoc:
|
||||
if value.is_a?(Proc)
|
||||
value.call
|
||||
|
@ -76,8 +80,6 @@ module ActiveRecord
|
|||
|
||||
def _quote(value)
|
||||
case value
|
||||
when Type::Binary::Data
|
||||
"'#{escape_bytea(value.to_s)}'"
|
||||
when OID::Xml::Data
|
||||
"xml '#{quote_string(value.to_s)}'"
|
||||
when OID::Bit::Data
|
||||
|
|
|
@ -18,15 +18,11 @@ module ActiveRecord
|
|||
quoted_date(value)
|
||||
end
|
||||
|
||||
private
|
||||
def quoted_binary(value)
|
||||
"x'#{value.hex}'"
|
||||
end
|
||||
|
||||
def _quote(value)
|
||||
if value.is_a?(Type::Binary::Data)
|
||||
"x'#{value.hex}'"
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
private
|
||||
|
||||
def _type_cast(value)
|
||||
case value
|
||||
|
|
Loading…
Reference in a new issue