Fixes for broken RO check
authorCarsten Schlote <c.schlote@konzeptpark.de>
Thu, 11 Nov 2010 16:35:41 +0000 (17:35 +0100)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 14 Feb 2011 15:51:40 +0000 (10:51 -0500)
- When calling GetChanges() the ReadOnly check for DataCalumns must be
  turned off, as otherwise data of readonly columns can't be cloned
  into new rows for the new created DataSet/dataTable

Signed-off-by: Carsten Schlote <schlote@vahanus.net>
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/System.Data/MergeManager.cs

index 941bc1f9097ef37a6888686e913d2dbdeb13f728..bef0d3054668cedc36b72091d6c24a14ee3e44e4 100644 (file)
@@ -487,7 +487,7 @@ namespace System.Data {
                                CheckValue (this [col], col, false);
                }
 
-               void CheckValue (object v, DataColumn col)
+               private void CheckValue (object v, DataColumn col)
                {
                        CheckValue (v, col, true);
                }
@@ -1399,6 +1399,11 @@ namespace System.Data {
 
                //Copy all values of this DataRow to the row parameter.
                internal void CopyValuesToRow (DataRow row)
+               {
+                       CopyValuesToRow(row, true);
+               }
+               
+               internal void CopyValuesToRow (DataRow row, bool doROCheck)
                {
                        if (row == null)
                                throw new ArgumentNullException("row");
@@ -1454,19 +1459,19 @@ namespace System.Data {
                                if (targetColumn != null) {
                                        if (HasVersion (DataRowVersion.Original)) {
                                                object val = column[Original];
-                                               row.CheckValue (val, targetColumn);
+                                               row.CheckValue (val, targetColumn, doROCheck);
                                                targetColumn [row.Original] = val;
                                        }
 
                                        if (HasVersion (DataRowVersion.Current) && Current != Original) {
                                                object val = column[Current];
-                                               row.CheckValue (val, targetColumn);
+                                               row.CheckValue (val, targetColumn, doROCheck);
                                                targetColumn [row.Current] = val;
                                        }
 
                                        if (HasVersion (DataRowVersion.Proposed)) {
                                                object val = column[row.Proposed];
-                                               row.CheckValue (val, targetColumn);
+                                               row.CheckValue (val, targetColumn, doROCheck);
                                                targetColumn [row.Proposed] = val;
                                        }
                                }
index b62aff1e4d7847ae0836161b9f48aadd6d63d6ca..3b0f0c4e9adb3e3fb239c90d66301bcd0176440c 100644 (file)
@@ -568,7 +568,8 @@ namespace System.Data
                        // add the current row\r
                        DataRow newRow = copyTable.NewNotInitializedRow ();\r
                        copyTable.Rows.AddInternal (newRow);\r
-                       row.CopyValuesToRow (newRow);\r
+                       // Don't check for ReadOnly, when cloning data to new uninitialized row.\r
+                       row.CopyValuesToRow (newRow, false);\r
                        newRow.XmlRowID = row.XmlRowID;\r
                        addedRows.Add (row, row);\r
                }\r
index 21f54308f3973638285f81312b6f6684ad947e32..f622744cf39085b8f0a46e80c8eb89fe5ae68784 100644 (file)
@@ -996,7 +996,8 @@ namespace System.Data {
                                if (copyTable == null)\r
                                        copyTable = Clone ();\r
                                DataRow newRow = copyTable.NewNotInitializedRow ();\r
-                               row.CopyValuesToRow (newRow);\r
+                               // Don't check for ReadOnly, when cloning data to new uninitialized row.\r
+                               row.CopyValuesToRow (newRow, false);\r
 #if NET_2_0\r
                                newRow.XmlRowID = row.XmlRowID;\r
 #endif\r
index 09b8f58ff4586251b1bf3de96d5ea353698cec20..911ca37f36fc848b535b135ee0a7c7f5fbcbf6ab 100644 (file)
@@ -148,7 +148,8 @@ namespace System.Data
                        if (targetRow == null)
                        { 
                                DataRow newRow = targetTable.NewNotInitializedRow();
-                               row.CopyValuesToRow(newRow);
+                               // Don't check for ReadOnly, when cloning data to new uninitialized row.
+                               row.CopyValuesToRow(newRow, false);
                                targetTable.Rows.AddInternal (newRow);
                        }
                        // row exists in target table, and presere changes is false -