
`assert_valid_fields': +options[:field]+ entry :<child_only_property> does not map to a property in <rootclass> (ArgumentError)
Reported by Andrea Dallera | September 29th, 2009 @ 08:56 AM | in 1.0.0
The following code:
require 'rubygems'
require 'dm-core'
include DataMapper::Types
class Root
include DataMapper::Resource
property :id, Serial
property :name, String
property :type, Discriminator
end
class Branch < Root
property :value, Integer
end
DataMapper.setup(:default, {:adapter => 'sqlite3', :database => 'test.db'})
DataMapper.auto_migrate!
branch_one = Branch.new
branch_one.name = "branch one"
branch_one.value = 42
branch_one.save
entities = Root.all
p entities[0].value
raises an ArgumentError, coming from an assert in Query. The cause is that entities[0] is recognized as a Root while it is a Branch instead in the Query constructor (line 590 in query.rb), which determines @property to be Root.properties and not Branch.properties and then causes the assert fail in assert_valid_fields
Comments and changes to this ticket
-
Andrea Dallera May 28th, 2010 @ 01:46 AM
I ran this against dm-core (v 10.2) and it works fine so I think you can close this.
-
Dan Kubb (dkubb) May 28th, 2010 @ 01:47 PM
- Milestone set to 1.0.0
- State changed from new to resolved
- Assigned user set to Dan Kubb (dkubb)
I can also confirm this works with DM 1.0.0 rc3.
I believe this was resolved in some changes I made before 0.10.2 in how Query tests the properties added to the query fields.
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 »