Skip to content

Commit cb64ee1

Browse files
author
msftbot[bot]
authored
Merge pull request #31667 from dotnet-maestro-bot/merge/release/8.0-to-main
[automated] Merge branch 'release/8.0' => 'main'
2 parents eeabdf4 + 6bc2298 commit cb64ee1

File tree

8 files changed

+266
-8
lines changed

8 files changed

+266
-8
lines changed

test/EFCore.Relational.Specification.Tests/Query/JsonQueryFixtureBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ public static void AssertAllTypes(JsonOwnedAllTypes expected, JsonOwnedAllTypes
393393
Assert.Equal(expected.TestSignedByte, actual.TestSignedByte);
394394
Assert.Equal(expected.TestSingle, actual.TestSingle);
395395
Assert.Equal(expected.TestTimeSpan, actual.TestTimeSpan);
396+
Assert.Equal(expected.TestDateOnly, actual.TestDateOnly);
397+
Assert.Equal(expected.TestTimeOnly, actual.TestTimeOnly);
396398
Assert.Equal(expected.TestUnsignedInt16, actual.TestUnsignedInt16);
397399
Assert.Equal(expected.TestUnsignedInt32, actual.TestUnsignedInt32);
398400
Assert.Equal(expected.TestUnsignedInt64, actual.TestUnsignedInt64);
@@ -417,6 +419,8 @@ public static void AssertAllTypes(JsonOwnedAllTypes expected, JsonOwnedAllTypes
417419
AssertPrimitiveCollection(expected.TestSignedByteCollection, actual.TestSignedByteCollection);
418420
AssertPrimitiveCollection(expected.TestSingleCollection, actual.TestSingleCollection);
419421
AssertPrimitiveCollection(expected.TestTimeSpanCollection, actual.TestTimeSpanCollection);
422+
AssertPrimitiveCollection(expected.TestDateOnlyCollection, actual.TestDateOnlyCollection);
423+
AssertPrimitiveCollection(expected.TestTimeOnlyCollection, actual.TestTimeOnlyCollection);
420424
AssertPrimitiveCollection(expected.TestUnsignedInt16Collection, actual.TestUnsignedInt16Collection);
421425
AssertPrimitiveCollection(expected.TestUnsignedInt32Collection, actual.TestUnsignedInt32Collection);
422426
AssertPrimitiveCollection(expected.TestUnsignedInt64Collection, actual.TestUnsignedInt64Collection);

test/EFCore.Relational.Specification.Tests/Query/JsonQueryTestBase.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,8 @@ public virtual Task Json_all_types_projection_individual_properties(bool async)
21972197
x.Reference.TestSignedByte,
21982198
x.Reference.TestSingle,
21992199
x.Reference.TestTimeSpan,
2200+
x.Reference.TestDateOnly,
2201+
x.Reference.TestTimeOnly,
22002202
x.Reference.TestUnsignedInt16,
22012203
x.Reference.TestUnsignedInt32,
22022204
x.Reference.TestUnsignedInt64,
@@ -2365,6 +2367,22 @@ public virtual Task Json_predicate_on_timespan(bool async)
23652367
ss => ss.Set<JsonEntityAllTypes>().Where(x => x.Reference.TestTimeSpan != new TimeSpan(3, 2, 0)),
23662368
entryCount: 6);
23672369

2370+
[ConditionalTheory]
2371+
[MemberData(nameof(IsAsyncData))]
2372+
public virtual Task Json_predicate_on_dateonly(bool async)
2373+
=> AssertQuery(
2374+
async,
2375+
ss => ss.Set<JsonEntityAllTypes>().Where(x => x.Reference.TestDateOnly != new DateOnly(3, 2, 1)),
2376+
entryCount: 6);
2377+
2378+
[ConditionalTheory]
2379+
[MemberData(nameof(IsAsyncData))]
2380+
public virtual Task Json_predicate_on_timeonly(bool async)
2381+
=> AssertQuery(
2382+
async,
2383+
ss => ss.Set<JsonEntityAllTypes>().Where(x => x.Reference.TestTimeOnly != new TimeOnly(3, 2, 0)),
2384+
entryCount: 6);
2385+
23682386
[ConditionalTheory]
23692387
[MemberData(nameof(IsAsyncData))]
23702388
public virtual Task Json_predicate_on_unisgnedint16(bool async)

test/EFCore.Relational.Specification.Tests/TestModels/JsonQuery/JsonOwnedAllTypes.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class JsonOwnedAllTypes
2727
public DateTime TestDateTime { get; set; }
2828
public DateTimeOffset TestDateTimeOffset { get; set; }
2929
public TimeSpan TestTimeSpan { get; set; }
30+
public DateOnly TestDateOnly { get; set; }
31+
public TimeOnly TestTimeOnly { get; set; }
3032
public float TestSingle { get; set; }
3133
public bool TestBoolean { get; set; }
3234
public byte TestByte { get; set; }
@@ -73,6 +75,8 @@ public IList<double> TestDoubleCollection
7375
public List<DateTime> TestDateTimeCollection { get; set; }
7476
public IList<DateTimeOffset> TestDateTimeOffsetCollection { get; set; }
7577
public TimeSpan[] TestTimeSpanCollection { get; set; } = { new(1, 1, 1) };
78+
public DateOnly[] TestDateOnlyCollection { get; set; }
79+
public TimeOnly[] TestTimeOnlyCollection { get; set; }
7680

7781
public List<float> TestSingleCollection
7882
{

test/EFCore.Relational.Specification.Tests/TestModels/JsonQuery/JsonQueryData.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
699699
TestDateTime = DateTime.Parse("01/01/2000 12:34:56"),
700700
TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)),
701701
TestTimeSpan = new TimeSpan(0, 10, 9, 8, 7),
702+
TestDateOnly = new DateOnly(2023, 10, 10),
703+
TestTimeOnly = new TimeOnly(11, 12, 13),
702704
TestSingle = -1.234F,
703705
TestBoolean = true,
704706
TestByte = 255,
@@ -749,6 +751,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
749751
-1.234F
750752
},
751753
TestTimeSpanCollection = new[] { new TimeSpan(0, 10, 9, 8, 7), new TimeSpan(0, -10, 9, 8, 7) },
754+
TestDateOnlyCollection = new[] { new DateOnly(1234, 1, 23), new DateOnly(4321, 1, 21) },
755+
TestTimeOnlyCollection = new[] { new TimeOnly(11, 42, 23), new TimeOnly(7, 17, 27) },
752756
TestUnsignedInt16Collection = new List<ushort>
753757
{
754758
ushort.MinValue,
@@ -802,6 +806,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
802806
TestDateTime = DateTime.Parse("01/01/3000 12:34:56"),
803807
TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("01/01/3000 12:34:56"), TimeSpan.FromHours(-8.0)),
804808
TestTimeSpan = new TimeSpan(0, 5, 9, 8, 7),
809+
TestDateOnly = new DateOnly(2123, 7, 8),
810+
TestTimeOnly = new TimeOnly(9, 10, 11),
805811
TestSingle = -1.24F,
806812
TestBoolean = true,
807813
TestByte = 25,
@@ -852,6 +858,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
852858
-1.234F
853859
},
854860
TestTimeSpanCollection = new[] { new TimeSpan(0, 10, 9, 8, 7), new TimeSpan(0, -10, 9, 8, 7) },
861+
TestDateOnlyCollection = new[] { new DateOnly(2234, 1, 23), new DateOnly(5321, 1, 21) },
862+
TestTimeOnlyCollection = new[] { new TimeOnly(21, 42, 23), new TimeOnly(17, 17, 27) },
855863
TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue },
856864
TestUnsignedInt32Collection = new[] { uint.MinValue, (uint)0, uint.MaxValue },
857865
TestUnsignedInt64Collection = new ObservableCollection<ulong>
@@ -900,6 +908,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
900908
TestDateTime = DateTime.Parse("11/11/2100 12:34:56"),
901909
TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("11/11/2200 12:34:56"), TimeSpan.FromHours(-5.0)),
902910
TestTimeSpan = new TimeSpan(0, 6, 5, 4, 3),
911+
TestDateOnly = new DateOnly(2323, 4, 3),
912+
TestTimeOnly = new TimeOnly(5, 7, 8),
903913
TestSingle = -1.4F,
904914
TestBoolean = false,
905915
TestByte = 25,
@@ -950,6 +960,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
950960
-1.234F
951961
},
952962
TestTimeSpanCollection = new[] { new TimeSpan(0, 10, 9, 8, 7), new TimeSpan(0, -10, 9, 8, 7) },
963+
TestDateOnlyCollection = new[] { new DateOnly(3234, 1, 23), new DateOnly(4331, 1, 21) },
964+
TestTimeOnlyCollection = new[] { new TimeOnly(13, 42, 23), new TimeOnly(7, 17, 25) },
953965
TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue },
954966
TestUnsignedInt32Collection = new[] { uint.MinValue, (uint)0, uint.MaxValue },
955967
TestUnsignedInt64Collection = new ObservableCollection<ulong>
@@ -998,6 +1010,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
9981010
TestDateTime = DateTime.Parse("11/11/3100 12:34:56"),
9991011
TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("11/11/3200 12:34:56"), TimeSpan.FromHours(-5.0)),
10001012
TestTimeSpan = new TimeSpan(0, 6, 5, 2, 3),
1013+
TestDateOnly = new DateOnly(4019, 2, 25),
1014+
TestTimeOnly = new TimeOnly(5, 30, 42),
10011015
TestSingle = -1.4F,
10021016
TestBoolean = false,
10031017
TestByte = 25,
@@ -1048,6 +1062,8 @@ public static IReadOnlyList<JsonEntityAllTypes> CreateJsonEntitiesAllTypes()
10481062
-1.234F
10491063
},
10501064
TestTimeSpanCollection = new[] { new TimeSpan(0, 10, 9, 8, 7), new TimeSpan(0, -10, 9, 8, 7) },
1065+
TestDateOnlyCollection = new[] { new DateOnly(1638, 1, 23), new DateOnly(4321, 1, 21) },
1066+
TestTimeOnlyCollection = new[] { new TimeOnly(8, 22, 23), new TimeOnly(7, 27, 37) },
10511067
TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue },
10521068
TestUnsignedInt32Collection = new[] { uint.MinValue, (uint)0, uint.MaxValue },
10531069
TestUnsignedInt64Collection = new ObservableCollection<ulong>

