Skip to content

Add parenthesis on filter#100

Open
sfreidahl wants to merge 1 commit intoZEXSM:mainfrom
sfreidahl:patch-1
Open

Add parenthesis on filter#100
sfreidahl wants to merge 1 commit intoZEXSM:mainfrom
sfreidahl:patch-1

Conversation

@sfreidahl
Copy link
Copy Markdown

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
Copy Markdown
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

Copy link
Copy Markdown

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
Copy Markdown
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