Conversation
`filter: {or: [{}]}` (or `and`, or an entry whose only operator comes
from an omitted variable) dropped each empty entry but still pushed the
compound filter, which transpiled to `()` and failed with a SQL syntax
error. Skip the compound filter when no entries remain, the same way an
empty list is already ignored.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
|
Closing as this is 100% AI generated. |
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.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
An
and/orfilter whose entries are all empty fails with a raw SQL error, where it should be ignored:{ accountCollection(filter: {or: [{}]}) { edges { node { id } } } } # {"errors": [{"message": "syntax error at or near \")\""}]}The same happens with
and: [{}], withnot: {or: [{}]}, onupdate/deletemutation filters, and, most commonly in practice, when an entry's only operator comes from an omitted variable:create_filtersdrops each empty entry (the "Avoid argumentlessand" branch). If nothing is left, it still pushesCompoundFilterBuilder::Or(vec![]), which transpiles to().What is the new behavior?
When no entries remain, the compound filter is skipped, just as
or: []/and: []already are. The docs say "Empty filters are ignored, i.e. they behave as if the operator was not specified at all". Mixed lists are unchanged:or: [{}, {id: {eq: 2}}]still returns id 2 only.Additional context
test/sql/compound_filters_empty_entries.sqlcoversor: [{}],and: [{}], the omitted-variable case, a mixed list,notaround an emptyor, and an update mutation.dockerfiles/db/Dockerfiletoolchain (PG 17, pgrx 0.19.2):syntax error at or near ")"../bin/installcheckpasses all 123 tests.cargo fmt --checkandcargo clippy --features pg17 -- -D warningsare clean.This PR was prepared with AI assistance (Claude). I reviewed and tested the change as described above.
🤖 Generated with Claude Code