-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySqlConnectionStringBuilder.ConnectionString depends on order in which properties are set #1217
Comments
|
Related: dotnet/runtime#834 |
But may not be what people expect. It's very common (for MySQL connection strings) to see |
dotnet/runtime#834 (comment) raises a point that's relevant to MySqlConnector; because using (var connection = new MySqlConnection("server=localhost;userid=root;password=pass"))
connection.Open();
using (var connection = new MySqlConnection("server=localhost;password=pass;userid=root"))
connection.Open();
using (var connection = new MySqlConnection("userid=root;password=pass;server=localhost"))
connection.Open();
using (var connection = new MySqlConnection("password=pass;userid=root;server=localhost"))
connection.Open(); MySqlConnector should detect that these are all equivalent connection strings and map them to the same pool. While fixing the order of options in |
Signed-off-by: Bradley Grainger <bgrainger@gmail.com>
Signed-off-by: Bradley Grainger <bgrainger@gmail.com>
Signed-off-by: Bradley Grainger <bgrainger@gmail.com>
Fixed in 2.2.0. |
produces:
It's unexpected that the serialized connection string would depend on the order in which C# properties are set.
This may be an artifact of some logic in the base
DbConnectionStringBuilder
class, possibly in an attempt to preserve connection strings set via the string constructor? (Although normalization of property names and punctuation does occur; see example below.) Or it could be an unintentional side-effect of using aDictionary
to store the options, which tends to returnKeys
in the order in which they were inserted, although this is certainly not guaranteed by the implementation.produces:
Since option key names and punctuation are already normalized by the implementation, it makes the most sense to also output the options themselves in a consistent order;
OrdinalIgnoreCase
would be simplest.The text was updated successfully, but these errors were encountered: