Bugs item #21720, was opened at 2008-08-29 17:57
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=7857&aid=21720&group_id=2014
Category: AR-JDBC
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Nobody (None)
Assigned to: Nobody (None)
Summary: Derby adapter quotes rails 2.1 times as yaml
Initial Comment:
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.
----------------------------------------------------------------------
Comment By: Daniel Sheppard (danshep)
Date: 2008-09-01 16:21
Message:
Patch here fixes issues:
http://rubyforge.org/tracker/index.php?func=detail&aid=21760&group_id=2014&atid=7859
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=7857&aid=21720&group_id=2014
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel