
SaveFailureError when Using Inheritance
Reported by Daniel Ribeiro | May 10th, 2010 @ 08:21 PM
Update: the changes on 1.0.0 made the error change from IntegrityError to SaveFailureError, provided I use validations and turn DataMapper::Model.raise_on_save_failure = true. Without raise_on_save_failure, it just fails silently.
When a subclass has a 1-n relationship with its superclass, creating an instance of the former returns an Integrity error. A simple example:
require 'dm-core'
require 'dm-migrations'
require 'dm-validations'
require 'pp'
DataMapper.setup :default, 'sqlite3:database.Sqlite3'
DataMapper::Model.raise_on_save_failure = true
class Deity
include DataMapper::Resource
property :god_id, Serial
property :name, String
property :type, Discriminator
end
class DemiGod < Deity
end
class God < Deity
has n, :deitys
end
DataMapper.auto_migrate!
God.create :name => "zeus" # DataMapper::SaveFailureError: God#save returned false, God was not saved
Comments and changes to this ticket
-
Daniel Ribeiro July 18th, 2010 @ 09:05 PM
- Milestone order changed from 0 to 0
-
Daniel Ribeiro July 18th, 2010 @ 09:09 PM
- Title changed from IntegrityError when Using Inheritance to SaveFailureError when Using Inheritance
- Tag changed from integrity error inheritance to 1.0, savefailureerror
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 »