diff options
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/quoting.rb | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 0e1c28e330..1c063c003d 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1094,7 +1094,7 @@ module ActiveRecord #:nodoc: # Turns an +attribute+ that's currently true into false and vice versa. Returns self. def toggle(attribute) - self[attribute] = quote(!send("#{attribute}?", column_for_attribute(attribute))) + self[attribute] = !send("#{attribute}?") self end 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 |