From c882154cd121ea494019afa0c9ce8d31767de691 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 12 Oct 2010 11:45:59 -0700 Subject: reduce the number of times we test for the column variable --- .../lib/active_record/connection_adapters/abstract/quoting.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 39bd5e1cab..820c6d9f0c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -12,14 +12,17 @@ module ActiveRecord case value when String, ActiveSupport::Multibyte::Chars value = value.to_s - if column && column.type == :binary && column.class.respond_to?(:string_to_binary) + return "'#{quote_string(value)}'" unless column + + if column.type == :binary && column.class.respond_to?(:string_to_binary) "'#{quote_string(column.class.string_to_binary(value))}'" # ' (for ruby-mode) - elsif column && [:integer, :float].include?(column.type) + elsif [:integer, :float].include?(column.type) value = column.type == :integer ? value.to_i : value.to_f value.to_s else "'#{quote_string(value)}'" # ' (for ruby-mode) 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) -- cgit v1.2.3