Skip to content

service: group the alternatives of the __in filter lookup - #321

Closed
VitorCoelho wants to merge 3 commits into
SAP:masterfrom
VitorCoelho:fix/filter-in-precedence
Closed

VitorCoelho wants to merge 3 commits into
SAP:masterfrom
VitorCoelho:fix/filter-in-precedence

Conversation

@VitorCoelho

Copy link
Copy Markdown

What

The __in lookup of the chainable filter produced its alternatives without parentheses. Lookups are joined with and, and and binds tighter than or, so combining __in with any other lookup changed the meaning of the filter:

employees.filter(ID__in=[1, 2], NickName="Tim")
# before: $filter=ID eq 1 or ID eq 2 and NickName eq 'Tim'
#         == ID eq 1 or (ID eq 2 and NickName eq 'Tim')  -> wrong rows
# after:  $filter=(ID eq 1 or ID eq 2) and NickName eq 'Tim'

Why

The query returned entities that do not match the other lookups. This is the __in breakage mentioned in the discussion of #280. Only the output of __in itself is grouped, so other filters keep their current URLs, and __in with a single value is still a plain ID eq 1.

How it was tested

  • New test test_count_with_chainable_filter_in_operator_and_other_lookup: fails on master, passes with the fix.
  • New test for a single value (no parentheses).
  • test_count_with_chainable_filter_in_operator now expects (ID eq 1 or ID eq 2 or ID eq 3), which has the same meaning.
  • pytest: 300 passed.
  • CHANGELOG updated (Unreleased / Fixed).

Added tests for counting employees with chainable filters.
Document fixes related to filter lookup and entity updates.
@phanak-sap
phanak-sap self-requested a review October 25, 2026 09:41
@phanak-sap phanak-sap added bug Something isn't working and removed bug Something isn't working labels Oct 25, 2026
@VitorCoelho VitorCoelho closed this by deleting the head repository Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants