jirutka / rsql-parser

Parser for RSQL / FIQL – query language for RESTful APIs
739 stars 156 forks source link

Allowing reserved character in selector ? #32

Open ajitnain opened 6 years ago

ajitnain commented 6 years ago

Currently reserved character are not allowed in selector. In one of my use case selector contains reserved characters.

  1. Is there any way to handle this.
  2. What was the reason for not allowing reserved character in selector. I think it could have been handled like arguments i.e. if reserved characters in selector then it can be quoted.

Thanks

mkargar commented 6 years ago

Seems that changing Selector() in RSQLParser.jj from

String Selector(): {}
{
    token = <UNRESERVED_STR>
    {
        return token.image;
    }
}

to

String Selector(): {}
{
    token = <UNRESERVED_STR> { return token.image; }
    |
    ( token = <DOUBLE_QUOTED_STR> | token = <SINGLE_QUOTED_STR> )
    {
        return unescape(token.image.substring(1, token.image.length() -1));
    }
}

Addresses the issue.

Still not sure why they are excluded in the first place!