List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:October 6 2010 8:39pm
Subject:bzr commit into connector-net-6.1 branch (reggie.burnett:853)
View as plain text  
#At file:///C:/work/connector-net/6.1/ based on revid:reggie.burnett@stripped

  853 Reggie Burnett	2010-10-06 [merge]
      merged

    modified:
      CHANGES
      MySql.Data/Provider/Source/StoredProcedure.cs
      MySql.Data/Provider/Source/Types/MySqlBit.cs
      MySql.Data/Tests/Source/StoredProcedure.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2010-09-17 16:22:58 +0000
+++ b/CHANGES	2010-10-06 20:39:21 +0000
@@ -1,4 +1,5 @@
 - Added MySqlHelper.ExecuteReader that takes an external connection and array of paramters (bug #56755)
+- fixed problem with using bit parameters as output (bug #56756)
 
 Version 6.1.5
 - Fix authorization popup after modifying stored procedure in VS (Bug #44715)

=== modified file 'MySql.Data/Provider/Source/StoredProcedure.cs'
--- a/MySql.Data/Provider/Source/StoredProcedure.cs	2010-08-18 19:03:33 +0000
+++ b/MySql.Data/Provider/Source/StoredProcedure.cs	2010-10-06 20:39:21 +0000
@@ -283,7 +283,16 @@
                 string fieldName = reader.GetName(i);
                 fieldName = fieldName.Remove(0, ParameterPrefix.Length + 1);
                 MySqlParameter parameter = Parameters.GetParameterFlexible(fieldName, true);
-                results.SetValueObject(i, MySqlField.GetIMySqlValue(parameter.MySqlDbType));
+
+                IMySqlValue v = MySqlField.GetIMySqlValue(parameter.MySqlDbType);
+                if (v is MySqlBit)
+                {
+                    MySqlBit bit = (MySqlBit)v;
+                    bit.ReadAsString = true;
+                    results.SetValueObject(i, bit);
+                }
+                else
+                    results.SetValueObject(i, v);
             }
             if (!reader.Read())
             {

=== modified file 'MySql.Data/Provider/Source/Types/MySqlBit.cs'
--- a/MySql.Data/Provider/Source/Types/MySqlBit.cs	2010-08-18 19:03:33 +0000
+++ b/MySql.Data/Provider/Source/Types/MySqlBit.cs	2010-10-06 20:39:21 +0000
@@ -33,13 +33,21 @@
 	{
 		private ulong mValue;
 		private bool isNull;
+        private bool readAsString;
 
 		public MySqlBit(bool isnull)
 		{
 			mValue = 0;
 			isNull = isnull;
+            readAsString = false;
 		}
 
+        public bool ReadAsString
+        {
+            get { return readAsString; }
+            set { readAsString = value; }
+        }
+
 		public bool IsNull
 		{
 			get { return isNull; }
@@ -94,7 +102,10 @@
 			if (length == -1)
                 length = packet.ReadFieldLength();
 
-            mValue = (UInt64)packet.ReadBitValue((int)length);
+            if (ReadAsString)
+                mValue = UInt64.Parse(packet.ReadString(length));
+            else
+                mValue = (UInt64)packet.ReadBitValue((int)length);
 			return this;
 		}
 

=== modified file 'MySql.Data/Tests/Source/StoredProcedure.cs'
--- a/MySql.Data/Tests/Source/StoredProcedure.cs	2010-08-18 19:03:33 +0000
+++ b/MySql.Data/Tests/Source/StoredProcedure.cs	2010-10-06 20:39:21 +0000
@@ -1316,5 +1316,23 @@
                 cmd.ExecuteScalar();
             }
         }
+
+        /// <summary>
+        /// Bug #56756	Output Parameter MySqlDbType.Bit get a wrong Value (48/49 for false or true)
+        /// </summary>
+        [Test]
+        public void BitTypeAsOutParameter()
+        {
+            execSQL(@"CREATE PROCEDURE `spTest`(out x bit(1))
+                BEGIN
+                Set x = 1; -- Outparameter value is 49
+                Set x = 0; -- Outparameter value is 48
+                END");
+            MySqlCommand cmd = new MySqlCommand("spTest", conn);
+            cmd.CommandType = CommandType.StoredProcedure;
+            cmd.Parameters.Add("x", MySqlDbType.Bit).Direction = ParameterDirection.Output;
+            cmd.ExecuteNonQuery();
+            Assert.AreEqual(0, cmd.Parameters[0].Value);
+        }
     }
 }


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20101006203921-fxs64qcyvyh0oy1h.bundle
Thread
bzr commit into connector-net-6.1 branch (reggie.burnett:853) Reggie Burnett6 Oct