In Test/System.Data:
authorSureshkumar T <suresh@mono-cvs.ximian.com>
Tue, 25 Jan 2005 09:06:33 +0000 (09:06 -0000)
committerSureshkumar T <suresh@mono-cvs.ximian.com>
Tue, 25 Jan 2005 09:06:33 +0000 (09:06 -0000)
2005-01-25  Sureshkumar T  <tsureshkumar@novell.com>

* DataTableTest.cs: added test case for checking ImportRow when
the row state is detached. Test case by Ankit Jain.

In System.Data:
2005-01-25  Sureshkumar T  <tsureshkumar@novell.com>

* DataRow.cs: CopyValuesToRow : set the column value with the
default version of the given row.
* DataTable.cs: ImportRow: Copy values before adding row.
* DataSet.cs: AddChangedRow: Add the row to the table after
copying values.

Fixes bug #67317. Patch by Ankit Jain.

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

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataRow.cs
mcs/class/System.Data/System.Data/DataSet.cs
mcs/class/System.Data/System.Data/DataTable.cs
mcs/class/System.Data/Test/System.Data/ChangeLog
mcs/class/System.Data/Test/System.Data/DataTableTest.cs

index e04bd6baf261b128bd9057e3d243e53c709c4450..23798d1173ae09577abfa61cb089cae3945bf325 100644 (file)
@@ -1,3 +1,13 @@
+2005-01-25  Sureshkumar T  <tsureshkumar@novell.com>
+
+       * DataRow.cs: CopyValuesToRow : set the column value with the
+       default version of the given row.
+       * DataTable.cs: ImportRow: Copy values before adding row.
+       * DataSet.cs: AddChangedRow: Add the row to the table after
+       copying values.
+
+       Fixes bug #67317. Patch by Ankit Jain.
+
 2005-01-25  Atsushi Enomoto  <atsushi@ximian.com>
 
        * DataRowView.cs : Fixed IsEdit to reflect correct status of DataRow.
index 2ad5f64894f8ffce6797746f68b426874da92b28..a1869900f7bbef5b6d1c4a2c967c91f3451b238e 100644 (file)
@@ -1368,7 +1368,7 @@ namespace System.Data {
                                        }
                                        
                                        //Saving the current value as the column value
-                                       row[index] = targetColumn[row._current];
+                                       row [index] = targetColumn [IndexFromVersion (DataRowVersion.Default)];
                                        
                                }
                        }
index 990330b8f313e85f0d6bf8414ed07d2f52969d97..50d9bd9be4f54ca445225a40480fe484fe739232 100644 (file)
@@ -496,8 +496,8 @@ namespace System.Data {
                        }
                
                        DataRow newRow = copyTable.NewRow ();
-                       copyTable.Rows.Add (newRow);
                        row.CopyValuesToRow (newRow);
+                       copyTable.Rows.Add (newRow);
                        newRow.XmlRowID = row.XmlRowID;
                        addedRows.Add (row,row);
                }
index c9fb8b6a50d8deb7d7bc5eda6a822fe5ae61eee3..a68f5f021055f393376674ba51a6468daa77eae4 100644 (file)
@@ -945,9 +945,9 @@ namespace System.Data {
                public void ImportRow (DataRow row) 
                {
                        DataRow newRow = NewRow();
-                       Rows.Add(newRow);
-                       row.CopyValuesToRow(newRow);
-                       
+                       row.CopyValuesToRow (newRow);
+                       Rows.Add (newRow);
+                       row.CopyState (newRow);
                }
 
                internal int DefaultValuesRowIndex
index 57df4964bdbe5512797930729976023c11530cc1..7c530004ef366cb4860455cbc302e3d3a15fea2d 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-25  Sureshkumar T  <tsureshkumar@novell.com>
+
+       * DataTableTest.cs: added test case for checking ImportRow when
+       the row state is detached. Test case by Ankit Jain.
+
 2005-01-25  Atsushi Enomoto  <atsushi@ximian.com>
 
        * DataRowViewTest.cs : added IsEdit tests and Item tess (not working).
index 91cc0cf6cde807803e2b864caab45a5af28f750a..acecbcb722a290eca20484df3337ae6ea56c8fab 100644 (file)
@@ -1084,7 +1084,7 @@ namespace MonoTests.System.Data
                        col.ColumnName = "Id";
                        col.DataType = Type.GetType ("System.Int32");
                        table.Columns.Add (col);
-                        
+
                        col = new DataColumn ();
                        col.ColumnName = "Name";
                        col.DataType = Type.GetType ("System.String");
@@ -1111,6 +1111,31 @@ namespace MonoTests.System.Data
                        AssertEquals ("#A03", DataRowState.Modified, table.Rows [2].RowState);
                        AssertEquals ("#A04", DataRowState.Added, table.Rows [3].RowState);
                }
+
+                [Test]
+               public void ImportRowDetachedTest ()
+               {
+                       DataTable table = new DataTable ();
+                       DataColumn col = new DataColumn ();
+                       col.ColumnName = "Id";
+                       col.DataType = Type.GetType ("System.Int32");
+                       table.Columns.Add (col);
+
+                        table.PrimaryKey = new DataColumn [] {col};
+
+                        col = new DataColumn ();
+                       col.ColumnName = "Name";
+                       col.DataType = Type.GetType ("System.String");
+                       table.Columns.Add (col);
+                        
+                       DataRow row = table.NewRow ();
+                       row ["Id"] = 147;
+                       row ["name"] = "Abc";
+
+                        // keep silent as ms.net ;-), though this is not useful.
+                        table.ImportRow (row); 
+               }
+
                [Test]
                public void ClearReset () //To test Clear and Reset methods
                {