alirezanet / Gridify

Easy and optimized way to apply Filtering, Sorting, and Pagination using text-based data.
https://alirezanet.github.io/Gridify/
MIT License
801 stars 64 forks source link

DateTime Kind and Postgres #188

Closed moxplod closed 1 month ago

moxplod commented 1 month ago

Version

2.14.2

Details

Bringing this up from this issue - https://github.com/alirezanet/Gridify/issues/134

And your quote -

Recognizing the importance of this issue, I am considering adding a setting/configuration in future versions that would allow users to choose the default DateTimeKind conversion. This feature would provide a more flexible and straightforward way to manage DateTime conversions according to individual project needs, reducing the necessity for manual adjustments via the GridifyMapper.

Without this setting, datetime filtering is broken in Postgres for Gridify, and I am unable to set this in Map as I have many DateTime (nullable and not nullable) properties across many entities.

Steps to reproduce

Use any datetime property (I tried it with a nullable datetime property). Try filtering by datetime string.

We get the error - System.ArgumentException: 'timestamp with time zone' literal cannot be generated for Unspecified DateTime: a UTC DateTime is required

cirrusone commented 1 month ago

You may find this post useful which relates to this Mapping .NET Timestamps to PostgreSQL

This lists all of the breaking changes from Npgsql 6.0 with explanations.

moxplod commented 1 month ago

You may find this post useful which relates to this Mapping .NET Timestamps to PostgreSQL

This lists all of the breaking changes from Npgsql 6.0 with explanations.

I read that a while ago, and my application is using the new recommended NpgSql and .net behavior. timestamptz for columns and all the datetime properties are consistently passed as Kind Utc. Which is where this bug comes in - NpgSql throws an error when the string datetime is converted to unspecified kind by Gridify.

moxplod commented 1 month ago

@alirezanet I will attempt to fix this and also complete https://github.com/alirezanet/Gridify/issues/191 I would appreciate any pointers that would help me do either of these before I dive into the Gridify code (for the first time).

moxplod commented 1 month ago

This was merged.