Skip to content

Commit a94ac6c

Browse files
Copilotrenemadsen
andcommitted
Simplify UInt64 Max value detection using direct enum comparison
Changed from numeric value comparison `(ulong)value == 18446744073709551615` to direct enum comparison `value == EnumU64.Max`. This is more reliable and clearer since both the symbolic EnumU64.Max and the numeric literal (EnumU64)18446744073709551615 are equivalent and will match this condition. The fix ensures both test cases with UInt64.MaxValue (symbolic and numeric forms) are properly adjusted for MariaDB's different serialization format at runtime. Applied to both nullable and non-nullable test methods. Co-authored-by: renemadsen <[email protected]>
1 parent 4467b5a commit a94ac6c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public override Task Can_read_write_collection_of_ulong_enum_JSON_values()
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-
// Check for both EnumU64.Max and the numeric literal (both represent UInt64.MaxValue)
70-
if (AppConfig.ServerVersion.Type == ServerType.MariaDb && (ulong)value == 18446744073709551615)
69+
// Check if the value is UInt64.MaxValue (works for both enum and numeric literal)
70+
if (AppConfig.ServerVersion.Type == ServerType.MariaDb && value == EnumU64.Max)
7171
{
7272
json = """{"Prop":18446744073709551615}""";
7373
}
@@ -88,9 +88,9 @@ public override Task Can_read_write_collection_of_ulong_enum_JSON_values()
8888
public async Task Can_read_write_nullable_ulong_enum_JSON_values(EnumU64? value, string json)
8989
{
9090
// MariaDB serializes UInt64.MaxValue as "18446744073709551615" instead of "-1"
91-
// Adjust the expected JSON value for MariaDB to match its actual behavior
92-
// Check for both EnumU64.Max and the numeric literal (both represent UInt64.MaxValue)
93-
if (AppConfig.ServerVersion.Type == ServerType.MariaDb && value.HasValue && (ulong)value.Value == 18446744073709551615)
91+
// Adjust the expected JSON value for MariaDB to match its actual behavior
92+
// Check if the value is UInt64.MaxValue (works for both enum and numeric literal)
93+
if (AppConfig.ServerVersion.Type == ServerType.MariaDb && value.HasValue && value.Value == EnumU64.Max)
9494
{
9595
json = """{"Prop":18446744073709551615}""";
9696
}

0 commit comments

Comments
 (0)