aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2005-10-06 04:15:14 +0000
committerMichael Koziarski <michael@koziarski.com>2005-10-06 04:15:14 +0000
commit656fb866f91a87677ce501d3c9ad6aba9048d00f (patch)
treec6db1f2d6fc045aa428cc7575aec87e74f1f8957 /activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
parent0639e1ca7c63afa79b54cc1eb73871026f9b473d (diff)
downloadrails-656fb866f91a87677ce501d3c9ad6aba9048d00f.tar.gz
rails-656fb866f91a87677ce501d3c9ad6aba9048d00f.tar.bz2
rails-656fb866f91a87677ce501d3c9ad6aba9048d00f.zip
Quote booleans according the rules defined by the adapter
* SQLite schema has been updated * Postgresql schema needs to be fixed too Simplify AR::Base#toggle to store the boolean, not the quoted value * expand the tests git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2474 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
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 c8088bd978..c7e7d83ca1 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
@@ -14,11 +14,11 @@ module ActiveRecord
"'#{quote_string(value)}'" # ' (for ruby-mode)
end
when NilClass then "NULL"
- when TrueClass then (column && column.type == :boolean ? quoted_true : "1")
- when FalseClass then (column && column.type == :boolean ? quoted_false : "0")
+ when TrueClass then (column && column.type == :integer ? '1' : quoted_true)
+ when FalseClass then (column && column.type == :integer ? '0' : quoted_false)
when Float, Fixnum, Bignum then value.to_s
when Date then "'#{value.to_s}'"
- when Time, DateTime then "'#{value.strftime("%Y-%m-%d %H:%M:%S")}'"
+ when Time, DateTime then "'#{quoted_date(value)}'"
else "'#{quote_string(value.to_yaml)}'"
end
end
@@ -42,6 +42,10 @@ module ActiveRecord
def quoted_false
"'f'"
end
+
+ def quoted_date(value)
+ value.strftime("%Y-%m-%d %H:%M:%S")
+ end
end
end
end \ No newline at end of file