aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-02-13 00:33:56 -0300
committerGitHub <noreply@github.com>2017-02-13 00:33:56 -0300
commit2f60a7525e8727f6c6d111637221b22898179fc5 (patch)
treec9a288d1b1f23d65e4685058bf030903f5a7079c /activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
parentc6b4b4a52c7ec66d1923ef44dcbc71b582d7b165 (diff)
parent4a4286acc3047363d5dfaee58cd71a47b3991575 (diff)
downloadrails-2f60a7525e8727f6c6d111637221b22898179fc5.tar.gz
rails-2f60a7525e8727f6c6d111637221b22898179fc5.tar.bz2
rails-2f60a7525e8727f6c6d111637221b22898179fc5.zip
Merge pull request #26630 from kamipo/quoted_binary
Extract `quoted_binary` and use it rather than override `_quote`
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/quoting.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/quoting.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
index 437e7c6510..7f4132accf 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
@@ -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)}'"