Subject: [pgAdmin4][Patch]: Fixed RM #2425 : Can't delete rows when using composite primary key

From: Khushboo Vashi <[email-masked]>
Date: Wed, 31 May 2017 15:31:08 +0530

Hi,

Please find the attached patch to fix RM #2425 :  Can't delete rows when
using composite primary key.

The grid selection checking for Primary key does not honour the composite
key which has been fixed.

Thanks,
Khushboo
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 7d51193..fc578b7 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -726,14 +726,18 @@ define(
 
                  // Clear selection model if row primary keys is set to default
                  var row_data = _.clone(collection[selected_rows_list[count]]),
-                   is_primary_key = _.has(row_data, primary_key_list) &&
-                                      row_data[0] != undefined ? true : false;
-
-                 if (primary_key_list.length &&
-                     !is_primary_key && !is_new_row
-                 ) {
-                   this.selection.setSelectedRows([]);
-                   selected_rows_list = [];
+                   is_primary_key = true;
+
+                 // Primary key validation
+                 _.each(primary_key_list, function(pk) {
+                   if (!(_.has(row_data, pk)) || row_data[pk] == undefined) {
+                     is_primary_key = false;
+                   }
+                 })
+
+                 if (primary_key_list.length && !is_primary_key && !is_new_row) {
+                     this.selection.setSelectedRows([]);
+                     selected_rows_list = [];
                  }
                }

-- 
Sent via pgadmin-hackers mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

---

From: Dave Page <[email-masked]>
Date: Tue, 6 Jun 2017 09:58:59 +0100

Thanks, applied.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company