Skip to content

FromAsString & ToAsString properties were not serializing #994

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,11 @@ public IAggregation GetRangeAggregation(JsonReader reader, JsonSerializer serial
reader.Read();
break;
case "from_as_string":
reader.Read();
fromAsString = reader.Value as string;
fromAsString = reader.ReadAsString();
reader.Read();
break;
case "to_as_string":
reader.Read();
toAsString = reader.Value as string;
toAsString = reader.ReadAsString();
reader.Read();
break;
case "doc_count":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using Elasticsearch.Net;
using FluentAssertions;
using Nest.Tests.MockData.Domain;
Expand Down Expand Up @@ -180,6 +181,20 @@ public void DateRangeItem()
firstAgg.Items.Should().NotBeEmpty();
var grams = firstAgg.Items.OfType<RangeItem>();
grams.Should().NotBeEmpty();
var firstRange = grams.FirstOrDefault();
firstRange.Should().NotBeNull();
firstRange.To.Should().HaveValue();
firstRange.ToAsString.Should().NotBeNull();
var firstRangeToDateLeft = firstRange.To.Value.JavaTimeStampToDateTime();
var firstRangeToDateRight = DateTime.Parse(firstRange.ToAsString);
firstRangeToDateLeft.Should().Be(firstRangeToDateRight);
var lastRange = grams.LastOrDefault();
lastRange.Should().NotBeNull();
lastRange.From.Should().HaveValue();
lastRange.FromAsString.Should().NotBeNull();
var LastRangeFromDateLeft = lastRange.From.Value.JavaTimeStampToDateTime();
var LastRangeFromDateRight = DateTime.Parse(lastRange.FromAsString);
LastRangeFromDateLeft.Should().Be(LastRangeFromDateRight);
}
[Test]
public void IpRangeItem()
Expand Down