Repository navigation
Conversation
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.
patchAndFetch(),patchAndFetchById(),updateAndFetch()andupdateAndFetchById()merge the fetched row into the model they patch with. Each run works on a copy of the query, but that model is shared, so awaiting the same query builder a second time patched all fetched columns, writing back values that other writes had changed in between (#519, since at least 1.0.0).A second run of such a query now throws, and the docs of
execute()say to create a new query for each run. The query counts as run once the fetched row is merged, so a run that fails before that, e.g. on a deadlock, can be retried. Concurrent runs of the same query aren't detected.It throws rather than returning a new model, as the issue proposed, because
patchAndFetchById()returns the model that was passed in as the patch, which a test pins since 2015. Inserts aren't guarded: they also write their ids into the given models, but re-running them already fails with a unique violation, or works as intended withonConflict().As this turns a re-awaited
patchAndFetch()that mostly worked into an error, it's listed under Changes for 4.2.0.Closes #519