ソースを参照

2004-05-21 Atsushi Enomoto <[email protected]>

	* DataColumnCollection.cs : NullReferenceException was thrown when
	  the table was not found.
	* DataRowCollection.cs :
	  Find() just returns null for null value under MS.NET 1.1.
	  RemoveAt() should also avoid to call AcceptChanges() like Remove().
	* UniqueConstraint.cs : in AssertConstraint() throw ConstraintException
	  directly under MS.NET (for nunit test).

svn path=/trunk/mcs/; revision=27829
Atsushi Eno 21 年 前
コミット
a1ad65b95b

+ 10 - 0
mcs/class/System.Data/System.Data/ChangeLog

@@ -1,3 +1,13 @@
+2004-05-21  Atsushi Enomoto  <[email protected]>
+
+	* DataColumnCollection.cs : NullReferenceException was thrown when
+	  the table was not found.
+	* DataRowCollection.cs :
+	  Find() just returns null for null value under MS.NET 1.1.
+	  RemoveAt() should also avoid to call AcceptChanges() like Remove().
+	* UniqueConstraint.cs : in AssertConstraint() throw ConstraintException
+	  directly under MS.NET (for nunit test).
+
 2004-05-21  Atsushi Enomoto  <[email protected]>
 
 	* XmlSchemaDataImporter.cs : Setting startindex in LastIndexOf() 

+ 1 - 1
mcs/class/System.Data/System.Data/DataColumnCollection.cs

@@ -527,7 +527,7 @@ namespace System.Data {
 			DataColumn column = this[name];
 			
 			if (column == null)
-				throw new ArgumentException ("Column '" + name + "' does not belong to table " + ( parentTable != null ? "" : parentTable.TableName ) + ".");
+				throw new ArgumentException ("Column '" + name + "' does not belong to table " + ( parentTable == null ? "" : parentTable.TableName ) + ".");
 			Remove(column);
 		}
 

+ 8 - 1
mcs/class/System.Data/System.Data/DataRowCollection.cs

@@ -154,7 +154,11 @@ namespace System.Data
 				throw new ArgumentException ("Expecting " + table.PrimaryKey.Length +" value(s) for the key being indexed, but received 1 value(s).");
 
 			if (key == null)
+#if NET_1_1
+				return null;
+#else
 				throw new ArgumentException("Expecting 1 value(s) for the key being indexed, but received 0 value(s).");
+#endif
 
 			DataColumn primaryKey = table.PrimaryKey[0];
 			Index primaryKeyIndex = table.GetIndexByColumns(table.PrimaryKey);
@@ -325,7 +329,10 @@ namespace System.Data
 				throw new IndexOutOfRangeException ("There is no row at position " + index + ".");
 			DataRow row = (DataRow)List [index];
 			row.Delete();
-			row.AcceptChanges();
+			// if the row was in added state it will be in Detached state after the
+			// delete operation, so we have to check it.
+			if (row.RowState != DataRowState.Detached)
+				row.AcceptChanges();
 		}
 
 		///<summary>

+ 4 - 0
mcs/class/System.Data/System.Data/UniqueConstraint.cs

@@ -424,8 +424,12 @@ namespace System.Data {
 				Table.InitializeIndex (Index);
 			}
 			catch (ConstraintException) {
+#if false//NET_1_1
+				throw;
+#else
 				Index = null;
 				throw new ArgumentException (String.Format ("Column '{0}' contains non-unique values", this._dataColumns[0]));
+#endif
 			}
 			
 			// if there is no index with same columns - add the new index to the table.