File tree 3 files changed +36
-3
lines changed
Nest/CommonOptions/DateMath
Tests/CommonOptions/DateMath
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)
83
83
84
84
internal static bool IsValidDateMathString ( string dateMath ) => dateMath != null && DateMathRegex . IsMatch ( dateMath ) ;
85
85
86
- internal bool IsValid => Self . Anchor . Match ( d => d != default , s => ! s . IsNullOrEmpty ( ) ) ;
86
+ internal bool IsValid => Self . Anchor . Match ( _ => true , s => ! s . IsNullOrEmpty ( ) ) ;
87
87
88
88
public override string ToString ( )
89
89
{
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()
23
23
}
24
24
25
25
[ U ] // F# backticks would be great in C# :)
26
- public void ImplicitConversionFromDefaultDateTimeIsNotNullButEmptyString ( )
26
+ public void ImplicitConversionFromDefaultDateTimeIsMinValue ( )
27
27
{
28
28
// in 6.x DateMath is backed by a DateTime instance
29
29
// for 7.x we will adress this
30
30
DateTime nullableDateTime = default ;
31
31
Nest . DateMath dateMath = nullableDateTime ;
32
32
dateMath . Should ( ) . NotBeNull ( ) ;
33
- dateMath . ToString ( ) . Should ( ) . BeEmpty ( ) ;
33
+ dateMath . ToString ( ) . Should ( ) . Be ( "0001-01-01T00:00:00" ) ;
34
34
}
35
35
36
36
[ U ]
You can’t perform that action at this time.
0 commit comments