jruby/activerecord-jdbc-adapter — Issue #153: DB2 Adapter - Error in field of type Time in legacy tables
Author: CiceroOliveira
Created: 2012-01-16 23:16:51+00:00
State: open

After defining a class which points to a legacy DB2 database, if the table contains a field of type Time, the following error is generated.

Extra info: the time field from the database contains a valid time.

The class definition:
class Prob < ActiveRecord::Base
set_table_name 'TCRDB.PROB'
end

Test:
prob = Table1.first
puts prob

It fails before the 'puts' command.

ActiveRecord::JDBCError: (NoMethodError) undefined method `hour' for nil:NilClass
columns at arjdbc/jdbc/RubyJdbcConnection.java:121
columns at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-jdbc-adapter-1.2.1/lib/arjdbc/db2/adapter.rb:401
initialize at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:95 with_connection at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185
initialize at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:92
call at org/jruby/RubyProc.java:258
default at org/jruby/RubyHash.java:647
[] at org/jruby/RubyHash.java:996
initialize at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106
call at org/jruby/RubyProc.java:258
default at org/jruby/RubyHash.java:647
[] at org/jruby/RubyHash.java:996
columns_hash at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717
locking_enabled? at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/locking/optimistic.rb:145
to_a at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation.rb:110
find_first at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:376
first at c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:122
(root) at test_connection_dipdb.rb:31

Thanks for all your efforts and for creating and supporting this great gem. Let me know in case you need some more help.