You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A UTC DateTime is converted to a local DateTime before being passed to custom JsonConverters inside of ExpressionToSql.ApplyCustomConverters.
******* Incorrect *******
Date: 5/26/2022 12:00:00 AM
DateTimeKind: Utc
Query: {"query":"SELECT VALUE root FROM root WHERE (root[\"StartDate\"] <= \"2022-05-25\")"}
******* Correct *******
Date: 5/26/2022 12:00:00 AM
DateTimeKind: Local
Query: {"query":"SELECT VALUE root FROM root WHERE (root[\"StartDate\"] <= \"2022-05-26\")"}
It works as expected for local DateTime, but fails for UTC.
Expected behavior
The same value passed into the query is passed into the custom JsonConverter.
Actual behavior
A UTC DateTime is converted to Local DateTime before being passed into the custom JsonConverter.
Environment summary
SDK Version: 3.27.1 (and earlier)
OS Version (e.g. Windows, Linux, MacOSX): All
Additional context
This seems to be a side-effect of ExpressionToSql.VisitConstant converting the value from it's .NET type to a string representation. Because of that, the string value must be parsed before passing to the JsonConverter. It seems that it would be better to pass the value directly to the JsonConverter inside of VisitConstant, but that seems difficult to do since it would require including additional context (e.g., what property it is being used with to determine whether or not a custom converter is specified).
The text was updated successfully, but these errors were encountered:
Since DateTimeStyles.RoundtripKind is meant to preserve kind when it was serialized with "o" or "r" formatters. Presumably this always happens with JsonConvert.SerializeObject(someDate):
Describe the bug
A UTC
DateTime
is converted to a localDateTime
before being passed to customJsonConverters
inside ofExpressionToSql.ApplyCustomConverters
.To Reproduce
Output:
It works as expected for local
DateTime
, but fails for UTC.Expected behavior
The same value passed into the query is passed into the custom
JsonConverter
.Actual behavior
A UTC
DateTime
is converted to LocalDateTime
before being passed into the customJsonConverter
.Environment summary
SDK Version: 3.27.1 (and earlier)
OS Version (e.g. Windows, Linux, MacOSX): All
Additional context
This seems to be a side-effect of
ExpressionToSql.VisitConstant
converting the value from it's .NET type to a string representation. Because of that, the string value must be parsed before passing to theJsonConverter
. It seems that it would be better to pass the value directly to theJsonConverter
inside ofVisitConstant
, but that seems difficult to do since it would require including additional context (e.g., what property it is being used with to determine whether or not a custom converter is specified).The text was updated successfully, but these errors were encountered: