You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
It seems DataMapper doesn't behave properly when a composite key is split between a foreign key declared with 'belongs_to' and a second, non-unique column declared with 'property'.
Example:
class Person
include DataMapper::Resource
property :id, Integer, :key => true
has n, :aliases
end
class Alias
include DataMapper::Resource
property :alias_num, Integer, :key => true
property :alias, String
belongs_to :person, :key => true
end
personA = Person.new(:id => 1)
personA.aliases.new(:alias_num => 1, :alias => 'Geoffery')
personA.save
personB = Person.new(:id => 2)
personB.aliases.new(:alias_num => 1, :alias => 'Richard')
personB.save
results in error: "column alias_num is not unique"
When 'alias_num' is not required to be unique because it is part of a composite key. Currently, the erroneous behavior can be circumvented by also adding a property declaration to match the belongs_to declaration:
class Alias
include DataMapper::Resource
property :alias_num, Integer, :key => true
property :alias, String
property :person_id, Integer, :key => true
belongs_to :person, :key => true
end
But it seems like such an extra declaration shouldn't be necessary
The text was updated successfully, but these errors were encountered:
It seems DataMapper doesn't behave properly when a composite key is split between a foreign key declared with 'belongs_to' and a second, non-unique column declared with 'property'.
Example:
results in error: "column alias_num is not unique"
When 'alias_num' is not required to be unique because it is part of a composite key. Currently, the erroneous behavior can be circumvented by also adding a property declaration to match the belongs_to declaration:
But it seems like such an extra declaration shouldn't be necessary
The text was updated successfully, but these errors were encountered: