From: Date: November 7 2008 8:35pm
Subject: Connector/NET commit: r1446 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Tests/Source
List-Archive: http://lists.mysql.com/commits/58229
X-Bug: 40571
Message-Id: <200811071935.mA7JZJ9K025107@bk-internal.mysql.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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;
}
+ ///
+ /// Gets the value of the specified column as a sbyte.
+ ///
+ ///
+ ///
+ public byte GetSByte(string name)
+ {
+ return GetByte(GetOrdinal(name));
+ }
+
+ ///
+ /// Gets the value of the specified column as a sbyte.
+ ///
+ ///
+ ///
+ public sbyte GetSByte(int i)
+ {
+ IMySqlValue v = GetFieldValue(i, false);
+ if (v is MySqlByte)
+ return ((MySqlByte)v).Value;
+ else
+ return (sbyte)((MySqlByte)v).Value;
+ }
+
///
/// Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset.
///
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);
}
}
+
+ ///
+ /// Bug #40571 Add GetSByte to the list of public methods supported by MySqlDataReader
+ ///
+ [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));
+ }
+
+ }
}
}