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

Add parenthesis on filter #100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add parenthesis on filter #100

wants to merge 1 commit into from

Conversation

sfreidahl
Copy link

When combining several filters by calling Filter() multiple times, they will be joined by "and" which is "fine".
The issues comes when there's an or in one of the filters, which will produce unexpected results.
e.g.
Filter(x => x.Foo == "some string")
Filter(x => x.Bar == 1 || x.Bar == 2 )
Should be:
"(Foo eq 'some string') and (Bar eq 1 or Bar eq 2)"
But will be:
"Foo eq 'some string' and Bar eq 1 or Bar eq 2"

@sfreidahl sfreidahl marked this pull request as draft June 7, 2022 11:21
@sfreidahl sfreidahl marked this pull request as ready for review June 7, 2022 12:59
{
ExpressionType.And => true,
ExpressionType.AndAlso => true,
ExpressionType.And => true && _expressionType.HasValue,
Copy link
Owner

Choose a reason for hiding this comment

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

need a unit test

Choose a reason for hiding this comment

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

@sfreidahl Mind adding the unit test? Would love to see this PR get accepted.

Copy link
Author

Choose a reason for hiding this comment

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

@ZEXSM a unit test has been added

When combining several filters by calling Filter() multiple times, they will be joined by "and" which is "fine".
The issues comes when there's an or in one of the filters, which will produce unexpected results.
e.g.
Filter(x => x.Foo == "some string")
Filter(x => x.Bar == 1 || x.Bar == 2 )
Should be:
"(Foo eq 'some string') and (Bar eq 1 or Bar eq 2)"
But will be:
"Foo eq 'some string' and Bar eq 1 or Bar eq 2"
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.

3 participants