You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unique attributes: conditional deletes of missing items skip the condition, and stale instances fail unexplained #81
Priority: medium. Two gaps in deletes and updates of models with unique attributes (repository.py, _plan_delete; transactions.py):
A conditional delete of a missing item ignores the condition. For unique models, the delete reads the stored item for its guards and returns None when there is none, without sending the caller's condition; in a transaction the step is dropped. Plain models raise ConditionalCheckFailedError or cancel the transaction. So tx.delete(User.key(...), model=User, condition=...), used as a guard of the transaction, lets the rest commit.
Unversioned unique models raise an unexplained ConditionalCheckFailedError when the stored unique values changed since the instance was loaded: delete() of a loaded instance after the item was deleted elsewhere (plain models return None), or after another writer changed a unique value, says "the condition of delete failed" though no condition was given; update(handle.set(...)) fails the same way. put() and save() already read the stored item again in this case (_write).
Fix: keep the caller's condition when the item is missing (send a ConditionCheck, or fail the delete), and re-read and re-plan deletes and updates of unversioned unique models like put()/save() do.
Found in a review of the library for bugs (fctl session); the fixes that fit in its ten pull requests are #61 to #65, #67 to #70 and #72.
Activity