aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb48
1 files changed, 25 insertions, 23 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb b/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb
index a6df79ad0d..415e15a588 100644
--- a/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb
@@ -375,31 +375,33 @@ module ActiveRecord
(column && column.type == :integer ? '0' : quoted_false)
when Float, Fixnum, Bignum, BigDecimal
value.to_s
- when Time, Date, DateTime
- if column
- case column.type
- when :date
+ else
+ if value.acts_like?(:time) || value.acts_like?(:date)
+ if column
+ case column.type
+ when :date
+ "DATE '#{value.strftime("%Y-%m-%d")}'"
+ when :time
+ "TIME '#{value.strftime("%H:%M:%S")}'"
+ when :timestamp
+ "TIMESTAMP '#{value.strftime("%Y-%m-%d %H:%M:%S")}'"
+ else
+ raise NotImplementedError, "Unknown column type!"
+ end # case
+ else # Column wasn't passed in, so try to guess the right type
+ if value.acts_like?(:date)
"DATE '#{value.strftime("%Y-%m-%d")}'"
- when :time
- "TIME '#{value.strftime("%H:%M:%S")}'"
- when :timestamp
- "TIMESTAMP '#{value.strftime("%Y-%m-%d %H:%M:%S")}'"
- else
- raise NotImplementedError, "Unknown column type!"
- end # case
- else # Column wasn't passed in, so try to guess the right type
- if value.kind_of? Date
- "DATE '#{value.strftime("%Y-%m-%d")}'"
- else
- if [:hour, :min, :sec].all? {|part| value.send(:part).zero? }
- "TIME '#{value.strftime("%H:%M:%S")}'"
else
- "TIMESTAMP '#{quoted_date(value)}'"
- end
- end
- end #if column
- else
- "'#{quote_string(value.to_yaml)}'"
+ if [:hour, :min, :sec].all? {|part| value.send(:part).zero? }
+ "TIME '#{value.strftime("%H:%M:%S")}'"
+ else
+ "TIMESTAMP '#{quoted_date(value)}'"
+ end
+ end
+ end #if column
+ else
+ "'#{quote_string(value.to_yaml)}'"
+ end
end #case
end
else