Bug #74533 MySqlParameter.Clone missed assign value to property SourceColumnNullMapping
Submitted: 24 Oct 2014 2:32 Modified: 19 Nov 2014 5:58
Reporter: yao yao Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.3, 6.9.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: MySqlParameter, SourceColumnNullMapping

[24 Oct 2014 2:32] yao yao
Description:
In function MySqlParameter.Clone didn't set SourceColumnNullMapping to correct value. 
If current parameter's SourceColumnNullMapping property is true; the cloned object will have SourceColumnNullMapping = false.
This will cause later use of cloned parameter can't be treated as right.

System.Data.Common.DbDataAdapter.ParameterInput
DbParameter dbParameter = dataParameter as DbParameter;
if (dbParameter != null && dbParameter.SourceColumnNullMapping)
{
dataParameter.Value = (ADP.IsNull(dataParameter.Value) ? DbDataAdapter.ParameterValueNullValue : DbDataAdapter.ParameterValueNonNullValue);
}

How to repeat:
MySqlCommand cmd = new MySqlCommand("CREATE TABLE `nullable` (`id` INT AUTO_INCREMENT,`name` VARCHAR(10) NULL, PRIMARY KEY(`id`))", connection);
cmd.ExecuteNonQuery();

cmd.CommandText = "INSERT INTO `nullable` VALUES (1, null)";
cmd.ExecuteNonQuery();
                
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM `nullable`", connection);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
da.DeleteCommand = cb.GetDeleteCommand().Clone();
cb.DataAdapter = null;
DataTable dt = new DataTable();
da.Fill(dt);
dt.Rows[0].Delete();
da.Update(dt);

exception caught:
System.Data.DBConcurrencyException: Concurrency violation: the DeleteCommand affected 0 of the expected 1 records.