And noticed that since the validations are checked before executing
the SQL updates it will always fail even if it is within a
transaction. I though perhaps it could be interesting to delay
validations at the end of the transactional context.
I would like to know if you are interested in adding such a type of
Example to add to test/cases/validations/uniqueness_validation_test.rb
e1 = Event.find(1)
e2 = Event.find(2)
e1.title = 'E2'
e2.title = 'E1'
assert_equal Event.find(1).title, 'E2'
assert_equal Event.find(2).title, 'E1'
An equivalent SQL would be:
update events set title='E2' where id = 1;
update events set title='E1' where id = 2;
Check Constraints after updates:
select events.id from events where title = 'E2' and id <> 1;
select events.id from events where title = 'E1' and id <> 2;
Commit or Rollback accordingly