List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:March 11 2010 8:56pm
Subject:bzr commit into connector-net-6.0 branch (reggie.burnett:801) Bug#47467
View as plain text  
#At file:///D:/bzr-connector-net/6.0/ based on revid:reggie.burnett@stripped

  801 Reggie Burnett	2010-03-11
      - added two requested features -- MySqlDataReader.GetFieldType(string columnname) &
        MySqlDataReader.GetOrdinal() includes the name of the column in the exception when not found
        (bug #47467)

    modified:
      CHANGES
      MySql.Data/Provider/Source/datareader.cs
      MySql.Data/Tests/Source/DataReaderTests.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2010-03-10 19:14:18 +0000
+++ b/CHANGES	2010-03-11 20:56:27 +0000
@@ -26,6 +26,9 @@
 - fixed bug in sql generation when using a negated binary fragment in EF (bug #49850)
 - fixed bug in tokenization where a nonterminated string in sql will cause a CLR exception
   rather than throwing a syntax exception (bug #51788)
+- added two requested features -- MySqlDataReader.GetFieldType(string columnname) &
+  MySqlDataReader.GetOrdinal() includes the name of the column in the exception when not found
+  (bug #47467)
 
 Version 6.0.5
 - ensure that MySqlPacket always has a valid encoding. This prevents null reference exceptions in ReadString()

=== modified file 'MySql.Data/Provider/Source/datareader.cs'
--- a/MySql.Data/Provider/Source/datareader.cs	2009-10-29 21:29:54 +0000
+++ b/MySql.Data/Provider/Source/datareader.cs	2010-03-11 20:56:27 +0000
@@ -459,6 +459,11 @@
 			return Convert.ToDouble(v.Value);
 		}
 
+        public Type GetFieldType(string column)
+        {
+            return GetFieldType(GetOrdinal(column));
+        }
+
 		/// <summary>
 		/// Gets the Type that is the data type of the object.
 		/// </summary>
@@ -601,7 +606,7 @@
 				return (int)ordinal;
 
 			// Throw an exception if the ordinal cannot be found.
-			throw new IndexOutOfRangeException("Could not find specified column in results");
+			throw new IndexOutOfRangeException("Could not find specified column in results: " + name);
 		}
 
 		/// <summary>

=== modified file 'MySql.Data/Tests/Source/DataReaderTests.cs'
--- a/MySql.Data/Tests/Source/DataReaderTests.cs	2009-08-31 19:32:51 +0000
+++ b/MySql.Data/Tests/Source/DataReaderTests.cs	2010-03-11 20:56:27 +0000
@@ -773,5 +773,29 @@
                 string name2 = reader.GetString(1);
             }
         }
+
+        /// <summary>
+        /// Bug #47467	Two simple changes for DataReader
+        /// </summary>
+        [Test]
+        public void Bug47467()
+        {
+            MySqlCommand cmd = new MySqlCommand("SELECT 1 as c1", conn);
+            using (MySqlDataReader reader = cmd.ExecuteReader())
+            {
+                reader.Read();
+                Type t = reader.GetFieldType("c1");
+
+                try
+                {
+                    reader.GetOrdinal("nocol");
+                    Assert.Fail("This should have failed");
+                }
+                catch (IndexOutOfRangeException ex)
+                {
+                    Assert.IsTrue(ex.Message.IndexOf("nocol") != -1);
+                }
+            }
+        }
     }
 }


Attachment: [text/bzr-bundle] bzr/reggie.burnett@sun.com-20100311205627-xw4kl705ga5agapc.bundle
Thread
bzr commit into connector-net-6.0 branch (reggie.burnett:801) Bug#47467Reggie Burnett11 Mar