Skip to content

Commit b5a8561

Browse files
Copilotrenemadsen
andcommitted
Fix numeric UInt64.MaxValue test case to use runtime adjustment
Changed the InlineData for numeric literal (EnumU64)18446744073709551615 to initially expect {"Prop":-1} (matching MySQL's behavior) and enhanced the runtime adjustment logic to check the actual numeric value instead of just enum equality. The fix: 1. Changed InlineData JSON expectation from {"Prop":18446744073709551615} to {"Prop":-1} 2. Updated condition from `value == EnumU64.Max` to `(ulong)value == 18446744073709551615` 3. This catches both EnumU64.Max and (EnumU64)18446744073709551615 representations Now both test cases for UInt64.MaxValue (symbolic and numeric) properly adjust expectations for MariaDB at runtime, allowing all 7 test cases to pass on both MySQL and MariaDB. Co-authored-by: renemadsen <[email protected]>
1 parent 3be5714 commit b5a8561

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/EFCore.MySql.FunctionalTests/Query/JsonTypesRelationalMySqlTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ public override Task Can_read_write_collection_of_ulong_enum_JSON_values()
6161
[InlineData(EnumU64.Default, """{"Prop":0}""")]
6262
[InlineData(EnumU64.One, """{"Prop":1}""")]
6363
[InlineData((EnumU64)8, """{"Prop":8}""")]
64-
[InlineData((EnumU64)18446744073709551615, """{"Prop":18446744073709551615}""")] // Additional test case for UInt64.MaxValue as numeric
64+
[InlineData((EnumU64)18446744073709551615, """{"Prop":-1}""")] // UInt64.MaxValue as numeric literal - will be adjusted for MariaDB at runtime
6565
public new async Task Can_read_write_ulong_enum_JSON_values(EnumU64 value, string json)
6666
{
6767
// MariaDB serializes UInt64.MaxValue as "18446744073709551615" instead of "-1"
6868
// Adjust the expected JSON value for MariaDB to match its actual behavior
69-
if (AppConfig.ServerVersion.Type == ServerType.MariaDb && value == EnumU64.Max)
69+
// Check for both EnumU64.Max and the numeric literal (both represent UInt64.MaxValue)
70+
if (AppConfig.ServerVersion.Type == ServerType.MariaDb && (ulong)value == 18446744073709551615)
7071
{
7172
json = """{"Prop":18446744073709551615}""";
7273
}

0 commit comments

Comments
 (0)