File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed
Nest/CommonOptions/DateMath
Tests/CommonOptions/DateMath Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public static DateMath FromString(string dateMath)
8383
8484 internal static bool IsValidDateMathString ( string dateMath ) => dateMath != null && DateMathRegex . IsMatch ( dateMath ) ;
8585
86- internal bool IsValid => Self . Anchor . Match ( d => d != default , s => ! s . IsNullOrEmpty ( ) ) ;
86+ internal bool IsValid => Self . Anchor . Match ( _ => true , s => ! s . IsNullOrEmpty ( ) ) ;
8787
8888 public override string ToString ( )
8989 {
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Text ;
4+ using Elastic . Xunit . XunitPlumbing ;
5+ using FluentAssertions ;
6+ using Nest ;
7+ using Tests . Core . Client ;
8+ using Tests . Core . Extensions ;
9+ using Tests . Core . Serialization ;
10+ using Tests . Domain ;
11+
12+ namespace Tests . Reproduce
13+ {
14+ public class GithubIssue4228
15+ {
16+ [ U ]
17+ public void CanSerializeDateMathDateTimeMinValue ( ) {
18+
19+ var searchResponse = TestClient . DefaultInMemoryClient . Search < object > ( s => s
20+ . AllIndices ( )
21+ . Query ( q => q
22+ . DateRange ( d => d
23+ . GreaterThanOrEquals ( DateTime . MinValue )
24+ . Field ( "date" )
25+ )
26+ )
27+ ) ;
28+
29+ Encoding . UTF8 . GetString ( searchResponse . ApiCall . RequestBodyInBytes )
30+ . Should ( ) . Be ( "{\" query\" :{\" range\" :{\" date\" :{\" gte\" :\" 0001-01-01T00:00:00\" }}}}" ) ;
31+ }
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -23,14 +23,14 @@ public void ImplicitConversionFromNullNullableDateTime()
2323 }
2424
2525 [ U ] // F# backticks would be great in C# :)
26- public void ImplicitConversionFromDefaultDateTimeIsNotNullButEmptyString ( )
26+ public void ImplicitConversionFromDefaultDateTimeIsMinValue ( )
2727 {
2828 // in 6.x DateMath is backed by a DateTime instance
2929 // for 7.x we will adress this
3030 DateTime nullableDateTime = default ;
3131 Nest . DateMath dateMath = nullableDateTime ;
3232 dateMath . Should ( ) . NotBeNull ( ) ;
33- dateMath . ToString ( ) . Should ( ) . BeEmpty ( ) ;
33+ dateMath . ToString ( ) . Should ( ) . Be ( "0001-01-01T00:00:00" ) ;
3434 }
3535
3636 [ U ]
You can’t perform that action at this time.
0 commit comments