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
When filtering is applied on DateTimeOffset column and target value is passed as a string, filtering works fine.
But when filter is deserialized from Json object (JSON used for WebApi request) NewtonSoft automatically Deserializes dates into DateTime. When DateTime filter is applied on DateTimeOffset, it produces a SQL where condition "@p2=1" where p2 equals 0. In other words it returns 0 rows no matter what.
var proj = new TestData();
proj.date = DateTime.UtcNow;
proj.timestamp = DateTimeOffset.UtcNow;
proj.categoryTitle = "P1";
session.Save(proj);
{
var loadOptions = new SampleLoadOptions
{
Filter = new[] { "timestamp", ">", "2020-01-01T18:04:57.610Z" },
RequireTotalCount = true
};
var loadResult = DataSourceLoader.Load(session.Query<TestData>(), loadOptions);
Assert.GreaterOrEqual(loadResult.totalCount, 1); // Success
}
{
var source = new[] { new TestData() { timestamp = DateTimeOffset.UtcNow } };
var filter = JsonConvert.DeserializeObject<IList>(@"[ ""timestamp"", "">="", ""2020-03-03T18:04:57.610Z"" ]");
var loadOptions = new SampleLoadOptions
{
Filter = filter,
RequireTotalCount = true
};
var loadResult = DataSourceLoader.Load(source, loadOptions);
Assert.GreaterOrEqual(loadResult.totalCount, 1); // Fail
}
PS: I would prefer to get an exception instead of 0 results.
The text was updated successfully, but these errors were encountered:
Thanks for reporting. We will fix this case of DateTime to DateTimeOffset conversion. As a workaround, you can useDateParseHandling = None, refer to JamesNK/Newtonsoft.Json#862
PS: I would prefer to get an exception instead of 0 results.
I agree with you, that this complicates debugging. However, we prefer to mute errors when, for instance, an end user enters text into a numeric column filter.
Just a suggestion: Maybe the library could output error in the resultObject in a separate error property? It would not affect DataGrid behavior but would be very useful for developers.
When filtering is applied on DateTimeOffset column and target value is passed as a string, filtering works fine.
But when filter is deserialized from Json object (JSON used for WebApi request) NewtonSoft automatically Deserializes dates into DateTime. When DateTime filter is applied on DateTimeOffset, it produces a SQL where condition "@p2=1" where p2 equals 0. In other words it returns 0 rows no matter what.
PS: I would prefer to get an exception instead of 0 results.
The text was updated successfully, but these errors were encountered: