Bug #109682 MySqlParameter.Clone loses specific MySqlDbType
Submitted: 18 Jan 2023 13:59 Modified: 7 Jun 2023 14:06
Reporter: Bradley Grainger (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.32 OS:Any
Assigned to: CPU Architecture:Any

[18 Jan 2023 13:59] Bradley Grainger
Description:
Executing MySqlParameter.Clone can return a MySqlParameter object with a different MySqlDbType than the original. The expectation is that the exact MySqlDbType will be preserved. This is a regression since 8.0.31.

How to repeat:
var param = new MySqlParameter("@param", MySqlDbType.MediumText);
var clone = param.Clone();
Console.WriteLine(param.MySqlDbType); // Prints "MediumText"
Console.WriteLine(clone.MySqlDbType); // Prints "VarChar"

Suggested fix:
Don't set DbType here: https://github.com/mysql/mysql-connector-net/blob/8.0/MySQL.Data/src/Framework/netstandard... because this will override MySqlDbType here: https://github.com/mysql/mysql-connector-net/blob/8.0/MySQL.Data/src/parameter.cs#L509

Or change MySqlDbType after setting DbType.
[19 Jan 2023 3:08] MySQL Verification Team
Hello Bradley,

Thank you for the report and feedback.

regards,
Umesh
[7 Jun 2023 14:06] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 8.1.0 release, and here's the proposed changelog entry from the documentation team:

MySqlParameter.Clone could return a MySqlParameter object with a
MySqlDbType value that differed from the original, rather than preserving
the original type.

Thank you for the bug report.