Bug #59835 .Net Connector MySqlConnectionStringBuilder wrong result ContainsKey function
Submitted: 31 Jan 2011 10:10 Modified: 14 Feb 2011 21:15
Reporter: Leonard Wennekers Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.3.6 OS:Any
Assigned to: Reggie Burnett CPU Architecture:Any

[31 Jan 2011 10:10] Leonard Wennekers
Description:
The MySQLConnectionStringBuilder is missing a correct implementation of the ContainsKey functionality.

When asking for existing keys the result is always false.

How to repeat:
MySqlConnectionStringBuilder csb = new MySqlConnectionStringBuilder();

if (csb.ContainsKey("server"))
{
  Console.Writeln("OK");
}
else
{
  Console.Writeln("Error");
}

csb["server"] = "localserver";
if (csb.ContainsKey("server"))
{
  Console.Writeln("OK");
}
else
{
  Console.Writeln("Error");
}

The result is 2 lines with "Error"

Suggested fix:
Add the followinf function to the MySqlConnectionStringBuilder

public override bool ContainsKey(string keyword)
{
    ValidateKeyword(keyword);
    string primaryKey = validKeywords[keyword];

    return true;
}
[2 Feb 2011 11:01] Tonci Grgin
Hi Leonard and thanks for your report.

ContainsKey is defined in .NET framework and I do not think we'll override it but let's see what Reggie will say.

Verified as described with remark that offending function is the part of framework, not something defined in c/NET.
[2 Feb 2011 12:42] Leonard Wennekers
Hello Toni,
OK  ContainsKey is defined in the .NET framework. But the result of the ContainsKey function give false results because you don't work with the base keys but with your own validKeywords list. There the ContainsKey always gives false as a result.
[2 Feb 2011 13:23] Tonci Grgin
Leonard, absolutely thus the report is "Verified" now.
[14 Feb 2011 21:15] Reggie Burnett
Fixed in 6.0.8, 6.1.6, 6.2.5, 6.3.7+
[29 Feb 2012 20:53] John Russell
Added to changelog for 6.0.8, 6.1.6, 6.2.5, 6.3.7: 

MySQLConnectionStringBuilder.ContainsKey() incorrectly returned false
when testing whether a keyword was part of the connection string.