diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-12 11:45:59 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-12 11:45:59 -0700 |
commit | c882154cd121ea494019afa0c9ce8d31767de691 (patch) | |
tree | 023d119baa5781230615f8cb60c974b2a58903d5 | |
parent | 0ca9c836c09865056c6c85f29d045e1c9c40a993 (diff) | |
download | rails-c882154cd121ea494019afa0c9ce8d31767de691.tar.gz rails-c882154cd121ea494019afa0c9ce8d31767de691.tar.bz2 rails-c882154cd121ea494019afa0c9ce8d31767de691.zip |
reduce the number of times we test for the column variable
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/quoting.rb | 7 |
1 files 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) |