Browse Source

2005-02-11 Sureshkumar T <[email protected]>
Ankit Jain <[email protected]>

* SqlGuid.cs: Fixed CompareTo to compare all the 16 digits. This
is a LAMESPEC and current implementation matches ms.net. This
actually reverts Uma's patch with revison 29013.


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

Sureshkumar T 21 years ago
parent
commit
8d8a0a1b9a

+ 7 - 0
mcs/class/System.Data/System.Data.SqlTypes/ChangeLog

@@ -1,3 +1,10 @@
+2005-02-11  Sureshkumar T  <[email protected]>
+	    Ankit Jain	   <[email protected]>
+
+	* SqlGuid.cs: Fixed CompareTo to compare all the 16 digits. This
+	is a LAMESPEC and current implementation matches ms.net. This
+	actually reverts Uma's patch with revison 29013.
+
 2005-02-03  Sureshkumar T  <[email protected]>
 
 	* SqlDateTime.cs : Parse : try with local culture first, then try

+ 8 - 7
mcs/class/System.Data/System.Data.SqlTypes/SqlGuid.cs

@@ -43,7 +43,6 @@ namespace System.Data.SqlTypes
 	        Guid value;
 
 		private bool notNull;
-		private byte[] lastSixBytes;
 
 		public static readonly SqlGuid Null;
 
@@ -53,7 +52,6 @@ namespace System.Data.SqlTypes
 
 		public SqlGuid (byte[] value) 
 		{
-			lastSixBytes = new byte[6];
 			this.value = new Guid (value);
 			notNull = true;
 		}
@@ -61,21 +59,18 @@ namespace System.Data.SqlTypes
 		public SqlGuid (Guid g) 
 		{
 			this.value = g;
-			lastSixBytes = new byte[6];
 			notNull = true;
 		}
 
 		public SqlGuid (string s) 
 		{
 			this.value = new Guid (s);
-			lastSixBytes = new byte[6];
 			notNull = true;
 		}
 
 		public SqlGuid (int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) 
 		{
 			this.value = new Guid (a, b, c, d, e, f, g, h, i, j, k);
-			lastSixBytes = new byte[6];
 			notNull = true;
 		}
 
@@ -98,7 +93,7 @@ namespace System.Data.SqlTypes
 
 		private byte[] GetLastSixBytes()
 		{
-			lastSixBytes = new byte[6];
+			byte [] lastSixBytes = new byte[6];
 			
 			byte[] guidArray = value.ToByteArray();
 			lastSixBytes[0] = guidArray[10];
@@ -124,9 +119,13 @@ namespace System.Data.SqlTypes
 			else if (((SqlGuid)value).IsNull)
 				return 1;
 			else
+                                // LAMESPEC : ms.net implementation actually compares all the 16 bytes.
+                                // This code is kept for future changes, if required.
+                                /*
 				{
 					//MSDN documentation says that CompareTo is different from 
-					//Guid's CompareTo. It uses the SQL Server behavior where					    //only the last 6 bytes of value are evaluated	
+					//Guid's CompareTo. It uses the SQL Server behavior where
+                                        //only the last 6 bytes of value are evaluated	
 					byte[] compareValue = ((SqlGuid)value).GetLastSixBytes();
 					byte[] currentValue = GetLastSixBytes();
 					for (int i = 0; i < 6; i++)
@@ -137,6 +136,8 @@ namespace System.Data.SqlTypes
 					}
 			                return 0;
 				}
+                                */
+                                return this.value.CompareTo (((SqlGuid)value).Value);
 				
 		}