Repository navigation
Conversation
lehni
force-pushed
the
fix/517
branch
4 times, most recently
from
October 18, 2026 14:08
af264ae to
5992394
Compare
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.
patchAndFetchById(id, {})and the other*AndFetch*methods returnedundefinedfor an existing row when the patch was empty. Since 1.5.0, an update with nothing to write isn't run and resolves with 0, and the fetch read that 0 as "no rows matched".An empty update now still fetches. As nothing was written, the fetch uses the find form of the update, the same query the static hooks get from
asFindQuery(), so the row comes back only if it matches the update's filters, e.g.where()or the relation of$relatedQuery(). Updates that write something fetch by id as before, since a write can change the filtered columns. A builderonBuild()that selects columns applies to the fetch of an empty update; the fetch of a write copies only explicitselect()calls, as before.The find form had a bug of its own, also in
asFindQuery()of static after hooks since 2.0.0: it was taken from the built write query, which already holds what theonBuildhooks of its context added, and they ran again when the find query was built, so e.g. a context join was added twice ("ambiguous column name"). The query now remembers which operations its context'sonBuildhooks added during the build, andtoFindQuery()leaves them out.toFindQuery()also clears the write'srunAfter()callbacks, resolve value and fetched graph itself, whichasFindQuery()did before, so both callers share it.Tests cover
patchAndFetchById(),updateAndFetchById(),$query().patchAndFetch()and a many-to-many$relatedQuery().patchAndFetchById(), each with a matching and a non-matching row, an empty patch with a joining contextonBuild, andasFindQuery()inafterUpdate,afterInsertandafterDeletewith a joining contextonBuild(afterDeletenot on SQLite, which can't delete with joins). They fail without the fix.Closes #517