difficulty implementing $filter

181 views
Skip to first unread message

Mark Tiggas

unread,
Sep 13, 2017, 3:19:28 PM9/13/17
to odata4j-discuss
I'm trying to create a filter function for my needs, and I've run into a bit of a problem with the OptionsQueryParser.parseFilter(s) function. There seem to be several examples from the OData version 4 specification which it cannot parse. Specifically the following fail:

$filter="Name eq 'Milk' and Price lt 2.55"
e.getMessage()=Unable to read expression with tokens: [[2], [.], [55]]

$filter="Name eq 'Milk' or Price lt 2.55"
e.getMessage()=Unable to read expression with tokens: [[2], [.], [55]]

$filter="style has Sales.Pattern'Yellow'"
e.getMessage()=Unable to read expression with tokens: [[style], [ ], [has], [ ], [Sales], [.], [Pattern], ['Yellow']]

$filter="Price add 2.45 eq 5.00"
e.getMessage()=Unable to read expression with tokens: [[2], [.], [45]]

$filter="Price sub 0.55 eq 2.00"
e.getMessage()=Unable to read expression with tokens: [[0], [.], [55]]

$filter="Price mul 2.0 eq 5.10"
e.getMessage()=Unable to read expression with tokens: [[2], [.], [0]]

$filter="Price div 2.55 eq 1"
e.getMessage()=Unable to read expression with tokens: [[2], [.], [55]]

$filter="contains(CompanyName,'Alfreds')"
e.getMessage()=Unable to read expression with tokens: [[CompanyName], [,], ['Alfreds']]

$filter="fractionalseconds(BirthDate) lt 0.1"
e.getMessage()=Unable to read expression with tokens: [[fractionalseconds], [(][BirthDate][)]]

$filter="isof(NorthwindModel.BigOrder)"
e.getMessage()=Unable to read expression with tokens: [[NorthwindModel], [.], [BigOrder]]

$filter="isof($it,NorthwindModel.BigOrder)"
e.getMessage()=Unable to tokenize: isof($it,NorthwindModel.BigOrder) current: 5 rem: $it,NorthwindModel.BigOrder)

$filter="isof(Customer,NorthwindModel.VIPCustomer)"
e.getMessage()=Unable to read expression with tokens: [[NorthwindModel], [.], [VIPCustomer]]

I've also commented out all the statements that print to the console (leaving only those that print to syserr), yet I still get two strings printed to the console:
WORD[isof]
OPENPAREN[(]

My code is attached. I think this is a fault in odata4j's implementation of OptionsQueryParser.parseFilter(), but I'm hoping that there is something I should be doing differently?


Mark Tiggas
InvestigateFilter.java

Prathiba KR

unread,
Mar 4, 2021, 8:16:36 PM3/4/21
to odata4j-discuss
Hi Mark,

since your post is 3 years old, want to know how you solved this issue?

I have run in to a similar issue where i am trying to pass the date in a filter 


the response received is : 400Bad Request
{
    "odata.error": {
        "code""",
        "message": {
            "lang""en-US",
            "value""Unable to read expression with tokens: [[TO_DATE], [(][2011][-07][-28][,][ ][YYYY][-][MM][-][DD][)]]"
        }
    }
}
Trying to pass the date as a string and which is understood by Oracle SQL

Any idea of what could be done here?

Appreciate any helpful response.
Cheers.


Mark Tiggas

unread,
Mar 4, 2021, 8:35:23 PM3/4/21
to odata4j...@googlegroups.com
Sorry to disappoint, but I found that the code base was so riddled with bugs and incomplete capabilities that I had to abandon it.

--
You received this message because you are subscribed to a topic in the Google Groups "odata4j-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/odata4j-discuss/m5Vo6J_YxmI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to odata4j-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/odata4j-discuss/07ac85b4-9a0c-4b6c-b7d3-22d75d5e4feeo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages