Skip to content

Building of a filter with both "any" and "or" fails on keeping operations priority #1415

Description

@AndreyAndreev

The ODataUri.BuildUrl() method fails when a filter looks like this: any() and (condition1 or condition2)

Assemblies affected

OData .Net lib 7.6.0.30305

Reproduce steps

The test case to demonstrate the bug:

public void BuildFilterWithOpenPropertyInsideAnyAndTwoOrs()
{
    Uri queryUri = new Uri("People?$filter=MyPaintings%2Fany(p%3Ap%2FOpenProperty) and (ID eq 124) and ((ID eq 125) or (ID eq 126))", UriKind.Relative);
    Uri actualUri = UriBuilder(queryUri, ODataUrlKeyDelimiter.Parentheses, settings);
    Assert.Equal(new Uri("http://gobbledygook/People?$filter=MyPaintings%2Fany(p%3Ap%2FOpenProperty) and ID eq 124 and (ID eq 125 or ID eq 126)"), actualUri);
}

Expected result

The parentheses at the end of the filter shouldn't be removed. The result is expected to be like this:
http://gobbledygook/People?$filter=MyPaintings/any(p:p/OpenProperty) and ID eq 124 and (ID eq 125 or ID eq 126)

Actual result

All the parentheses are removed which ruins the filter breaking operations priorities.

http://gobbledygook/People?$filter=MyPaintings/any(p:p/OpenProperty) and ID eq 124 and ID eq 125 or ID eq 126

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions