Closed inexorabletash closed 4 years ago
This is handled in the steps to asynchronously execute a request:
If result is an error, then revert all changes made by operation.
So... I think it's fine, even though that's fairly disconnected from the algorithm.
https://w3c.github.io/IndexedDB/#object-store-storage-operation has:
Step 1.2: ...run possibly update the key generator for store with key
Step 4: Store a record in store containing...
Steps 5.3 and 5.4: If ... index already contains a record with key equal to index key, and index’s unique flag is true, then this operation failed with a "ConstraintError" DOMException. Abort this algorithm without taking any further steps.
There's no verbiage that the key generator update or store should be undone.
Similarly, if there are multiple indexes, there's no text indicating that a failure on a later index should undo any ...store a record in index... actions.
One approach might be to introduce transaction-like prose, e.g. rewrite the steps as "...tentatively store..." and have a final "commit any tentative changes" sep.
A simpler change might be to have the "Abort this algorithm..." invocation include text to undo any changes to stores or key generator updates made by this algorithm.