aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
index 8a94e55e30..28936f8a89 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -347,9 +347,14 @@ module ActiveRecord
case value
when TrueClass then '1'
when FalseClass then '0'
- when Time, DateTime then "'#{value.strftime("%Y%m%d %H:%M:%S")}'"
- when Date then "'#{value.strftime("%Y%m%d")}'"
- else super
+ else
+ if value.acts_like?(:time)
+ "'#{value.strftime("%Y%m%d %H:%M:%S")}'"
+ elsif value.acts_like?(:date)
+ "'#{value.strftime("%Y%m%d")}'"
+ else
+ super
+ end
end
end