Bugs: Browse | Submit New | Admin

[#21720] Derby adapter quotes rails 2.1 times as yaml

Date:
2008-08-29 07:57
Priority:
3
Submitted By:
Nobody
Assigned To:
Nobody (None)
Category:
AR-JDBC
State:
Open
Summary:
Derby adapter quotes rails 2.1 times as yaml

Detailed description
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.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2008-09-01 06:21
Sender: Daniel Sheppard

Patch here fixes issues:

http://rubyforge.org/tracker/index.php?func=detail&aid=21760&
amp;group_id=2014&atid=7859

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item