Changeset [d462db9fa77f94e0db51e4a48271334f60449644] by Anders Törnqvist and Jonas Nicklas

July 8th, 2011 @ 04:37 AM

Do not optimize away checking non-dirty attributes

There are a lot of situations where this is a bad
move and can lead to invalid data in the database.
The attached testcase is a simple example of this
problem, where a change to another field
invalidates the resource. DM will now happily save
this resource, even though it is quite clearly
invalid.

We also removed the check where valid? isn't
called at all if the model isn't dirty. It's not
safe to assume that the model is valid just
because there are no dirty attributes, the
validations of the model class may have changed
since the model was added to the DB. With the
current architecture there is no way of even
checking if such invalid models exist.
https://github.com/datamapper/dm-validations/commit/d462db9fa77f94e...

Committed by Anders Törnqvist and Jonas Nicklas

  • A spec/fixtures/llama_spaceship.rb
  • A spec/integration/dirty_attributes/dirty_attributes_spec.rb
  • M lib/dm-validations.rb
  • M lib/dm-validations/contextual_validators.rb
  • M spec/public/resource_spec.rb
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 »