[Mono-bugs] [Bug 66111][Nor] New - DataRow.GetParentRows() Incompatible with .NET 1.1
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 16 Sep 2004 13:24:22 -0400 (EDT)
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 rscaletta@augustmack.com.
http://bugzilla.ximian.com/show_bug.cgi?id=66111
--- shadow/66111 2004-09-16 13:24:22.000000000 -0400
+++ shadow/66111.tmp.7874 2004-09-16 13:24:22.000000000 -0400
@@ -0,0 +1,108 @@
+Bug#: 66111
+Product: Mono: Class Libraries
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Fedora Core 2
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: rscaletta@augustmack.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: DataRow.GetParentRows() Incompatible with .NET 1.1
+
+Description of Problem:
+Given a DataRelation between two tables in a DataSet, set
+DataSet.EnforceConstraints = false. Now create two valid rows in the
+database that relate. DataRow.GetParentRow(DataRelation) returns null
+instead of the parent row. On Microsoft's .NET framework 1.1, the parent
+row is returned.
+
+Our company's website depends on this behavior in the .NET framework. As a
+result it doesn't work on a mono system without (lots and lots of) tweaking.
+
+
+Steps to reproduce the problem:
+Compile this program:
+// snip
+using System;
+using System.Data;
+
+class TestGetParentRow {
+ const int id = 0;
+ public static int Main(string[] args)
+ {
+ // Setup stuff
+ DataSet ds = new DataSet();
+ DataTable parent = ds.Tables.Add("parent");
+ parent.Columns.Add("id", typeof(int));
+ DataTable child = ds.Tables.Add("child");
+ child.Columns.Add("idref", typeof(int));
+ Constraint uniqueId = null;
+ parent.Constraints.Add(uniqueId = new UniqueConstraint("uniqueId",
+ new DataColumn[] {
+ parent.Columns["id"]
+ },
+ true));
+ ForeignKeyConstraint fkc = new
+ForeignKeyConstraint("ParentChildConstraint",
+ new
+DataColumn[] { parent.Columns["id"] },
+ new
+DataColumn[] { child.Columns["idref"]});
+
+ child.Constraints.Add(fkc);
+
+ DataRelation relateParentChild = new DataRelation("relateParentChild",
+ new DataColumn[] {
+parent.Columns["id"] },
+ new DataColumn[] {
+child.Columns["idref"] },
+ false);
+ ds.Relations.Add(relateParentChild);
+
+ // The actual test only takes 3 lines.
+ ds.EnforceConstraints = false;
+ DataRow parentRow = parent.Rows.Add(new object[] { id });
+ DataRow childRow = child.Rows.Add(new object[] { id });
+
+ if (parentRow == childRow.GetParentRow(relateParentChild)) {
+ Console.WriteLine("OK");
+ return 0;
+ } else {
+ Console.WriteLine("FAIL");
+ return 1;
+ }
+
+ }
+}
+// done
+Actual Results:
+prints "FAIL"
+
+Expected Results:
+prints "OK"
+
+How often does this happen?
+Every time.
+
+Additional Information:
+To fix this, you can change a line in DataRow.cs. Somewhere around line #
+1043, change
+
+if (indx != null) { // get the child rows from the index
+
+to
+
+if (indx != null &&
+ (Table == null || Table.DataSet == null ||
+ Table.DataSet.EnforceConstraints)) { // get the child rows from the index
+
+That will force the datarow to search for the parent row manually instead
+of letting the Index do the work. Apparantly Index will not work if
+constraints are disabled.