[Mono-bugs] [Bug 75123][Nor] New - [PATCH] GetChanges() throws NoNullAllowedException

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Jun 2 11:45:09 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by george.barbarosie at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=75123

--- shadow/75123	2005-06-02 11:45:09.000000000 -0400
+++ shadow/75123.tmp.11816	2005-06-02 11:45:09.000000000 -0400
@@ -0,0 +1,110 @@
+Bug#: 75123
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: george.barbarosie at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [PATCH] GetChanges() throws NoNullAllowedException
+
+This applies for Mono Class Libraries SVN trunk version.
+
+Execute following sample:
+
+using System;
+using System.Data;
+
+class Test {
+    public static void Main() {
+        DataSet ds = new DataSet("testds");
+
+        DataTable tbl = ds.Tables.Add("parent");
+        DataColumn col = tbl.Columns.Add("id", typeof(int));
+        col.AutoIncrement = true;
+        col = tbl.Columns.Add("data", typeof(string));
+        col.AllowDBNull = false;
+        tbl.PrimaryKey = new DataColumn[] { tbl.Columns["id"] };
+
+        tbl = ds.Tables.Add("child");
+        col = tbl.Columns.Add("id", typeof(int));
+        col.AutoIncrement = true;
+        col = tbl.Columns.Add("parent", typeof(int));
+        tbl.Columns.Add("data", typeof(string));
+        tbl.PrimaryKey = new DataColumn[] { tbl.Columns["id"] };
+
+        ds.Relations.Add("child2parent",
+                ds.Tables["parent"].Columns["id"],
+                ds.Tables["child"].Columns["parent"]);
+
+        DataRow row = ds.Tables["parent"].NewRow();
+        row["data"] = "something on parent";
+        ds.Tables["parent"].Rows.Add(row);
+
+        row = ds.Tables["child"].NewRow();
+        row["data"] = "something on child";
+        row["parent"] = 0;
+        ds.Tables["child"].Rows.Add(row);
+        ds.AcceptChanges();
+
+        row = ds.Tables["child"].Rows.Find(0);
+        row["data"] = "something else";
+
+        Console.WriteLine(ds.GetChanges().GetXml());
+    }
+}
+
+Expected result:
+
+<testds>
+  <parent>
+    <id>0</id>
+    <data>something on parent</data>
+  </parent>
+  <child>
+    <id>0</id>
+    <parent>0</parent>
+    <data>something else</data>
+  </child>
+</testds>
+
+Actual result:
+
+Unhandled Exception: System.Data.NoNullAllowedException: Exception of type
+System.Data.NoNullAllowedException was thrown.in <0x000e9>
+System.Data.DataRow:CheckNullConstraints ()
+in <0x00050> System.Data.DataRowCollection:ValidateDataRowInternal
+(System.Data.DataRow row)
+in <0x00092> System.Data.DataRowCollection:Add (System.Data.DataRow row)
+in <0x00180> System.Data.DataSet:AddChangedRow
+(System.Collections.Hashtable addedRows, System.Data.DataSet copySet,
+System.Data.DataTable copyTable, IEnumerator relations, System.Data.DataRow
+row)
+in <0x0018f> System.Data.DataSet:GetChanges (DataRowState rowStates)
+in <0x0000f> System.Data.DataSet:GetChanges ()
+in <0x004ea> Test:Main ()
+
+To fix this, apply this patch:
+
+Index: mcs/class/System.Data/System.Data/DataSet.cs
+===================================================================
+--- mcs/class/System.Data/System.Data/DataSet.cs        (revision 45328)
++++ mcs/class/System.Data/System.Data/DataSet.cs        (working copy)
+@@ -513,9 +513,9 @@
+                        }
+
+                        DataRow newRow = copyTable.NewRow ();
+-                       copyTable.Rows.Add (newRow);
+                        row.CopyValuesToRow (newRow);
+                        newRow.XmlRowID = row.XmlRowID;
++                       copyTable.Rows.Add (newRow);
+                        addedRows.Add (row,row);
+                }


More information about the mono-bugs mailing list