Hello, all!

We're on DM 0.10.2, with an application using two (mysql innodb)
repositories.  The default repo holds our app models, while the 2nd
one contains a user table.

One of our models (call it Widget) declares ownership with a
"belongs_to :user, :repository => :the_user_repo".  I believe this is
causing some odd behavior when saving Widgets inside a transaction,
since the save is trying to transactionally cascading to user, in
another repo(..?)

The error (trace below) is cropping up in a controller, when saving a
different app model, call it Whatzit.  Whatzits belongs_to :widget.
The .save() call in the controller is wrapped in a Whatzit.transaction
block.  When the transaction block is removed, the error goes away.

Would the Gurus that Be agree with our assessment of the situation?
If so, is there something we can do about it?  My gut says the real
problem is the ownership semantics that come with belongs_to, which
perhaps aren't appropriate for this one case (this user table would
ideally be a read-only source.)  Is there some other way of declaring
the relation, so that the foreign key still resides on Widget, but
saves (or other mutating operations) don't cascade?  Unfortunately
changing the user table schema is not an option.

The trace:

~ Unknown adapter #<DataMapper::Adapters::MysqlAdapter:0x101dab400> -
(RuntimeError)
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/transaction.rb:
222:in `primitive_for'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/transaction.rb:
438:in `current_connection'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/transaction.rb:
412:in `open_connection'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/adapters/
data_objects_adapter.rb:269:in `with_connection'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/adapters/
data_objects_adapter.rb:136:in `read'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/repository.rb:
145:in `read'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/model.rb:317:in
`first'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/associations/
many_to_one.rb:97:in `resource_for'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/associations/
many_to_one.rb:182:in `lazy_load'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/associations/
many_to_one.rb:112:in `get'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/model/
relationship.rb:350:in `user'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:
93:in `__send__'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:
93:in `validation_property_value'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations/
validators/required_field_validator.rb:10:in `call'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations/
contextual_validators.rb:58:in `execute'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations/
contextual_validators.rb:57:in `map'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations/
contextual_validators.rb:57:in `execute'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:
89:in `hookable__valid_ques_before_advised'
~/.bundle/ruby/1.8/gems/extlib-0.9.14/lib/extlib/hook.rb:299:in
`valid?'
~/.bundle/ruby/1.8/gems/extlib-0.9.14/lib/extlib/hook.rb:297:in
`catch'
~/.bundle/ruby/1.8/gems/extlib-0.9.14/lib/extlib/hook.rb:297:in
`valid?'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:
60:in `save_self'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:942:in
`__send__'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:942:in
`save_parents'
/opt/local/lib/ruby/1.8/digest.rb:13:in `all?'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:939:in
`each'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:939:in
`all?'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:939:in
`save_parents'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:1085:in
`run_once'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:938:in
`save_parents'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:912:in
`_save'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:1085:in
`run_once'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:911:in
`_save'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/resource.rb:351:in
`save'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:
48:in `save'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations/
support/context.rb:30:in `validation_context'
~/.bundle/ruby/1.8/gems/dm-validations-0.10.2/lib/dm-validations.rb:
48:in `save'
~/code/the_app/app/controllers/some_controller.rb:105:in `update'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/transaction.rb:
475:in `transaction'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/transaction.rb:
131:in `commit'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/transaction.rb:
195:in `within'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/transaction.rb:
131:in `commit'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/transaction.rb:
475:in `transaction'
~/code/the_app/app/controllers/some_controller.rb:82:in `update'
~/.bundle/ruby/1.8/gems/merb-action-args-1.0.15/lib/merb-action-args/
abstract_controller.rb:42:in `__send__'
~/.bundle/ruby/1.8/gems/merb-action-args-1.0.15/lib/merb-action-args/
abstract_controller.rb:42:in `_call_action'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0.15/lib/merb-core/
controller/abstract_controller.rb:289:in `_dispatch'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0.15/lib/merb-core/
controller/merb_controller.rb:252:in `_dispatch'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0.15/lib/merb-core/
dispatch/dispatcher.rb:100:in `dispatch_action'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0.15/lib/merb-core/
dispatch/dispatcher.rb:100:in `synchronize'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0.15/lib/merb-core/
dispatch/dispatcher.rb:100:in `dispatch_action'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0.15/lib/merb-core/
dispatch/dispatcher.rb:74:in `handle'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0.15/lib/merb-core/
dispatch/dispatcher.rb:36:in `handle'
~/.bundle/ruby/1.8/gems/merb-core-1.0.15/lib/merb-core/rack/
application.rb:17:in `call'
~/.bundle/ruby/1.8/gems/merb-core-1.0.15/lib/merb-core/rack/middleware/
static.rb:28:in `call'
~/.bundle/ruby/1.8/gems/merb_datamapper-1.0.15/lib/merb_datamapper.rb:
78:in `call'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core.rb:208:in
`repository'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core/repository.rb:
111:in `scope'
~/.bundle/ruby/1.8/gems/dm-core-0.10.2/lib/dm-core.rb:208:in
`repository'
~/.bundle/ruby/1.8/gems/merb_datamapper-1.0.15/lib/merb_datamapper.rb:
76:in `call'
~/.bundle/ruby/1.8/gems/merb-core-1.0.15/lib/merb-core/test/helpers/
request_helper.rb:43:in `request'
~/code/the_app/spec/requests/some_controller/edit_spec.rb:114

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamap...@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to