test/EFCore.Relational.Specification.Tests/Update/JsonUpdateTestBase.cs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,50 @@ public virtual Task Edit_single_property_timespan()
10711071
Assert.Equal(new TimeSpan(0, 10, 1, 1, 7), result.Collection[0].TestTimeSpan);
10721072
});
10731073

1074+
[ConditionalFact]
1075+
public virtual Task Edit_single_property_dateonly()
1076+
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
1077+
CreateContext,
1078+
UseTransaction,
1079+
async context =>
1080+
{
1081+
var query = await context.JsonEntitiesAllTypes.ToListAsync();
1082+
var entity = query.Single(x => x.Id == 1);
1083+
entity.Reference.TestDateOnly = new DateOnly(1023, 1, 1);
1084+
entity.Collection[0].TestDateOnly = new DateOnly(2000, 2, 4);
1085+
1086+
ClearLog();
1087+
await context.SaveChangesAsync();
1088+
},
1089+
async context =>
1090+
{
1091+
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
1092+
Assert.Equal(new DateOnly(1023, 1, 1), result.Reference.TestDateOnly);
1093+
Assert.Equal(new DateOnly(2000, 2, 4), result.Collection[0].TestDateOnly);
1094+
});
1095+
1096+
[ConditionalFact]
1097+
public virtual Task Edit_single_property_timeonly()
1098+
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
1099+
CreateContext,
1100+
UseTransaction,
1101+
async context =>
1102+
{
1103+
var query = await context.JsonEntitiesAllTypes.ToListAsync();
1104+
var entity = query.Single(x => x.Id == 1);
1105+
entity.Reference.TestTimeOnly = new TimeOnly(1, 1, 7);
1106+
entity.Collection[0].TestTimeOnly = new TimeOnly(1, 1, 7);
1107+
1108+
ClearLog();
1109+
await context.SaveChangesAsync();
1110+
},
1111+
async context =>
1112+
{
1113+
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
1114+
Assert.Equal(new TimeOnly(1, 1, 7), result.Reference.TestTimeOnly);
1115+
Assert.Equal(new TimeOnly(1, 1, 7), result.Collection[0].TestTimeOnly);
1116+
});
1117+
10741118
[ConditionalFact]
10751119
public virtual Task Edit_single_property_uint16()
10761120
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
@@ -2016,6 +2060,60 @@ public virtual Task Edit_single_property_collection_of_timespan()
20162060
Assert.False(result.Collection[0].NewCollectionSet);
20172061
});
20182062

