History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-1717
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Unassigned
Reporter: Daniel Wintschel
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JRuby

Errors when trying to persist has_many :through objects using Rails 2.0.1 and activerecord-jdbc-adapter 0.6

Created: 13/Dec/07 05:55 PM   Updated: 22/Dec/07 06:26 AM
Component/s: None
Affects Version/s: JRuby 1.1b1, JRuby 1.0.2
Fix Version/s: JRuby 1.0.3, JRuby 1.1RC1

Time Tracking:
Not Specified

File Attachments: 1. File has_many_through_test.rb (2 kb)

Environment:
JRuby 1.0.2 and JRuby 1.1b1
Oracle and MySQL
activerecord-jdbc-adapter 0.6
Rails 2.0.1


 Description  « Hide
I have a has_many :through relationship ( Role has_many Rights :through => PermissionGroups ). After upgrading to Rails 2.0.1, I am no longer able to save them. Cryptic errors abound. I ran many tests.

MySQL + MRI + Rails 1.2.6 ==> WORKS
MySQL + MRI + Rails 2.0.1 ==> WORKS
MySQL + JRuby (1.0.2 || 1.1b1) + activerecord-jdbc-adapter 0.6 + Rails 1.2.6 ==> WORKS
Oracle + JRuby (1.0.2 || 1.1b1) + activerecord-jdbc-adapter 0.6 + Rails 1.2.6 ==> WORKS
MySQL + JRuby (1.0.2 || 1.1b1) + activerecord-jdbc-adapter 0.6 + Rails 2.0.1 ==> FAILS
Oracle + JRuby (1.0.2 || 1.1b1) + activerecord-jdbc-adapter 0.6 + Rails 2.0.1 ==> FAILS

See all the script/console stuff and errors and class definitions below.

============================
Relevant bits of Role / Right class
============================

class Role < ActiveRecord::Base
has_many :rights, :through => :permission_groups
end

class Right < ActiveRecord::Base
has_many :roles, :through => :permission_groups
end

