Skip to content
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

Not able to use just Date in $filter #1205

Closed
ceouten opened this issue Jul 2, 2018 · 6 comments
Closed

Not able to use just Date in $filter #1205

ceouten opened this issue Jul 2, 2018 · 6 comments
Assignees

Comments

@ceouten
Copy link

ceouten commented Jul 2, 2018

This worked in Odata v6 but is now throwing an error in v7

$filter=CreateDateUtc gt 2014-06-23

In the above example CreateDateUtc would be a DateTimeOffset. I'm not sure what changed between versions that broke this functionality.

The error returned is "The query specified in the URI is not valid. No coercion operator is defined between types 'Microsoft.OData.Edm.Date' and 'System.Nullable`1[System.DateTimeOffset]'."

I tried upgrading to v7.5 but that didn't fix the issue.

I'm fine with writing custom code to handle this but I'm not exactly where I should start. I tried using a custom ODataUriResolver where I override the PromoteBinaryOperandTypes method but that didn't seem to work. Is the best way to make a custom EnableQueryAttribute where I modify the actual query?

Any guidance would be extremely helpful.

@xuzhg xuzhg self-assigned this Jul 2, 2018
@xuzhg
Copy link
Member

xuzhg commented Jul 2, 2018

@ceouten It looks your problem is similar to OData/WebApi#1473

Please refer to OData/WebApi#1473 and get the information. Thanks.

@xuzhg xuzhg closed this as completed Jul 2, 2018
@ceouten
Copy link
Author

ceouten commented Jul 2, 2018

@xuzhg I would prefer not to have to ask all my consumers to change how they are currently using my REST API because I want to upgrade an internal framework. Is there a way I can implement the proposed fix as a custom ExpressionBinder?

@csbowe
Copy link

csbowe commented Jul 2, 2018

I've run into the same issue and like @ceouten I have a public-facing API being consumed where folks are used to being able to filter by a date only, without the date() syntax. We cannot require consumers to change their integrations, so our options are either a) find a workaround we can implement internally or c) plead for this breaking change to be fixed in the next odata version or c) do not upgrade odata to the latest version and eventually move away from it.

@biaol-odata
Copy link
Contributor

biaol-odata commented Jul 2, 2018

Add reference to OData/WebApi #136, for broader context.

@NetTecture
Copy link

It is not "used to" only. OData is an open standard. People may be using toolkits - like excel or PowerBI. Not accepting a by standard well formed URL is a bug, and "rewrite your external tools" is not an answer.

@NetTecture
Copy link

NetTecture commented Jul 29, 2018

Acutally the problem is worse - it seems someone did not want t owrite any unit test for parsing literals of any kind and now as a result of that (plus not really well done programming) quite a number of literal types do not work.

GUID's are also not parsed properly.

Someone obviously did not write or want to write unit tests for literal parsing and then there was a sloppy programming job.

Now a number of iterals are not properly converted and now you seriously xpect other people to rewrite their access libraries to adhere to non-standard Odata?

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

No branches or pull requests

5 participants