#1264 new
Daniel Ribeiro

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

class DemiGod < Deity

class God < Deity
  has n, :deitys
God.create :name => "zeus" # DataMapper::SaveFailureError: God#save returned false, God was not saved

Comments and changes to this ticket

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket