Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Brackets #36

Open
unlight opened this issue Jul 30, 2016 · 3 comments
Open

Brackets #36

unlight opened this issue Jul 30, 2016 · 3 comments

Comments

@unlight
Copy link

unlight commented Jul 30, 2016

Consider following queries:
$filter=name eq 'John' or name lt 'Doe' and address gt 'x1234'
$filter=(name eq 'John' or name lt 'Doe') and name gt 'x1234'
AST for these queries is the same.

{
    "type": "or",
    "left": {
        "type": "eq",
        "left": {
            "type": "property",
            "name": "name"
        },
        "right": {
            "type": "literal",
            "value": "John"
        }
    },
    "right": {
        "type": "and",
        "left": {
            "type": "lt",
            "left": {
                "type": "property",
                "name": "name"
            },
            "right": {
                "type": "literal",
                "value": "Doe"
            }
        },
        "right": {
            "type": "gt",
            "left": {
                "type": "property",
                "name": "address"
            },
            "right": {
                "type": "literal",
                "value": "x1234"
            }
        }
    }
}
@mkasberg
Copy link

mkasberg commented Aug 1, 2016

The current implementation of the grammar does not know about operator precedence (in this case, specifically with and/or). You're right that this is incorrect behavior. Until it's fixed, the workaround is to always use parenthesis. Notice the following ASTs are different:

$filter=(name eq 'John' or name lt 'Doe') and name gt 'x1234'
$filter=name eq 'John' or (name lt 'Doe' and name gt 'x1234')

@traveldevel
Copy link

Also the folowing $filter pattern gives an error :

$filter=(created_at gt datetime'2017-01-01T17:41:32.102Z' and created_at lt datetime'2017-09-28T17:41:32.102Z') or device_id eq '59cbecac6354260045e46a91'

@igordeoliveirasa
Copy link

Any news?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants