List:Commits« Previous MessageNext Message »
From:rburnett Date:November 7 2008 8:35pm
Subject:Connector/NET commit: r1446 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Source
View as plain text  
Modified:
   branches/5.2/CHANGES
   branches/5.2/MySql.Data/Provider/Source/datareader.cs
   branches/5.2/MySql.Data/Tests/Source/DataTypeTests.cs
Log:
- added GetSByte to the reader for returning tinyint columns (bug #40571)


Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES	2008-11-07 19:17:22 UTC (rev 1445)
+++ branches/5.2/CHANGES	2008-11-07 19:35:19 UTC (rev 1446)
@@ -33,8 +33,8 @@
 - fixed problem where CharSetMap.GetDefaultCollation and CharSetMap.GetMaxLengths
   might have a thread sync issue on high load systems.  They were not locking
   the static collections there were initializing. (bug #40231)  
+- added GetSByte to the reader for returning tinyint columns (bug #40571)
   
-  
 Version 5.2.3 - 8/14/08
 - Increased the speed of MySqlDataReader.GetOrdinal dramatically by using a couple
   of hashes for lookups

Modified: branches/5.2/MySql.Data/Provider/Source/datareader.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/datareader.cs	2008-11-07 19:17:22 UTC (rev
1445)
+++ branches/5.2/MySql.Data/Provider/Source/datareader.cs	2008-11-07 19:35:19 UTC (rev
1446)
@@ -243,6 +243,30 @@
 				return (byte)((MySqlByte)v).Value;
 		}
 
+        /// <summary>
+        /// Gets the value of the specified column as a sbyte.
+        /// </summary>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        public byte GetSByte(string name)
+        {
+            return GetByte(GetOrdinal(name));
+        }
+
+        /// <summary>
+        /// Gets the value of the specified column as a sbyte.
+        /// </summary>
+        /// <param name="i"></param>
+        /// <returns></returns>
+        public sbyte GetSByte(int i)
+        {
+            IMySqlValue v = GetFieldValue(i, false);
+            if (v is MySqlByte)
+                return ((MySqlByte)v).Value;
+            else
+                return (sbyte)((MySqlByte)v).Value;
+        }
+
 		/// <summary>
 		/// Reads a stream of bytes from the specified column offset into the buffer an array
starting at the given buffer offset.
 		/// </summary>

Modified: branches/5.2/MySql.Data/Tests/Source/DataTypeTests.cs
===================================================================
--- branches/5.2/MySql.Data/Tests/Source/DataTypeTests.cs	2008-11-07 19:17:22 UTC (rev
1445)
+++ branches/5.2/MySql.Data/Tests/Source/DataTypeTests.cs	2008-11-07 19:35:19 UTC (rev
1446)
@@ -978,5 +978,26 @@
                 Assert.AreEqual(Math.PI, d);
             }
         }
+
+        /// <summary>
+        /// Bug #40571  	Add GetSByte to the list of public methods supported by
MySqlDataReader
+        /// </summary>
+        [Test]
+        public void SByteFromReader()
+        {
+            execSQL("DROP TABLE IF EXISTS Test");
+            execSQL("CREATE TABLE Test (c1 TINYINT, c2 TINYINT UNSIGNED)");
+            execSQL("INSERT INTO Test VALUES (99, 217)");
+
+            MySqlCommand cmd = new MySqlCommand("SELECT * FROM Test", conn);
+            using (MySqlDataReader reader = cmd.ExecuteReader())
+            {
+                reader.Read();
+                Assert.AreEqual(99, reader.GetSByte(0));
+                Assert.AreEqual(217, reader.GetByte(1));
+                Assert.AreEqual(99, reader.GetByte(0));
+            }
+
+        }
     }
 }

Thread
Connector/NET commit: r1446 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Sourcerburnett7 Nov