-
Notifications
You must be signed in to change notification settings - Fork 3
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
Unable to parse or for both string comparisons. #1
Comments
Hi, Thanks for your post. Intially this project was built as a prototype and only covers limited cases to demostrate the POC. In future, I have a plan to work on it and make it more concrete with respect to OData spec. If you can comeup with a generic solution, please feel free to open a PR. Regards, Adil |
That would be great. Thanks.
|
I have some time to verify the change with new added test to your suite: test("Parse $filter=Name eq 'Tom' and LastName eq 'Jones'") {
val query = "$filter=Name eq 'Tom' and LastName eq 'Jones'"
val expectedAST =
Filter(
AndExp(
EqualToExp(
Property("Name"),
StringLiteral("'Tom'")
)
, EqualToExp(
Property("LastName"),
StringLiteral("'Jones'")
)
)
)
val actualAST:Expression = p.parseThis(mainParser, query).get
assert(actualAST == expectedAST)
} While taking out the change to idn because it fails the ResourcePath parsing. I think the code should be working for the filter and parser with the change. However, it still does not take care of the case where filter name is nested like $filter=User/Name eq 'Tom' and User/LastName eq 'Jones' which is acceptable by the v4 standard. |
I have the query as below -
"$filter=item eq '12' or itimeLineItems eq 'new'"
And the result is
Filter(EqualToExp(Property(item),StringLiteral('12' or itimeLineItems eq 'new')))
While "$filter=item eq 12 or itimeLineItems eq 'new'" is parsed correctly:
Filter(OrExp(EqualToExp(Property(item),Number(12)),EqualToExp(Property(itimeLineItems),StringLiteral('new'))))
Also the Property seems to be limited to name without / in the path as item/color. Thanks for your help.
Note: I am updating the code
from
lazy val string: PackratParser[StringLiteral] = ("'" + """([^"\p{Cntrl}\]|\[\/bfnrt]|\u[a-fA-F0-9]{4})*""" + "'").r ^^ StringLiteral | stringLiteral ^^ StringLiteral
to
lazy val string: PackratParser[StringLiteral] = ("""(["'])(?:\1|.)*?\1""").r ^^ StringLiteral
and
from
lazy val idn: PackratParser[Property] = ident ^^ Property
to
lazy val idn: PackratParser[Property] = "[A-Za-z0-9/]+".r ^^ Property | ident ^^ Property
And those seem to fix the issues for limited test cases I have.
The text was updated successfully, but these errors were encountered: