Repository navigation
Write a delete without a state when its row is already gone - #182
Merged
Merged
Conversation
With on_error="log" (the default), an object whose row is gone when record_state loads its state (an unloaded tracked collection, a deferred column or a column expired on its own) now gets its entry without data.state and with data.state_missing = "row_gone", and a warning on audit_trail.listener naming the model and the id. The other objects of the flush keep their full states; a present state is always complete. With on_error="raise" the flush still fails with ObjectDeletedError. state_missing is an ordinary data key: scrub() keeps it, compaction takes it from the newest row, and integrity seals it in the leaf, so rows without it commit and seal byte for byte as before.
The row_gone marker, the member ids and the loaded column keys that load_for_state puts on InstanceState.info were cleared only by the next load of that instance or by the entry that used them. A flush that failed after marking an instance (StaleDataError, an IntegrityError of another object) left them behind, so a later entity.created of the same object could lose its state to a stale row_gone marker or get stale member ids for an untouched collection. The session now records the instances it gave keys to and drops the keys when the flush ends: in after_flush_postexec, in after_transaction_end of the flush's own subtransaction (a failed flush), and when loading itself raises in before_flush. A created entry also ignores both keys, since nothing is loaded for a new instance. The docs no longer say an update of a gone row always fails: one that only changes a tracked collection runs no UPDATE of the row, so its entry gets state_missing too, and state_at raises ValueError for it. The CHANGELOG names ActivityData.state_missing and that ValueError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Compatibility
Tests
Review follow-up