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:59:20 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-12 11:59:20 -0700
commit5b5ae01f294c2a305c62372be732cc59f97d3c06 (patch)
tree43620379da9ea67318c5e3f1d61e263dc25b5830 /activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
parent01893f43f68f3cba24751022131d51702d188979 (diff)
downloadrails-5b5ae01f294c2a305c62372be732cc59f97d3c06.tar.gz
rails-5b5ae01f294c2a305c62372be732cc59f97d3c06.tar.bz2
rails-5b5ae01f294c2a305c62372be732cc59f97d3c06.zip
drying up true and false cases
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/quoting.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/quoting.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
index b28eb3f758..1e0c5fe902 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
@@ -22,10 +22,14 @@ module ActiveRecord
"'#{quote_string(value)}'" # ' (for ruby-mode)
end
- when nil then "NULL"
- when true then (column && column.type == :integer ? '1' : quoted_true)
- when false then (column && column.type == :integer ? '0' : quoted_false)
+ when true, false
+ if column && column.type == :integer
+ value ? '1' : '0'
+ else
+ value ? quoted_true : quoted_false
+ end
# BigDecimals need to be put in a non-normalized form and quoted.
+ when nil then "NULL"
when BigDecimal then value.to_s('F')
when Numeric then value.to_s
when Date, Time then "'#{quoted_date(value)}'"