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

Dates in $filter parsed as DateTime with DateTimeKind.Unspecified #704

Open
2002Ezio opened this issue Mar 10, 2022 · 1 comment
Open

Dates in $filter parsed as DateTime with DateTimeKind.Unspecified #704

2002Ezio opened this issue Mar 10, 2022 · 1 comment

Comments

@2002Ezio
Copy link

I'm working on the breakdance-net5, with the latest postgres provider.

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.

Setting builder.Select().Expand().Filter().OrderBy().MaxTop(100).Count().SetTimeZoneInfo(TimeZoneInfo.Utc);

Assemblies affected
This behavior is observed using the latest bits in the branch titled "breakdance-net5"

Reproduce steps
Uses a postgres data base with the latest npgsql provider and try to filter an entity by date and time

https://localhost:44307/v_errorlog?$orderby=datetimeinlocaltime desc&$top=10&$filter=(datetimeinlocaltime ge 2022-03-10T16:43:00Z) and (datetimeinlocaltime lt 2022-03-10T16:44:00Z)&$count=true

Actual Result
write DateTime with Kind=Unspecified to PostgreSQL type 'timestamp with time zone', only UTC is supported. Note that it's not possible to mix DateTimes with different Kinds in an array/range. See the Npgsql.EnableLegacyTimestampBehavior AppContext switch to enable legacy behavior.

@robertmclaws
Copy link
Collaborator

It seems like this might have been an issue with the core OData libraries. I apologize for not seeing this issue sooner... were you able to work it out?

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

2 participants