2063+
[ConditionalFact]
2064+
public virtual Task Edit_single_property_collection_of_dateonly()
2065+
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
2066+
CreateContext,
2067+
UseTransaction,
2068+
async context =>
2069+
{
2070+
var query = await context.JsonEntitiesAllTypes.ToListAsync();
2071+
var entity = query.Single(x => x.Id == 1);
2072+
entity.Reference.TestDateOnlyCollection[0] = new DateOnly(1, 1, 7);
2073+
entity.Collection[0].TestDateOnlyCollection[1] = new DateOnly(1, 1, 7);
2074+
2075+
ClearLog();
2076+
await context.SaveChangesAsync();
2077+
},
2078+
async context =>
2079+
{
2080+
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
2081+
Assert.Equal(
2082+
new[] { new DateOnly(1, 1, 7), new DateOnly(4321, 1, 21) }, result.Reference.TestDateOnlyCollection);
2083+
Assert.Equal(
2084+
new[] { new DateOnly(3234, 1, 23), new DateOnly(1, 1, 7) }, result.Collection[0].TestDateOnlyCollection);
2085+
2086+
Assert.False(result.Reference.NewCollectionSet);
2087+
Assert.False(result.Collection[0].NewCollectionSet);
2088+
});
2089+
2090+
[ConditionalFact]
2091+
public virtual Task Edit_single_property_collection_of_timeonly()
2092+
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
2093+
CreateContext,
2094+
UseTransaction,
2095+
async context =>
2096+
{
2097+
var query = await context.JsonEntitiesAllTypes.ToListAsync();
2098+
var entity = query.Single(x => x.Id == 1);
2099+
entity.Reference.TestTimeOnlyCollection[0] = new TimeOnly(1, 1, 7);
2100+
entity.Collection[0].TestTimeOnlyCollection[1] = new TimeOnly(1, 1, 7);
2101+
2102+
ClearLog();
2103+
await context.SaveChangesAsync();
2104+
},
2105+
async context =>
2106+
{
2107+
var result = await context.Set<JsonEntityAllTypes>().SingleAsync(x => x.Id == 1);
2108+
Assert.Equal(
2109+
new[] { new TimeOnly(1, 1, 7), new TimeOnly(7, 17, 27) }, result.Reference.TestTimeOnlyCollection);
2110+
Assert.Equal(
2111+
new[] { new TimeOnly(13, 42, 23), new TimeOnly(1, 1, 7) }, result.Collection[0].TestTimeOnlyCollection);
2112+
2113+
Assert.False(result.Reference.NewCollectionSet);
2114+
Assert.False(result.Collection[0].NewCollectionSet);
2115+
});
2116+
20192117
[ConditionalFact]
20202118
public virtual Task Edit_single_property_collection_of_uint16()
20212119
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(

0 commit comments

Comments
 (0)