From 521ca37c3e6c453f48ab1dd9225bde6ea3a0c9d6 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 15 Jan 2007 17:23:01 +0000 Subject: be like a duck. Let's not rely on explicit classes, so we can pass proxy objects around and have them interpreted correctly by ActiveRecord's serialization routines git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5953 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_record/connection_adapters/abstract/quoting.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract/quoting.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 0f2008deb5..ce9495a5d2 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -24,9 +24,14 @@ module ActiveRecord when Float, Fixnum, Bignum then value.to_s # BigDecimals need to be output in a non-normalized form and quoted. when BigDecimal then value.to_s('F') - when Date then "'#{value.to_s}'" - when Time, DateTime then "'#{quoted_date(value)}'" - else "'#{quote_string(value.to_yaml)}'" + else + if value.acts_like?(:date) + "'#{value.to_s}'" + elsif value.acts_like?(:time) + "'#{quoted_date(value)}'" + else + "'#{quote_string(value.to_yaml)}'" + end end end -- cgit v1.2.3