============================
Using MRI
MySQL
Rails 2.0.1
============================
danbookpro:~/Work daniel$ ruby script/console
Loading development environment (Rails 2.0.1)
>> role_rights = Right.create( {:name => "Administrator - Full Access To Roles", :actions => "*", :controller_name => "Admin::RolesController"} )
=> #<Right id: 3, name: "Administrator - Full Access To Roles", controller_name: "Admin::RolesController", actions: "*">
>> right_rights = Right.create( {:name => "Administrator - Full Access To Rights", :actions => "*", :controller_name => "Admin::RightsController"} )
=> #<Right id: 4, name: "Administrator - Full Access To Rights", controller_name: "Admin::RightsController", actions: "*">
>> admin_role = Role.create( {:name => "Administrator", :description => "System defined super user - access to right and role management."} )
=> #<Role id: 2, name: "Administrator", description: "System defined super user - access to right and rol...">
>> admin_role.rights << role_rights
=> [#<Right id: 3, name: "Administrator - Full Access To Roles", controller_name: "Admin::RolesController", actions: "*">]
>> admin_role.rights << right_rights
=> ">#<Right id: 3, name: "Administrator - Full Access To Roles", controller_name: "Admin::RolesController", actions: "*">, #<Right id: 4, name: "Administrator - Full Access To Rights", controller_name: "Admin::RightsController", actions: "*">
>> admin_role.save
=> true

============================
JRuby 1.1b1 (error occurs in 1.0.2 as well - but stack trace is different)
activerecord-jdbc-adapter 0.6
Rails 2.0.1
Oracle && MySQL (Tested on both Oracle and MySQL Database)
============================
danbookpro:~/Work daniel$ jruby script/console
Loading development environment (Rails 2.0.1)
>> role_rights = Right.create( {:name => "Administrator - Full Access To Roles", :actions => "*", :controller_name => "Admin::RolesController"} )
=> #<Right id: 10002, name: "Administrator - Full Access To Roles", controller_name: "Admin::RolesController", actions: "*">
>> right_rights = Right.create( {:name => "Administrator - Full Access To Rights", :actions => "*", :controller_name => "Admin::RightsController"} )
=> #<Right id: 10003, name: "Administrator - Full Access To Rights", controller_name: "Admin::RightsController", actions: "*">
>> admin_role = Role.create( {:name => "Administrator", :description => "System defined super user - access to right and role management."} )
=> #<Role id: 10001, name: "Administrator", description: "System defined super user - access to right and rol...">
>> admin_role.rights << role_rights
=> [#<Right id: 10002, name: "Administrator - Full Access To Roles", controller_name: "Admin::RolesController", actions: "*">]
>> admin_role.rights << right_rights
=> ">#<Right id: 10002, name: "Administrator - Full Access To Roles", controller_name: "Admin::RolesController", actions: "*">, #<Right id: 10003, name: "Administrator - Full Access To Rights", controller_name: "Admin::RightsController", actions: "*">
>> admin_role.save
ArgumentError: wrong # of arguments(2 for 1)
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/base.rb:2172:in `update'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb:70:in `update_with_lock'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/callbacks.rb:240:in `update_with_callbacks'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/timestamp.rb:38:in `update_with_timestamps'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/base.rb:2165:in `create_or_update'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/callbacks.rb:213:in `create_or_update_with_callbacks'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/base.rb:1899:in `save'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/validations.rb:901:in `save_with_validation'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save_with_transactions'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `transaction'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/transactions.rb:80:in `transaction'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/transactions.rb:76:in `transaction'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save_with_transactions'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `rollback_active_record_state!'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save_with_transactions'
from /Users/daniel/Work/vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `binding'

============================
JRuby 1.1b1
activerecord-jdbc-adapter 0.6
Rails 1.2.6
Oracle
============================
>> role_rights = Right.create( {:name => "Administrator - Full Access To Roles", :actions => "*", :controller_name => "Admin::RolesController"} )
=> #<Right:0x1505b41 @attributes={"name"=>"Administrator - Full Access To Roles", "id"=>10002, "controller_name"=>"Admin::RolesController", "actions"=>"*"}, @new_record_before_save=true, @errors=#<ActiveRecord::Errors:0x183bd71 @errors={}, @base=#<Right:0x1505b41 ...>>, @new_record=false>
>> right_rights = Right.create( {:name => "Administrator - Full Access To Rights", :actions => "*", :controller_name => "Admin::RightsController"} )
=> #<Right:0x683bfc @attributes={"name"=>"Administrator - Full Access To Rights", "id"=>10003, "controller_name"=>"Admin::RightsController", "actions"=>"*"}, @new_record_before_save=true, @errors=#<ActiveRecord::Errors:0x36ea72 @errors={}, @base=#<Right:0x683bfc ...>>, @new_record=false>
>> admin_role = Role.create( {:name => "Administrator", :description => "System defined super user - access to right and role management."} )
=> #<Role:0xe551a4 @attributes={"name"=>"Administrator", "id"=>10001, "description"=>"System defined super user - access to right and role management."}, @new_record_before_save=true, @errors=#<ActiveRecord::Errors:0xd952d1 @errors={}, @base=#<Role:0xe551a4 ...>>, @new_record=false>
>> admin_role.rights << role_rights
=> [#<Right:0x1505b41 @attributes={"name"=>"Administrator - Full Access To Roles", "id"=>10002, "controller_name"=>"Admin::RolesController", "actions"=>"*"}, @new_record_before_save=true, @errors=#<ActiveRecord::Errors:0x183bd71 @errors={}, @base=#<Right:0x1505b41 ...>>, @new_record=false>]
>> admin_role.rights << right_rights
=> [#<Right:0x1505b41 @attributes={"name"=>"Administrator - Full Access To Roles", "id"=>10002, "controller_name"=>"Admin::RolesController", "actions"=>"*"}, @new_record_before_save=true, @errors=#<ActiveRecord::Errors:0x183bd71 @errors={}, @base=#<Right:0x1505b41 ...>>, @new_record=false>, #<Right:0x683bfc @attributes={"name"=>"Administrator - Full Access To Rights", "id"=>10003, "controller_name"=>"Admin::RightsController", "actions"=>"*"}, @new_record_before_save=true, @errors=#<ActiveRecord::Errors:0x36ea72 @errors={}, @base=#<Right:0x683bfc ...>>, @new_record=false>]
>> admin_role.save
=> true
>>



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Daniel Wintschel - 14/Dec/07 11:13 AM
Self contained unit test with migrations and active record models to reproduce the bug.

Daniel Wintschel - 14/Dec/07 12:04 PM
Testing with activerecord-jdbc-adapter 0.7 from Nick Sieger, and using the trunk snapshot build of JRuby (5260) - seems to resolve the issue.

Thomas E Enebo - 15/Dec/07 09:07 AM
Using latest stuff ar-jdbc + jruby's this is working