Modified:
branches/1.0/CHANGES
branches/1.0/TestSuite/ParameterTests.cs
branches/1.0/mysqlclient/command.cs
branches/1.0/mysqlclient/parameter_collection.cs
Log:
- fixed problem where changing the connection string of a connection to one that changes
the parameter marker after the connection had been assigned to a command but before
the connection is opened can cause parameters to not be found (bug #13991)
Modified: branches/1.0/CHANGES
===================================================================
--- branches/1.0/CHANGES 2007-11-06 03:35:47 UTC (rev 1075)
+++ branches/1.0/CHANGES 2007-11-06 16:09:09 UTC (rev 1076)
@@ -12,6 +12,9 @@
(Bug #32094)
- fixed problem where old code was preventing creating parameter objects with non-input
direction using
just a constructor (Bug #32093)
+ - fixed problem where changing the connection string of a connection to one that
changes
+ the parameter marker after the connection had been assigned to a command but before
+ the connection is opened can cause parameters to not be found (bug #13991)
Version 1.0.10
Bugs
Modified: branches/1.0/TestSuite/ParameterTests.cs
===================================================================
--- branches/1.0/TestSuite/ParameterTests.cs 2007-11-06 03:35:47 UTC (rev 1075)
+++ branches/1.0/TestSuite/ParameterTests.cs 2007-11-06 16:09:09 UTC (rev 1076)
@@ -528,5 +528,21 @@
ParameterDirection.Output, true, 0, 0, "id", DataRowVersion.Current, 0);
Assert.AreEqual(ParameterDirection.Output, p1.Direction);
}
+
+ /// <summary>
+ /// Bug #13991 oldsyntax configuration and ParameterMarker value bug
+ /// </summary>
+ [Test]
+ public void SetOldSyntaxAfterCommandCreation()
+ {
+ string connStr = this.GetConnectionString(true);
+ MySqlConnection c = new MySqlConnection(connStr);
+ MySqlCommand cmd = new MySqlCommand("INSERT INTO Test (id) VALUES (@id)", c);
+ c.ConnectionString = connStr += ";old syntax=yes";
+ cmd.Parameters.Add("@id", 2);
+ c.Open();
+ cmd.ExecuteNonQuery();
+ c.Close();
+ }
}
}
Modified: branches/1.0/mysqlclient/command.cs
===================================================================
--- branches/1.0/mysqlclient/command.cs 2007-11-06 03:35:47 UTC (rev 1075)
+++ branches/1.0/mysqlclient/command.cs 2007-11-06 16:09:09 UTC (rev 1076)
@@ -53,7 +53,7 @@
{
cmdType = CommandType.Text;
parameterMap = new ArrayList();
- parameters = new MySqlParameterCollection();
+ parameters = new MySqlParameterCollection(this);
updatedRowSource = UpdateRowSource.Both;
}
@@ -69,8 +69,6 @@
: this(cmdText)
{
Connection = connection;
- if (connection != null)
- parameters.ParameterMarker = connection.ParameterMarker;
}
/// <include file='docs/mysqlcommand.xml' path='docs/ctor4/*'/>
@@ -148,8 +146,6 @@
this.Transaction = null;
connection = (MySqlConnection)value;
- if (connection != null)
- parameters.ParameterMarker = connection.ParameterMarker;
}
}
@@ -621,7 +617,7 @@
writer.Version = connection.driver.Version;
continue;
}
- else if (token[0] == parameters.ParameterMarker)
+ else if (token[0] == connection.ParameterMarker)
{
if (SerializeParameter(writer, token)) continue;
}
@@ -658,12 +654,12 @@
foreach (string token in tokens)
{
- if (token[0] != parameters.ParameterMarker)
+ if (token[0] != connection.ParameterMarker)
newSQL.Append(token);
else
{
parameterMap.Add(token);
- newSQL.Append(parameters.ParameterMarker);
+ newSQL.Append(connection.ParameterMarker);
}
}
@@ -704,12 +700,12 @@
delim = c;
else if (c == '\\')
escaped = !escaped;
- else if (c == parameters.ParameterMarker && delim == Char.MinValue &&
!escaped)
+ else if (c == connection.ParameterMarker && delim == Char.MinValue &&
!escaped)
{
tokens.Add(sqlPart.ToString());
sqlPart.Remove(0, sqlPart.Length);
}
- else if (sqlPart.Length > 0 && sqlPart[0] == parameters.ParameterMarker
&&
+ else if (sqlPart.Length > 0 && sqlPart[0] == connection.ParameterMarker
&&
!Char.IsLetterOrDigit(c) && c != '_' && c != '.' && c != '$'
&& c != '@')
{
Modified: branches/1.0/mysqlclient/parameter_collection.cs
===================================================================
--- branches/1.0/mysqlclient/parameter_collection.cs 2007-11-06 03:35:47 UTC (rev 1075)
+++ branches/1.0/mysqlclient/parameter_collection.cs 2007-11-06 16:09:09 UTC (rev 1076)
@@ -45,8 +45,9 @@
private Hashtable ciHash;
private Hashtable hash;
private int returnParameterIndex;
+ private MySqlCommand owningCommand;
- internal MySqlParameterCollection()
+ internal MySqlParameterCollection(MySqlCommand cmd)
{
hash = new Hashtable();
#if NET20
@@ -56,12 +57,12 @@
new CaseInsensitiveComparer());
#endif
Clear();
+ owningCommand = cmd;
}
internal char ParameterMarker
{
- get { return paramMarker; }
- set { paramMarker = value; }
+ get { return owningCommand.Connection.ParameterMarker; }
}
private int InternalIndexOf(string name)
| Thread |
|---|
| • Connector/NET commit: r1076 - in branches/1.0: . TestSuite mysqlclient | rburnett | 6 Nov |