I've the following model, a Booking and a BookingDriver that is created when
the booking
has a driver information.
class Booking
include DataMapper::Resource
property :id, Serial
end
class BookingDriver
belongs_to :booking, :key => true, :parent_key => [:id], :childkey => [:id]
end
and DataMapper::Model.raise_on_save_failure = true
In the BookingDriver unit testing I'm doing the following :
booking = Booking.new
booking_driver = BookinDriver.new :booking => booking
booking_driver.save
When I do this, both the booking and the booking driving are saved, but if an
error is produced
due to others properties, because both have more properties, then the booking
is created and the
booking_driver is not. I can see the INSERT opertation in the log.
Question 1 : Why is the booking_driver fails the booking remains saved
I also tried to use transactions
BookingDriver.transaction do
booking_driver.save
end
In this case, the INSERT is rolled back, but the booking.saved? returns true.
Question 2: Why it returns true if it's really not saved?
Question 3: Is correct to define only one side of the relationship. In this
case I do not want
the Booking knows about the booking driver, because I probably use the booking
for other
types of booking.
Thank you
Juan
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.