fix: Map::fetch stream continues past row-level mapper errors#4224
Open
barry3406 wants to merge 2 commits intolaunchbadge:mainfrom
Open
fix: Map::fetch stream continues past row-level mapper errors#4224barry3406 wants to merge 2 commits intolaunchbadge:mainfrom
barry3406 wants to merge 2 commits intolaunchbadge:mainfrom
Conversation
Map::fetch() previously used fetch_many() + try_filter_map(), which stopped the stream at the first row-level error from the mapper. This meant query_as!().fetch() would silently stop when one row failed to deserialize, instead of yielding the error and continuing. Switch to executor.fetch().map() which processes each row independently — matching the behavior of query_as().fetch() (fixed in launchbadge#1887). This also resolves the FIXME noting that fetch() should have used executor.fetch() directly. Added a regression test that verifies the stream yields all rows (including errors) instead of terminating early. Fixes launchbadge#4126
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.
Fixes #4126
query_as!().fetch()stops the stream at the first row that fails to deserialize, whilequery_as().fetch()correctly yields the error and continues. The difference:query_as().fetch()usesexecutor.fetch().map(|row| ...)— each item processed independentlyMap::fetch()(used by macros) usedfetch_many()+try_filter_map()inside atry_stream!— the?operator terminates the stream on first errorBefore:
After:
// results = [Ok(1), Ok(2), Err(...), Ok(4), Ok(5)] — all rows yieldedThe fix switches
Map::fetch()to useexecutor.fetch(self.inner).map(...)directly — the same patternquery_as().fetch()uses since #1887. This also resolves the existing FIXME comment that noted fetch() should have usedexecutor.fetch().Added a regression test that inserts 5 rows, makes the mapper fail on row 3, and verifies all 5 items come through the stream (4 successes + 1 error).