Skip to content

Commit 14aaf53

Browse files
Copilotrenemadsen
andcommitted
Apply recursive JSON store type configuration to all remaining test files
Co-authored-by: renemadsen <[email protected]>
1 parent fcb70cf commit 14aaf53

File tree

3 files changed

+47
-12
lines changed

3 files changed

+47
-12
lines changed

test/EFCore.MySql.FunctionalTests/ComplexCollectionJsonMySqlTest.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright (c) Pomelo Foundation. All rights reserved.
2+
using Microsoft.EntityFrameworkCore.Metadata;
23
// Licensed under the MIT. See LICENSE in the project root for license information.
34

45
using System;
@@ -132,13 +133,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
132133
{
133134
foreach (var complexProperty in entityType.GetComplexProperties())
134135
{
135-
if (complexProperty.GetJsonPropertyName() != null)
136-
{
137-
complexProperty.ComplexType.SetContainerColumnType("json");
138-
}
136+
SetJsonStoreTypeRecursively(complexProperty);
139137
}
140138
}
141139
}
140+
141+
private static void SetJsonStoreTypeRecursively(IMutableComplexProperty complexProperty)
142+
{
143+
if (complexProperty.GetJsonPropertyName() != null)
144+
{
145+
complexProperty.ComplexType.SetContainerColumnType("json");
146+
}
147+
148+
// Also handle nested complex properties
149+
foreach (var nestedComplexProperty in complexProperty.ComplexType.GetComplexProperties())
150+
{
151+
SetJsonStoreTypeRecursively(nestedComplexProperty);
152+
}
153+
}
142154
}
143155

144156
public class ComplexCollectionJsonMySqlFixture : SharedStoreFixtureBase<ComplexCollectionJsonMySqlContext>

test/EFCore.MySql.FunctionalTests/ComplexTypesTrackingMySqlTest.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,23 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
294294
{
295295
foreach (var complexProperty in entityType.GetComplexProperties())
296296
{
297-
if (complexProperty.GetJsonPropertyName() != null)
298-
{
299-
complexProperty.ComplexType.SetContainerColumnType("json");
300-
}
297+
SetJsonStoreTypeRecursively(complexProperty);
301298
}
302299
}
303300
}
301+
302+
private static void SetJsonStoreTypeRecursively(IMutableComplexProperty complexProperty)
303+
{
304+
if (complexProperty.GetJsonPropertyName() != null)
305+
{
306+
complexProperty.ComplexType.SetContainerColumnType("json");
307+
}
308+
309+
// Also handle nested complex properties
310+
foreach (var nestedComplexProperty in complexProperty.ComplexType.GetComplexProperties())
311+
{
312+
SetJsonStoreTypeRecursively(nestedComplexProperty);
313+
}
314+
}
304315
}
305316
}

test/EFCore.MySql.FunctionalTests/PropertyValuesMySqlTest.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
2+
using Microsoft.EntityFrameworkCore.Metadata;
23
using Microsoft.EntityFrameworkCore;
34
using Microsoft.EntityFrameworkCore.TestUtilities;
45

@@ -27,13 +28,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
2728
{
2829
foreach (var complexProperty in entityType.GetComplexProperties())
2930
{
30-
if (complexProperty.GetJsonPropertyName() != null)
31-
{
32-
complexProperty.ComplexType.SetContainerColumnType("json");
33-
}
31+
SetJsonStoreTypeRecursively(complexProperty);
3432
}
3533
}
3634
}
35+
36+
private static void SetJsonStoreTypeRecursively(IMutableComplexProperty complexProperty)
37+
{
38+
if (complexProperty.GetJsonPropertyName() != null)
39+
{
40+
complexProperty.ComplexType.SetContainerColumnType("json");
41+
}
42+
43+
// Also handle nested complex properties
44+
foreach (var nestedComplexProperty in complexProperty.ComplexType.GetComplexProperties())
45+
{
46+
SetJsonStoreTypeRecursively(nestedComplexProperty);
47+
}
48+
}
3749
}
3850
}
3951
}

0 commit comments

Comments
 (0)