Hi,
The latest version of
ActiveRecord-JDBC<http://rubyforge.org/projects/jruby-extras/>is 0.8.
To install AR jdbc adapter for Oracle, run:
jruby -S gem install activerecord-jdbc-adapter
The date type conversion error is a bug of AR jdbc adapter for oracle. Here
is a way to solve this problem:
1. suppose you installed activerecord-jdbc-adapter 0.8
2. open
$JRUBY_HOME/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.8/lib/jdbc_adapter/jdbc_oracle.rb
3. and uncomment line 61 and 70.
> line 61: when :datetime then
> JdbcSpec::Oracle::Column.cast_to_date_or_time(value)
> line 70: return
> "JdbcSpec::Oracle::Column.cast_to_date_or_time(#{var_name})" if type ==
> :datetime
>
restart your Rails app, and it should work well.
--
cheers,
Jesse
2008/4/12, one_too_many <[EMAIL PROTECTED]>:
>
>
> Greetings, all.
>
> When I use ActiveRecord within JRuby, and I access an Oracle 10g date
> field
> (which include time in Oracle - it's really a DATETIME), the object
> ActiveRecord gives me is a Date object, not a Time. As such, the time is
> lost, so all I get is a truncated date w/o time.
>
> When I access these same fields in a normal Ruby/ActiveRecord interpreter
> environment, I get a Time object as expected.
>
> I've searched for this issue and have not found a fix (though, this seems
> closely related:
>
> http://www.nabble.com/-jira--Created%3A-%28JRUBY-1217%29-Date-columns-ending-in-_at-returning-Jan-01%2C-2000-on-Oracle-to11675146.html#a11675146
> ).
> Any help would be greatly appreciated! The code below shows what I'm
> seeing:
>
> -- Sample code that illustrates my problem
> class EtlParm < ActiveRecord::Base
> end
>
> parm = EtlParm.find_by_parm_name('abc_parm')
> x = parm.value_date
> puts "x.class: #{x.class}"
> puts "x.inspect: #{x.inspect}"
>
> -- [JRuby] Output
> >> x.class: Date
> >> x.inspect: Sun, 01 Jan 2006
>
> -- [Ruby] Output
> >> x.class: Time
> >> x.inspect: Sun, 01 Jan 2006 17:53:54
>
> Here is what my environment looks like:
>
> ruby 1.8.5 (2007-11-01 rev 4810) [x86-jruby1.0.2]
> JRuby gem version: 0.9.4
>
> JRuby gems (local):
> activerecord (2.0.1)
> Implements the ActiveRecord pattern for ORM.
>
> ActiveRecord-JDBC (0.5)
> JDBC adapter for ActiveRecord, for use within JRuby on Rails.
>
> activeresource (2.0.1)
> Think Active Record for web resources.
>
> activesupport (2.0.1)
> Support and utility classes used by the Rails framework.
>
> ar-extensions (0.7.0)
> Extends ActiveRecord functionality.
> --
> View this message in context:
> http://www.nabble.com/Oracle-dates-%28w--time%29-interpreted-by-ActiveRecord-as-Date-objects%2C-not-Time-tp16628183p16628183.html
> Sent from the JRuby - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email