Closed eliezeralmeida closed 2 years ago
In my project I resolved the problem adding one interceptor for transform dates to utc dates, but it would be nice to have the fix in the package.
Hi @eliezeralmeida ,
It makes sense, go ahead and make a pr!
Thx
Fixed at v6.0.6
More details: https://www.roji.org/postgresql-dotnet-timestamp-mapping
Details of problem:
From what I understand, basically the problem happens when you have a date with Kind other than UTC, to get around the problem a flag must be changed globally, but it is not a good practice, the best is to use the concept of "UTC Everywhere".
Checking the source code on line 14 of the KeyMaterial file, the Data value starts with Now, this causes the error because of Kind=Local.
Likely correction: KeyMaterial line 14: DateTime.UtcNow KeyMaterial line 37: DateTime.UtcNow
This will make Npgsql not throw excpetion on account of Kind other than UTC and also the dates will be bought in UTC ignoring infra setting.
Imagem do erro em um projeto .NET6 com PostgreSQL:
Conclusion
If these changes make sense for the project proposal, I can be making and submitting the pull request. I used google translate to create the text, in case something was confused in the translation I can send it in pt-br.