Hi,

While deleting a few (400!) records from a master table (in a development
database), I realised that PgAdmin just wouldn't stop displaying 400 error
messages informing that each of the deletes failed (in this case because a
foreign key dependency would not allow the delete to succeed).

I think a good solution to this would be that after the initial confirmation
for deletion in EditGrid, the first error (during delete process) should
allow the user to cancel further deletes. This can help a great deal, for
e.g. in cases when the user realises his mistake as soon as the first error
pops up.

Attached is a patch to do the same. Note, that the 'reconfirmation' is done
only on the first error. So this takes care of another possible case when
the users 'knows' that some random 20 out of his 500 deletes would fail !

Regards,
*Robins Tharakan*
Index: pgadmin/frm/frmEditGrid.cpp
===================================================================
--- pgadmin/frm/frmEditGrid.cpp	(revision 7105)
+++ pgadmin/frm/frmEditGrid.cpp	(working copy)
@@ -1034,8 +1034,20 @@
 
     // don't care a lot about optimizing here; doing it line by line
     // just as sqlTable::DeleteRows does
-	while (i--)
-		sqlGrid->DeleteRows(delrows.Item(i), 1);
+    int show_continue_message = 1;
+    while (i--)
+    {
+        if (!sqlGrid->DeleteRows(delrows.Item(i), 1) &&
+            i > 0 &&
+            show_continue_message == 1)
+        {
+        	wxMessageDialog msg(this, wxString::Format(_("There was an error deleting the previous record.\nAre you sure you wish to delete the remaining %d rows ?"), i), _("Delete more records ?"), wxYES_NO | wxICON_QUESTION);
+        	if (msg.ShowModal() != wxID_YES)
+            	break;
+            else
+                show_continue_message = 0;
+        }
+    }
 
 
     sqlGrid->EndBatch();
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to