
Auto-generated foreign keys aren't accessible from Model.update
Reported by Fred Wu | April 15th, 2010 @ 10:18 PM
For example, the following model has a 'belongs_to' association.
class ExampleModel
include DataMapper::Resource
property :id, Serial
property :title, String
belongs_to :some_other_models
end
ExampleModel.create (and .new + .save) works fine.
However, upon using ExampleModel.update({attributes}), the auto-generated foreign key could not be accessed:
The attribute 'some_other_model_id' is not accessible in
ExampleModel
The work-round is to manually set a
some_other_model_id
property in the model, but I
believe the behaviour is inconsistent between save and update, thus
should be fixed.
Any thoughts?
P.S. I did a search on lighthouse and cannot see this reported, I apologise it's duplicated.
Comments and changes to this ticket
-
John E. Vincent June 28th, 2010 @ 12:52 PM
- Milestone order changed from 0 to 0
I just want to confirm that this bug is still happening for me as well. dm-core 1.0.0
-
Martin Gamsjaeger (snusnu) June 28th, 2010 @ 08:50 PM
- Assigned user set to Martin Gamsjaeger (snusnu)
- State changed from new to not-applicable
Guys, I can't reproduce this. Are you calling
DataMapper.finalize
afterDataMapper.auto_migrate!
?Marking this not applicable for now. We can always reopen it if I misunderstood your issue.
-
John E. Vincent June 28th, 2010 @ 08:55 PM
I'll give it a shot outside of my Padrino application again but I tested it outside of the framework and got the same results before commenting on the ticket. Let me also try it with 1.8.7 as well.
-
John E. Vincent June 28th, 2010 @ 09:21 PM
Okay it looks like in my case I wasn't calling finalize. I swear I was.
This means that it's not being called properly in Padrino either. I was just about to open a bug with Padrino when I came across this:
http://github.com/padrino/padrino-framework/issues/#issue/207
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »