Bugs item #9920, was opened at 2007-04-07 05:57
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=7857&aid=9920&group_id=2014
Category: AR-JDBC
Group: 0.2.3
>Status: Closed
Resolution: None
Priority: 3
Submitted By: Nobody (None)
Assigned to: Nobody (None)
Summary: MySQL 5: ActiveRecord::StatementInvalid (RuntimeError: jdbc_adapter:
type REAL not supported yet...
Initial Comment:
Hi,
first of all, thanks for the lib, overall it rocks. I was able to switch my RoR
app to JRuby without any major headache.
Now, I think there is a bug in jdbc_adapter.rb.
Look, I've created a small table this way:
create_table :opinions, :force => true do |t|
t.column "user_id", :integer, :default => 0
t.column "topic_id", :integer, :default => 0, :null => false
t.column "created_at", :datetime
t.column "summary", :string, :limit => 127
t.column "text", :string, :limit => 1023
t.column "alias_of", :integer
t.column "cached_score", :float, :default => 0.0
t.column "cached_times_presented", :integer, :default => 0
end
So as you see, cached_score is a float. In my phpMyAdmin, it's indeed tagged as
a float and it was working fine under MRI.
Now, in the jruby console, if I do that:
Opinion.find_by_id(1), it will systematically break shouting out:
ActiveRecord::StatementInvalid (RuntimeError: jdbc_adapter: type REAL not
supported yet...
with that stack trace:
/home/rvalyi/DEV/jruby/lib/ruby/gems/1.8/gems/ActiveRecord-JDBC-0.2.3/lib/active_record/connection_adapters/jdbc_adapter.rb:651:in
`log_no_bench'
/home/rvalyi/DEV/jruby/lib/ruby/gems/1.8/gems/ActiveRecord-JDBC-0.2.3/lib/active_record/connection_adapters/jdbc_adapter.rb:630:in
`select'
/home/rvalyi/DEV/jruby/lib/ruby/gems/1.8/gems/ActiveRecord-JDBC-0.2.3/lib/active_record/connection_adapters/jdbc_adapter.rb:581:in
`select_all'
And indeed, in convert_jdbc_type_to_ruby, you'll see that the REAL type is
never handled (Now don't ask me why the hell it looks for REAL while it's
actually a FLOAT, I have no idea why).
That said, if I add Jdbc::Types::REAL to the line 464 handling the FLOAT and
DOUBLE case, everything went fine.
So since I see no other king of Ruby encoding for REAL than Double (but I don't
know Ruby that much), I think this fix is OK, what do you think?
Can you patch ActiveRecord JDBC then?
Thanks,
Raphaƫl Valyi.
----------------------------------------------------------------------
>Comment By: Ola Bini (olabini)
Date: 2007-08-11 15:29
Message:
I'm pretty certain this works in trunk now.
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=7857&aid=9920&group_id=2014
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel