Bug #92734 MySqlParameter.Clone doesn't clone all properties
Submitted: 10 Oct 2018 15:45 Modified: 25 Oct 2022 16:30
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.12 OS:Windows (10)
Assigned to: CPU Architecture:Other (x64)

[10 Oct 2018 15:45] Bradley Grainger
Description:
The MySqlParameter.Clone() method doesn't copy the values of the Size, Scale, Precision, IsNullable, and SourceColumnNullMapping properties to the cloned object.

How to repeat:
Execute the following C# code:

var parameter = new MySqlParameter
{
	Size = 1,
	Scale = 2,
	Precision = 3,
	IsNullable = true,
	SourceColumnNullMapping = true,
};

var clone = parameter.Clone();

Console.WriteLine(clone.Size); // prints 0, expected 1
Console.WriteLine(clone.Scale); // prints 0, expected 2
Console.WriteLine(clone.Precision); // prints 0, expected 3
Console.WriteLine(clone.IsNullable); // prints False, expected True
Console.WriteLine(clone.SourceColumnNullMapping); // prints False, expected True

Suggested fix:
Copy the values of these properties in Clone().
[11 Oct 2018 4:00] MySQL Verification Team
Hello Bradley,

Thank you for the report and test case.
Observed this using VS 2017 and C/Net 8.0.12.

regards,
Umesh
[23 Sep 2022 18:14] Omar Chavez
Posted by developer:
 
Verified using Connector/Net version 8.0.30
[24 Oct 2022 14:21] Omar Chavez
Posted by developer:
 
This patch fixed a bug that prevented the MySqlParameter.Clone method to copy all the MySqlParameter properties.
[25 Oct 2022 16:30] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 8.0.32 release, and here's the proposed changelog entry from the documentation team:

Values of the Size, Scale, Precision, IsNullable, and
SourceColumnNullMapping properties were omitted during the copy operation
performed by the MySqlParameter.Clone() method.

Thank you for the bug report.