Description:
The default value of MySqlParameter.Value (for integral types) changed from null to 0 in 8.0.22. This is a breaking change, because it changes the meaning of existing code.
In the attached example, the code inserts the value NULL into the table with 8.0.21, but 0 when using 8.0.22. Updating the MySql.Data library should not cause a change in the behaviour of previously-working application code.
This regression was probably introduced by the fix for bug #85027.
How to repeat:
using (var connection = new MySqlConnection("..."))
{
connection.Open();
using (var command = new MySqlCommand(@"drop table if exists int_test;
create table int_test(data int null);", connection))
{
command.ExecuteNonQuery();
}
using (var command = new MySqlCommand("insert into int_test(data) values(@Data)", connection))
{
command.Parameters.Add(new MySqlParameter("@Data", MySqlDbType.Int32));
// this inserts NULL with 8.0.21, 0 with 8.0.22
command.ExecuteNonQuery();
}
using (var command = new MySqlCommand("select data from int_test;", connection))
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine(reader.IsDBNull(0)); // 8.0.21 prints True, 8.0.22 prints False
}
}
}
Suggested fix:
Revert the fix for bug #85027.