Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong negation under allGroupSegmentsAreMatched for 'not' operator #64

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

polok
Copy link
Contributor

@polok polok commented Feb 22, 2024

Background

Conditions can also be combined using not operator.

# ...
conditions:
  not:
    - attribute: country
      operator: equals
      value: us

Issue

When using not operator all segment groups have to match. Moreover, if at least one of the segment doesn't match at the end we get false positive.

Where to fix?

In this line:

return !notGroupSegment.not.allSatisfy { groupSegment in

before:

case .not(let notGroupSegment):
return !notGroupSegment.not.allSatisfy { groupSegment in
    allGroupSegmentsAreMatched(
            groupSegments: groupSegment,
            context: context,
            datafileReader: datafileReader

after:

case .not(let notGroupSegment):
return notGroupSegment.not.allSatisfy { groupSegment in
    !allGroupSegmentsAreMatched(
            groupSegments: groupSegment,
            context: context,
            datafileReader: datafileReader
    )
}

@polok polok requested a review from a team as a code owner February 22, 2024 20:55
return !notGroupSegment.not.allSatisfy { groupSegment in
allGroupSegmentsAreMatched(
return notGroupSegment.not.allSatisfy { groupSegment in
!allGroupSegmentsAreMatched(
Copy link
Member

@fahad19 fahad19 Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@polok polok merged commit 785984e into main Feb 23, 2024
1 check passed
@polok polok deleted the bugfix-segments-not-operator branch February 23, 2024 08:34
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.

4 participants