Repository navigation
fix(datastore): keep existing query in add_must_sub_query - #9
Merged
adamsrnmsu merged 1 commit intoNov 18, 2026
Merged
Conversation
add_must_sub_query silently discarded the caller's query when it was
not a bool query: it replaced it with an empty bool and only added the
sub query. Direct callers (anything not going through pull(), which
wraps the query first) lost their match/term filter.
Root cause: the "bool" not in query branch did query = {"bool": {}}
instead of wrapping the existing query. The fix wraps a non-empty
non-bool query into bool.must, the same way add_filter in this file
does. An empty query and an existing bool query behave as before.
Verified:
- new test_non_bool_query_is_preserved_alongside_sub_query fails on
main (query dropped) and passes with the fix; the existing-bool and
empty-query tests pass on both
- full pytest: the same 21 failures and 1 error as main and nothing
new (Elasticsearch tests with no server running, plus the known
macOS-only test_build_paths_uses_var_lib_for_manifest_state)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
5 of 11 tasks
Ethane98
approved these changes
Nov 18, 2026
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.
Description
datastore/query_api.pyadd_must_sub_query(query, sub_query)silently discarded the caller's query when it was not a bool query:if "bool" not in query: query = {"bool": {}}. A caller passing{"match": ...}got back only the sub query, with its own filter gone.pull()wraps the query first, so it was not affected; direct callers were.Fix: a non-empty non-bool query is wrapped into
bool.must, the same wayadd_filterin the same file does it. An empty query and an existing bool query behave as before.Related Issues/PRs
Type of Change
fix)feat)docs)refactor)chore)Checklist
Testing
tests/test_query_api_must_sub_query.py: existing bool query (and the input is not mutated), non-bool query preserved alongside the sub query, empty query. The non-bool test fails onmainand passes with the fix.mainand no new ones (Elasticsearch tests that need a server, plus the macOS-onlytest_build_paths_uses_var_lib_for_manifest_state).🤖 Generated with Claude Code