aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-12 11:45:59 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-12 11:45:59 -0700
commitc882154cd121ea494019afa0c9ce8d31767de691 (patch)
tree023d119baa5781230615f8cb60c974b2a58903d5 /activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
parent0ca9c836c09865056c6c85f29d045e1c9c40a993 (diff)
downloadrails-c882154cd121ea494019afa0c9ce8d31767de691.tar.gz
rails-c882154cd121ea494019afa0c9ce8d31767de691.tar.bz2
rails-c882154cd121ea494019afa0c9ce8d31767de691.zip
reduce the number of times we test for the column variable
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, 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)