2004-09-14 Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
authorFrancisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com>
Tue, 14 Sep 2004 23:02:12 +0000 (23:02 -0000)
committerFrancisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com>
Tue, 14 Sep 2004 23:02:12 +0000 (23:02 -0000)
    * Npgsql/NpgsqlRowDescription.cs:
        FieldIndex: Added support for case insensitive fields index lookup. Thanks Martin ( martijn at boland dot org)

svn path=/trunk/mcs/; revision=33910

mcs/class/Npgsql/ChangeLog
mcs/class/Npgsql/Npgsql/NpgsqlRowDescription.cs

index f2be599e1cd1adc077a15c1e7d5ba198f25fa1da..e64921e0c55984e46819db1fd0117672b320cf1b 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-14  Francisco Figueiredo Jr.  <fxjrlists@yahoo.com.br>
+
+    * Npgsql/NpgsqlRowDescription.cs:
+        FieldIndex: Added support for case insensitive fields index lookup. Thanks Martin ( martijn at boland dot org)
+        
 2004-09-12  Francisco Figueiredo Jr.  <fxjrlists@yahoo.com.br>
 
        * NpgsqlTypes/NpgsqlTypesHelper:
index e7eecbac17315e037c9a616f5001e24d8b27c242..3b4ddf48f5185c04823693f4cab159facd9c0f8f 100755 (executable)
@@ -76,7 +76,8 @@ namespace Npgsql
 
         public void ReadFromStream(Stream input_stream, Encoding encoding, NpgsqlBackendTypeMapping type_mapping)
         {
-            switch (protocol_version) {
+            switch (protocol_version)
+            {
             case ProtocolVersion.Version2 :
                 ReadFromStream_Ver_2(input_stream, encoding, type_mapping);
                 break;
@@ -175,21 +176,34 @@ namespace Npgsql
 
         public Int16 FieldIndex(String fieldName)
         {
-            Int16 result = 0;
+            Int16 result = -1;
+
+            // First try to find the index with IndexOf (case-sensitive)
+            result = (Int16)fields_index.IndexOf(fieldName);
 
-            foreach (String name in fields_index)
+            if (result > -1)
+            {
+                return result;
+            }
+            else
             {
 
-                if (name.Equals(fieldName))
+                result = 0;
+                foreach (String name in fields_index)
                 {
-                    return result;
+
+                    if (name.Equals(fieldName))
+                    {
+                        return result;
+                    }
+                    result++;
                 }
-                result++;
+
             }
+            
+            throw new ArgumentOutOfRangeException("fieldName", fieldName, "Field name not found");
 
-            throw new ArgumentOutOfRangeException("fieldName", fieldName, "Field name not found"); 
         }
 
     }
-
-}
+}
\ No newline at end of file