List:Commits« Previous MessageNext Message »
From:rburnett Date:January 8 2007 8:50pm
Subject:Connector/NET commit: r543 - in branches/5.0: . Driver/Source TestSuite
View as plain text  
Modified:
   branches/5.0/CHANGES
   branches/5.0/Driver/Source/parameter.cs
   branches/5.0/Driver/Source/parameter_collection.cs
   branches/5.0/TestSuite/ParameterTests.cs
Log:
Fixed problem with parameter name hashing where the hashes were not getting updated
       or removed in certain situations.

Modified: branches/5.0/CHANGES
===================================================================
--- branches/5.0/CHANGES	2007-01-08 18:01:21 UTC (rev 542)
+++ branches/5.0/CHANGES	2007-01-08 20:50:25 UTC (rev 543)
@@ -7,6 +7,8 @@
   Other changes
   -------------
   Return parameters created with DeriveParameters now have the name RETURN_VALUE
+  Fixed problem with parameter name hashing where the hashes were not getting updated
+       or removed in certain situations.
 
 Version 5.0.3 12-31-2006
 

Modified: branches/5.0/Driver/Source/parameter.cs
===================================================================
--- branches/5.0/Driver/Source/parameter.cs	2007-01-08 18:01:21 UTC (rev 542)
+++ branches/5.0/Driver/Source/parameter.cs	2007-01-08 20:50:25 UTC (rev 543)
@@ -54,6 +54,7 @@
 		private DbType dbType;
 		private bool inferType;
 		private bool sourceColumnNullMapping;
+        private MySqlParameterCollection collection;
 
 		#region Constructors
 
@@ -159,6 +160,12 @@
 
 		#region Properties
 
+        internal MySqlParameterCollection Collection
+        {
+            get { return collection; }
+            set { collection = value; }
+        }
+
 		internal bool TypeHasBeenSet
 		{
 			get { return inferType == false; }
@@ -227,7 +234,12 @@
 		public override String ParameterName
 		{
 			get { return paramName; }
-			set { paramName = value; }
+			set 
+            { 
+                if (collection != null)
+                    collection.ParameterNameChanged(this, paramName, value);
+                paramName = value;
+            }
 		}
 
 		/// <summary>

Modified: branches/5.0/Driver/Source/parameter_collection.cs
===================================================================
--- branches/5.0/Driver/Source/parameter_collection.cs	2007-01-08 18:01:21 UTC (rev 542)
+++ branches/5.0/Driver/Source/parameter_collection.cs	2007-01-08 20:50:25 UTC (rev 543)
@@ -116,6 +116,7 @@
 			int index = items.Add(value);
 			hash.Add(value.ParameterName, index);
 			ciHash.Add(value.ParameterName, index);
+            value.Collection = this;
 			return value;
 		}
 
@@ -285,6 +286,8 @@
 		/// </summary>
 		public override void Clear()
 		{
+            foreach (MySqlParameter p in items)
+                p.Collection = null;
 			items.Clear();
 			hash.Clear();
 			ciHash.Clear();
@@ -422,6 +425,7 @@
             MySqlParameter p = (value as MySqlParameter);
             hash.Remove(p.ParameterName);
             ciHash.Remove(p.ParameterName);
+            p.Collection = null;
             if (p.Direction == ParameterDirection.ReturnValue)
                 returnParameterIndex = -1;
 		}
@@ -458,5 +462,15 @@
 
 		#endregion
 
+        internal void ParameterNameChanged(MySqlParameter p, string oldName, string newName)
+        {
+            if (p.Direction == ParameterDirection.ReturnValue)
+                return;
+            int index = IndexOf(oldName);
+            hash.Remove(oldName);
+            ciHash.Remove(oldName);
+            hash.Add(newName, index);
+            ciHash.Add(newName, index);
+        }
 	}
 }

Modified: branches/5.0/TestSuite/ParameterTests.cs
===================================================================
--- branches/5.0/TestSuite/ParameterTests.cs	2007-01-08 18:01:21 UTC (rev 542)
+++ branches/5.0/TestSuite/ParameterTests.cs	2007-01-08 20:50:25 UTC (rev 543)
@@ -393,5 +393,28 @@
                 Assert.IsFalse(reader.Read());
             }
         }
+
+        [Test]
+        public void ParameterCacheNotClearing()
+        {
+            try
+            {
+                MySqlCommand cmd = new MySqlCommand("INSERT INTO test (id, name) VALUES (?id, ?name)", conn);
+                cmd.Parameters.Add("?id", 1);
+                cmd.Parameters.Add("?name", "test");
+                cmd.ExecuteNonQuery();
+
+                cmd.CommandText = "INSERT INTO test (id, name, dt) VALUES (?id1, ?name1, ?id)";
+                cmd.Parameters[0].ParameterName = "?id1";
+                cmd.Parameters[0].Value = 2;
+                cmd.Parameters[1].ParameterName = "?name1";
+                cmd.Parameters.Add("?id", DateTime.Now);
+                cmd.ExecuteNonQuery();
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail(ex.Message);
+            }
+        }
     }
 }

Thread
Connector/NET commit: r543 - in branches/5.0: . Driver/Source TestSuiterburnett8 Jan