From d5f537aae497e4ac3811a035ca357dbef07c0885 Mon Sep 17 00:00:00 2001 From: Rahul Shirsat Date: Mon, 7 Jun 2021 21:11:28 +0530 Subject: [PATCH] Added extra check for verifying the rename of the database. refs #4203 --- web/pgadmin/tools/sqleditor/__init__.py | 2 ++ web/pgadmin/tools/sqleditor/static/js/sqleditor.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 884cc8be0..780c0243f 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -505,6 +505,8 @@ def poll(trans_id): transaction_status = conn.transaction_status() data_obj['db_name'] = conn.db + data_obj['db_id'] = trans_obj.did \ + if trans_obj is not None and hasattr(trans_obj, 'did') else 0 return make_json_response( data={ diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index 33547223e..3e91f424a 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -5125,9 +5125,10 @@ define('tools.querytool', [ tree_data = pgWindow.default.pgAdmin.Browser.treeMenu.translateTreeNodeIdFromACITree(selected_item), server_data = pgWindow.default.pgAdmin.Browser.treeMenu.findNode(tree_data.slice(0,2)), database_data = pgWindow.default.pgAdmin.Browser.treeMenu.findNode(tree_data.slice(0,4)), - db_name = database_data.data.label; + db_name = database_data.data.label, + db_did = database_data.data._id; - if(!_.isEqual(db_name, data.data_obj.db_name)) { + if(data.data_obj.db_id == db_did && !_.isEqual(db_name, data.data_obj.db_name)) { var message = `Current database has been moved or renamed to ${data.data_obj.db_name}. Click on the OK button to refresh the database name.`, title = self.url_params.title;