-
Notifications
You must be signed in to change notification settings - Fork 164
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
Dates in $filter parsed as DateTime with DateTimeKind.Unspecified #378
Comments
@jamerst We are working on a refactor for FilterBinder to allow customers to override the binding process. Now, the setting on ODataOptions could help you resolve the problem. |
Thanks for the reply @xuzhg How does the |
I agree we are seeing the same |
fixed in today's nightly build! |
This issue still doesn't appear to be resolved as of version 8.0.10. Apologies for the long period of inactivity on the issue, I assumed it was fixed but foolishly didn't confirm it, so I've only just encountered it again. The issue with dates in the query is still present, but I've also discovered very similar issue with POST, PUT and PATCH endpoints where any DateTime properties in the entity are created with DateTimeKind.Unspecified. I've created a basic API to show the issue: https://github.com/jamerst/ODataDateDemo. This can only demonstrate the issue with POST, the issue with parsing dates in $filter is harder to demonstrate without a database to connect to since it's not a problem when querying in-memory. To reproduce the issue, send a POST request to
The endpoint will simply return the I've tried many different combinations of the following in order to fix this, but nothing has worked:
|
@jamerst this is not an answer to your original question, but have you considered migrating towards |
@julealgon good suggestion, should be a good workaround and probably fits my use case better anyway, I'll have to look into it further when I get chance. |
Hi, The issue still persists in 8.0.11. Though I set the TimeZone property of ODataOptions, I receive DateTime Kind as Unspecified. Is there any workaround or fix without changing the Database column type? |
Hi, is there any progress with this issue ? I tried the last version and the issue still exist. |
Hello,
The instruction " return dateTimeOffsetValue.DateTime;", according to the microsoft documentation to DataTimeOffset.Value always return a Kind=Unspecified. The point is that it is not possible to perform this customization using dependency injection. Thanks |
Npgsql 6.0 has a breaking change around timestamp mapping which breaks querying via OData. In order to query a Postgres column of type 'timestamp with time zone', the corresponding DateTime needs to have Kind =
DateTimeKind.Utc
.However, all dates in the $filter clause are parsed with
DateTimeKind.Unspecified
, which causes Npgsql to throw an exception and results in OData returning an invalid and incomplete JSON response.Is there a way to override the parsing of dates? Would it be possible for setting
ODataOptions.TimeZoneInfo = TimeZoneInfo.Utc
to also set theKind
of any parsed dates to UTC?The text was updated successfully, but these errors were encountered: