I understand that a database is invalid or invalid as a whole, which is why you don't need to check constraints until transaction commit (when the transaction becomes visible to the world). Why do you want to bundle constraint checking with a savepoint release though? They seem logically unrelated. Wouldn't a standalone way to check deferred constraints be more useful?
On Wed, Dec 30, 2015 at 4:23 PM, Shai Berger <[email protected]> wrote: > Hi, > > On Tuesday 29 December 2015 19:40:44 Gavin Wahl wrote: > > What does it even mean for constraints to be checked at savepoint > commit? I > > would expect this to not cause any errors: > > > > with atomic(): > > # insert invalid fk > > with atomic(check_deferred_constraints=True): > > # do stuff that doesn't invalidate any contraints > > # delete the invalid fk inserted before > > > > I think your expectation is wrong, for both technical and "ideological" > reasons. > > Technically, you can easily do things in the inner block which, although > they > do not violate any constraints in themselves, rely on the invalid FK > record. > If that were allowed to pass silently, we would violate the expectation > that > "if the inner block succeeded, then things in it are ok". > > Philosophically, I don't think "checking the constraints only for things I > changed here" is a valid *logical* operation, as you seem to imply; a > database > is valid or broken as a whole. The fact that we can get away with checking > only the changes at a transaction limit is an *implementation* shortcut, > valid > only as far as it is logically equivalent to checking the whole database. > > Shai. > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CACPudh1WTvBi_m%3DJZ%2BZvbWpj-pXu5T%2BpyjEwF%3D5_34pVV-17eA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
