[Mono-bugs] [Bug 77411][Nor] New - Clone() method in System.Data.DataSet does not clone copy ForeignKeyContraints.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jan 30 18:13:08 EST 2006


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 john_marchesini at symantec.com.

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

--- shadow/77411	2006-01-30 18:13:08.000000000 -0500
+++ shadow/77411.tmp.2656	2006-01-30 18:13:08.000000000 -0500
@@ -0,0 +1,120 @@
+Bug#: 77411
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: RedHat 2.6.11-1.1369_FC4smp
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: tsenganal at novell.com                            
+ReportedBy: john_marchesini at symantec.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Clone() method in System.Data.DataSet does not clone copy ForeignKeyContraints.
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+
+Description of Problem: The Clone() method in System.Data.DataSet does not
+copy ForeignKeyConstraints that have been Add()ed to the original DataSet.
+ I verified that the Windows .NET framework clones the ForeignKeyConstraints.
+
+
+Steps to reproduce the problem:
+1. Create a file Main.cs with the following small C# program:
+
+//------------------------------------------------------------------------
+using System;
+using System.Data;
+
+class MainClass
+{
+   public static void Main( string[] args )
+   {
+      // Build a simple Directories table
+      DataTable dirTable = new DataTable( "Directories" );
+
+      DataColumn dir_UID = new DataColumn( "UID", typeof(System.Guid) );
+      dir_UID.Unique = true;
+      dir_UID.AllowDBNull = false;
+
+      dirTable.Columns.Add( dir_UID );
+
+      // Build a simple Files table
+      DataTable fileTable = new DataTable( "Files" );
+
+      DataColumn file_DirID = new DataColumn( "DirectoryID",
+typeof(System.Guid) );
+      file_DirID.Unique = false;
+      file_DirID.AllowDBNull = false;
+
+      fileTable.Columns.Add( file_DirID );
+	
+      // Build the DataSet
+      DataSet ds = new DataSet( "TestDataset" );
+      ds.Tables.Add( dirTable );
+      ds.Tables.Add( fileTable );
+	
+      // Add a foreign key constraint
+      DataColumn[] parentColumns = new DataColumn[1];
+      parentColumns[0] = ds.Tables["Directories"].Columns["UID"];
+
+      DataColumn[] childColumns = new DataColumn[1];
+      childColumns[0] = ds.Tables["Files"].Columns["DirectoryID"];
+		
+      ForeignKeyConstraint fk = new ForeignKeyConstraint( "FK_Test",
+parentColumns, childColumns );
+      ds.Tables["Files"].Constraints.Add( fk );		
+      ds.EnforceConstraints = true;
+
+      // Show Constraints for the ds
+      DumpConstraints( ds, "Directories" );
+      DumpConstraints( ds, "Files" );
+	
+      // Clone the ds
+      DataSet dsc = ds.Clone();
+
+      // Show Constraints for the clone: ForeignKeyConstraint is missing
+      DumpConstraints( dsc, "Directories" );
+      DumpConstraints( dsc, "Files" );
+   }
+	
+   private static void DumpConstraints( DataSet ds, string table )
+   {
+      Console.Write( "Constraints for the " + table + " table: " );
+	
+      int numConstraints = ds.Tables[table].Constraints.Count;
+		
+      for (int i=0; i < numConstraints; i++)
+      {
+         Console.WriteLine( ds.Tables[table].Constraints[i].ToString() );
+      }
+   }
+}
+//------------------------------------------------------------------------
+
+2. Compile using 'mcs -r:System.Data Main.cs'
+
+3. Run using 'mono Main.exe'
+
+Actual Results:
+Constraints for the Directories table: Constraint1
+Constraints for the Files table: FK_Test
+Constraints for the Directories table: Constraint1
+Constraints for the Files table: 
+
+Expected Results:  (Results from Main.exe in the MS .NET 1.1 framework)
+Constraints for the Directories table: Constraint1
+Constraints for the Files table: FK_Test
+Constraints for the Directories table: Constraint1
+Constraints for the Files table: FK_Test
+
+How often does this happen? 
+ - Always on Mono 1.1.13.
+ - Cannot repro on WinXP sp2 .NET Framework 1.1.
+
+Additional Information:


More information about the mono-bugs mailing list