#537 ✓resolved
Lincoln Ritter

Resource#save fails for resources with non-serial keys that have defaults

Reported by Lincoln Ritter | August 21st, 2008 @ 04:38 PM

Saving a new resource with a non-serial, key property that has a default value fails and the resource does not get created. It seems that the resource isn't saved since it is not marked dirty and does not have any serial keys even though the value will be set via the default once it is accessed. For example


class Ticket
  include DataMapper::Resource
  property :id, String, :key => true, :default => lambda {|r,p| UUID.new}
end

Ticket.new.save # fails!

This ticket includes a patch that includes a spec demonstrating the problem and code that solves this problem.

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

Attachments

Pages