Skip to content

Commit 6813cad

Browse files
Copilotrenemadsen
andcommitted
Skip JSON tests on MariaDB using JsonDataTypeEmulation condition
Added [SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))] to all JSON test classes. This condition skips tests when JsonDataTypeEmulation is true, which indicates MariaDB's LONGTEXT-based JSON storage instead of MySQL's native JSON type. MariaDB limitations: - Stores JSON as LONGTEXT (not native JSON) - No support for CAST(... AS json) - Different NULL comparison semantics - Unstable JSON_TABLE implementation All JSON tests will now be skipped on MariaDB versions 10.2.4+ where JsonDataTypeEmulation is enabled, preventing test failures on MariaDB 10.5.2 through 12.0.2. Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
1 parent 9622888 commit 6813cad

9 files changed

+38
-11
lines changed

test/EFCore.MySql.FunctionalTests/BadDataJsonDeserializationMySqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
using Microsoft.EntityFrameworkCore;
22
using Microsoft.EntityFrameworkCore.Infrastructure;
3+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
34
using Pomelo.EntityFrameworkCore.MySql.Tests;
5+
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
46

57
namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests;
68

79
// Re-enabled to test JSON deserialization with bad data
10+
// Skip on MariaDB as it uses JSON emulation (LONGTEXT) which has different behavior
11+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
812
public class BadDataJsonDeserializationMySqlTest : BadDataJsonDeserializationTestBase
913
{
1014
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

test/EFCore.MySql.FunctionalTests/ComplexCollectionJsonMySqlTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.EntityFrameworkCore.Infrastructure;
1010
using Microsoft.EntityFrameworkCore.TestUtilities;
1111
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
12+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
1213
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
1314
using Xunit;
1415

@@ -20,9 +21,10 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests;
2021
///
2122
/// Requirements:
2223
/// - MySQL 5.7.8+ (JSON type support)
23-
/// - MariaDB 10.2.4+ (JSON functions support)
24+
/// - MariaDB 10.2.4+ (JSON functions support) - Currently skipped due to JsonDataTypeEmulation limitations
2425
/// </summary>
2526
[SupportedServerVersionCondition("Json")]
27+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
2628
public class ComplexCollectionJsonMySqlTest : IClassFixture<ComplexCollectionJsonMySqlTest.ComplexCollectionJsonMySqlFixture>
2729
{
2830
private readonly ComplexCollectionJsonMySqlFixture _fixture;

test/EFCore.MySql.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonBulkUpdateMySqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
using Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson;
44
using Microsoft.EntityFrameworkCore.TestUtilities;
55
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
6+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
7+
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
68
using Microsoft.EntityFrameworkCore.Infrastructure;
79
using Xunit;
810
using Xunit.Abstractions;
911

1012
namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.Associations.ComplexJson;
1113

1214
// Re-enabled to test JSON functionality for complex types
15+
// Skip on MariaDB due to JsonDataTypeEmulation limitations
16+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
1317
public class ComplexJsonBulkUpdateMySqlTest : ComplexJsonBulkUpdateRelationalTestBase<ComplexJsonBulkUpdateMySqlTest.ComplexJsonBulkUpdateMySqlFixture>
1418
{
1519
public ComplexJsonBulkUpdateMySqlTest(ComplexJsonBulkUpdateMySqlFixture fixture, ITestOutputHelper testOutputHelper)

test/EFCore.MySql.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonCollectionMySqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
using Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson;
44
using Microsoft.EntityFrameworkCore.TestUtilities;
55
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
6+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
7+
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
68
using Microsoft.EntityFrameworkCore.Infrastructure;
79
using Xunit;
810
using Xunit.Abstractions;
911

1012
namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.Associations.ComplexJson;
1113

1214
// Re-enabled to test JSON functionality for complex types
15+
// Skip on MariaDB due to JsonDataTypeEmulation limitations
16+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
1317
public class ComplexJsonCollectionMySqlTest : ComplexJsonCollectionRelationalTestBase<ComplexJsonCollectionMySqlTest.ComplexJsonCollectionMySqlFixture>
1418
{
1519
public ComplexJsonCollectionMySqlTest(ComplexJsonCollectionMySqlFixture fixture, ITestOutputHelper testOutputHelper)

test/EFCore.MySql.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonMiscellaneousMySqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
using Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson;
33
using Microsoft.EntityFrameworkCore.TestUtilities;
44
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
5+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
6+
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
57
using Microsoft.EntityFrameworkCore.Infrastructure;
68
using Xunit;
79
using Xunit.Abstractions;
810

911
namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.Associations.ComplexJson;
1012

1113
// Re-enabled to test JSON functionality for complex types
14+
// Skip on MariaDB due to JsonDataTypeEmulation limitations
15+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
1216
public class ComplexJsonMiscellaneousMySqlTest : ComplexJsonMiscellaneousRelationalTestBase<ComplexJsonMiscellaneousMySqlTest.ComplexJsonMiscellaneousMySqlFixture>
1317
{
1418
public ComplexJsonMiscellaneousMySqlTest(ComplexJsonMiscellaneousMySqlFixture fixture, ITestOutputHelper testOutputHelper)

test/EFCore.MySql.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonPrimitiveCollectionMySqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
using Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson;
44
using Microsoft.EntityFrameworkCore.TestUtilities;
55
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
6+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
7+
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
68
using Microsoft.EntityFrameworkCore.Infrastructure;
79
using Xunit;
810
using Xunit.Abstractions;
911

1012
namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.Associations.ComplexJson;
1113

1214
// Re-enabled to test JSON functionality for complex types
15+
// Skip on MariaDB due to JsonDataTypeEmulation limitations
16+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
1317
public class ComplexJsonPrimitiveCollectionMySqlTest : ComplexJsonPrimitiveCollectionRelationalTestBase<ComplexJsonPrimitiveCollectionMySqlTest.ComplexJsonPrimitiveCollectionMySqlFixture>
1418
{
1519
public ComplexJsonPrimitiveCollectionMySqlTest(ComplexJsonPrimitiveCollectionMySqlFixture fixture, ITestOutputHelper testOutputHelper)

test/EFCore.MySql.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonProjectionMySqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
using Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson;
44
using Microsoft.EntityFrameworkCore.TestUtilities;
55
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
6+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
7+
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
68
using Microsoft.EntityFrameworkCore.Infrastructure;
79
using Xunit;
810
using Xunit.Abstractions;
911

1012
namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.Associations.ComplexJson;
1113

1214
// Re-enabled to test JSON functionality for complex types
15+
// Skip on MariaDB due to JsonDataTypeEmulation limitations
16+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
1317
public class ComplexJsonProjectionMySqlTest : ComplexJsonProjectionRelationalTestBase<ComplexJsonProjectionMySqlTest.ComplexJsonProjectionMySqlFixture>
1418
{
1519
public ComplexJsonProjectionMySqlTest(ComplexJsonProjectionMySqlFixture fixture, ITestOutputHelper testOutputHelper)

test/EFCore.MySql.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonSetOperationsMySqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
using Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson;
44
using Microsoft.EntityFrameworkCore.TestUtilities;
55
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
6+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
7+
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
68
using Microsoft.EntityFrameworkCore.Infrastructure;
79
using Xunit;
810
using Xunit.Abstractions;
911

1012
namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.Associations.ComplexJson;
1113

1214
// Re-enabled to test JSON functionality for complex types
15+
// Skip on MariaDB due to JsonDataTypeEmulation limitations
16+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
1317
public class ComplexJsonSetOperationsMySqlTest : ComplexJsonSetOperationsRelationalTestBase<ComplexJsonSetOperationsMySqlTest.ComplexJsonSetOperationsMySqlFixture>
1418
{
1519
public ComplexJsonSetOperationsMySqlTest(ComplexJsonSetOperationsMySqlFixture fixture, ITestOutputHelper testOutputHelper)

test/EFCore.MySql.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonStructuralEqualityMySqlTest.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson;
44
using Microsoft.EntityFrameworkCore.TestUtilities;
55
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
6+
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
7+
using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes;
68
using Microsoft.EntityFrameworkCore.Infrastructure;
79
using Xunit;
810
using Xunit.Abstractions;
@@ -11,21 +13,16 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.Associations.Co
1113

1214
// Re-enabled to test JSON functionality for complex types
1315
//
14-
// TODO: All tests in this class should be skipped for MariaDB.
15-
//
16-
// MariaDB stores JSON as LONGTEXT and doesn't support CAST(... AS json). When comparing JSON to NULL,
17-
// we need to distinguish between database NULL vs JSON null value ("null"), which requires CAST AS json
18-
// on MySQL but isn't supported on MariaDB. This causes incorrect result counts (returns 7 instead of 1)
19-
// because the NULL comparison semantics differ without the CAST.
16+
// Skip on MariaDB: MariaDB stores JSON as LONGTEXT and doesn't support CAST(... AS json).
17+
// When comparing JSON to NULL, we need to distinguish between database NULL vs JSON null value ("null"),
18+
// which requires CAST AS json on MySQL but isn't supported on MariaDB. This causes incorrect result counts
19+
// (returns 7 instead of 1) because the NULL comparison semantics differ without the CAST.
2020
//
2121
// Until proper JSON-null-vs-database-NULL handling is implemented for MariaDB's LONGTEXT-based JSON storage,
2222
// all structural equality tests in this class will fail on MariaDB with JsonDataTypeEmulation enabled.
2323
//
24-
// To skip these tests for MariaDB in CI/test runs, configure the test runner to skip tests with the
25-
// "SkipForMariaDb" trait, or run tests against MySQL only.
26-
//
2724
// See: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/151
28-
[Trait("Category", "SkipForMariaDb")]
25+
[SupportedServerVersionLessThanCondition(nameof(ServerVersionSupport.JsonDataTypeEmulation))]
2926
public class ComplexJsonStructuralEqualityMySqlTest : ComplexJsonStructuralEqualityRelationalTestBase<ComplexJsonStructuralEqualityMySqlTest.ComplexJsonStructuralEqualityMySqlFixture>
3027
{
3128
public ComplexJsonStructuralEqualityMySqlTest(ComplexJsonStructuralEqualityMySqlFixture fixture, ITestOutputHelper testOutputHelper)

0 commit comments

Comments
 (0)