Date columns ending in _at returning Jan 01, 2000 on Oracle
-----------------------------------------------------------
Key: JRUBY-1217
URL: http://jira.codehaus.org/browse/JRUBY-1217
Project: JRuby
Issue Type: Bug
Components: ActiveRecord-JDBC
Environment: OpenSuSE 10.2 Linux, Java 6u2, JRuby r4009, Oracle 10G
Reporter: Michael Schubert
Assignee: Thomas E Enebo
Attachments: jdbc_oracle_time.patch
On Oracle, the JDBC code seems to have the following typecasting in place:
{code:title=activerecord-jdbc/lib/jdbc_adapter/jdbc_oracle.rb|borderStyle=solid}
...
def simplified_type(field_type)
case field_type
when /char/i : :string
when /num|float|double|dec|real|int/i : @scale == 0 ? :integer : :float
when /date|time/i : @name =~ /_at$/ ? :time : :datetime
when /clob/i : :text
when /blob/i : :binary
end
end
...
{code}
The original implementation from Rails does not distinguish between columns
that end in _at to determine it should be interpreted as time or date time. Why
one would treat an oracle DATE column that ends in "_at" differently than a
column of the same type named anything else is a bit confusing to me. It seems
that the cast_to_time method results in the attribute being read back as Jan 1,
2000.
Patch attached.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email