MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Vladislav Vaintroub Date:October 7 2010 9:01pm
Subject:bzr commit into connector-net-6.0 branch (vvaintroub:839) Bug#57092
View as plain text  
#At file:///H:/connector_net/6.0/ based on revid:reggie.burnett@stripped

  839 Vladislav Vaintroub	2010-10-07
      Bug #57092 Row-By-Row-Update: only first row updated.
      
      The problem here is that after fix for Bug#54863, AcceptChanges 
      were called for the full Table,not for the individual row, so in a 
      row-by-row Update() modifications after the first one are lost.
      
      Fixed by calling AcceptChanges for each individual row. 
      
      It is a question whether we still need to the workaround for original
       bug#54863 and do AcceptChanges(), because it looks like the underlying
      bug in .NET was fixed  in a recent update, and Bug#54863 is no more 
      reproducible  even if we remove  AcceptChanges()  from  
      MySqlDataAdapter.Update() entirely.
      
      That is, DbDataAdapter.Update() does AcceptChanges() itself  for every row
      just like it is documented. (tried in .NET 2.0, 3.0, 3.5 and 4.0)

    modified:
      MySql.Data/Provider/Source/dataadapter.cs
=== modified file 'MySql.Data/Provider/Source/dataadapter.cs'
--- a/MySql.Data/Provider/Source/dataadapter.cs	2010-07-28 20:57:47 +0000
+++ b/MySql.Data/Provider/Source/dataadapter.cs	2010-10-07 21:01:53 +0000
@@ -165,46 +165,40 @@ namespace MySql.Data.MySqlClient
 
         protected override int Update(DataRow[] dataRows, DataTableMapping tableMapping)
         {
+
             List<MySqlConnection> connectionsOpened = new List<MySqlConnection>();
 
             try
             {
-                Dictionary<DataTable, bool> modifiedTables = new Dictionary<DataTable, bool>();
-
-                // Scan rows, lookiing for modified tables, we'll use them later 
-                // for AcceptChanges().
-                //
-                // Also open connections for insert/update/update commands, if 
+                // Open connections for insert/update/update commands, if 
                 // connections are closed.
                 foreach(DataRow row in dataRows)
                 {
                     OpenConnectionIfClosed(row.RowState, connectionsOpened);
+                }
+
+                int ret = base.Update(dataRows, tableMapping);
+
+                // Following was a workaround for Bug#54863
+                // It  a good question whether we still needed it, it seems like
+                // .NET bug (DbDataAdapter not issuing AcceptChanges() for 
+                // modified rows) has already been fixed in .NET
+                foreach (DataRow row in dataRows)
+                {
                     if (row.RowState != DataRowState.Unchanged &&
                         row.RowState != DataRowState.Detached)
                     {
-                        modifiedTables[row.Table] = true;
+                        row.AcceptChanges();
                     }
                 }
 
-                int ret = base.Update(dataRows, tableMapping);
-
-                // DbDataAdapter does automatically calls AcceptChanges on table.
-                // (even if  documentation states otherwise).
-                // Do AcceptsChanges() here, for SQL Server compatible behavior
-                // (see also Bug#5463)
-                
-                foreach (DataTable table in modifiedTables.Keys)
-                    table.AcceptChanges();
-
                 return ret;
-
             }
             finally 
             {
                 foreach(MySqlConnection c in connectionsOpened)
                     c.Close();
             }
-
         }
 
 


Attachment: [text/bzr-bundle] bzr/vvaintroub@mysql.com-20101007210153-gfjsq5bog9yuknzo.bundle
Thread
bzr commit into connector-net-6.0 branch (vvaintroub:839) Bug#57092Vladislav Vaintroub7 Oct