Using jruby 1.1.3. Activerecord-jdbc 0.8.2. Rails 2.1.0
>> t = Time.now
=> Fri Aug 29 17:44:59 +1000 2008
>> ActiveRecord::Base.connection.quote t
=> "'2008-08-29 17:44:59'"
>> ActiveRecord::Base.connection.quote t.in_time_zone
=> "'--- 2008-08-29 07:44:59.661700 Z\n'"
>> Time === t.in_time_zone
=> true
>> ActiveRecord::Base.connection.quoted_date t.in_time_zone
=> "2008-08-29 07:44:59"
>> t.in_time_zone.kind_of? Time
=> true
>> t.in_time_zone.class
=> ActiveSupport::TimeWithZone
For some reason, it appears that the check in JdbcDerbySpec isn't seeing the ActiveSupport::TimeWithZone objects as
a kind of time.
Relevant java code:
} else if (rubyApi.isKindOf(value, runtime.getModule("Date"))) {
return quote_string_with_surround(runtime, "'", RubyString.objAsString(context, value),
"'");
} else if (rubyApi.isKindOf(value, runtime.getModule("Time")) || rubyApi.isKindOf(value,
runtime.getModule("DateTime"))) {
return quote_string_with_surround(runtime, "'", (RubyString)(rubyApi.callMethod(recv,
"quoted_date", value)), "'");
Also quite puzzling is this behaviour:
>> ActiveRecord::Base.connection.quoted_date t.in_time_zone
=> "2008-08-29 07:44:59"
>> ActiveRecord::Base.connection.quoted_date t.in_time_zone.to_datetime
=> "2008-08-29 07:44:59"
>> ActiveRecord::Base.connection.quote t.in_time_zone.to_datetime
=> "'2008-08-29T07:44:59+00:00'"
The check for DateTime comes after the check for Date, so when a DateTime is passed to quote, it's just getting objAsString
called instead of quoted_date.
|