From 461c0abce1fbe842debc2a112525dc760e3682fa Mon Sep 17 00:00:00 2001 From: Nikhil Mohite Date: Tue, 21 Dec 2021 18:07:17 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20an=20issue=20where=C2=A0Tablespace=20is?= =?UTF-8?q?=20created=20though=20an=20error=20is=20shown=20on=20the=20dial?= =?UTF-8?q?og.=20Fixes=20#6745?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en_US/release_notes_6_4.rst | 1 + .../servers/tablespaces/__init__.py | 36 +++++++++++++------ web/pgadmin/browser/static/js/node.js | 6 ++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/docs/en_US/release_notes_6_4.rst b/docs/en_US/release_notes_6_4.rst index ac4f10edc..07dbe7046 100644 --- a/docs/en_US/release_notes_6_4.rst +++ b/docs/en_US/release_notes_6_4.rst @@ -17,4 +17,5 @@ Housekeeping Bug fixes ********* +| `Issue #6745 `_ - Fixed an issue where Tablespace is created though an error is shown on the dialog. | `Issue #7034 `_ - Fixed an issue where Columns with default value not showing when adding a new row. diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py index 9e53a4a9c..fe3c7f1ed 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py @@ -322,16 +322,6 @@ class TablespaceView(PGChildNodeView): if not status: return internal_server_error(errormsg=res) - SQL = render_template( - "/".join([self.template_path, self._ALTER_SQL]), - data=data, conn=self.conn - ) - - # Checking if we are not executing empty query - if SQL and SQL.strip('\n') and SQL.strip(' '): - status, res = self.conn.execute_scalar(SQL) - if not status: - return internal_server_error(errormsg=res) # To fetch the oid of newly created tablespace SQL = render_template( @@ -344,6 +334,32 @@ class TablespaceView(PGChildNodeView): if not status: return internal_server_error(errormsg=tsid) + SQL = render_template( + "/".join([self.template_path, self._ALTER_SQL]), + data=data, conn=self.conn + ) + + # Checking if we are not executing empty query + if SQL and SQL.strip('\n') and SQL.strip(' '): + status, res = self.conn.execute_scalar(SQL) + if not status: + return jsonify( + node=self.blueprint.generate_browser_node( + tsid, + sid, + data['name'], + icon="icon-tablespace" + ), + success=0, + errormsg=gettext( + 'Tablespace created successfully, ' + 'Set parameter fail: {0}'.format(res) + ), + info=gettext( + res + ) + ) + return jsonify( node=self.blueprint.generate_browser_node( tsid, diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js index 122358954..b51f09530 100644 --- a/web/pgadmin/browser/static/js/node.js +++ b/web/pgadmin/browser/static/js/node.js @@ -1550,6 +1550,12 @@ define('pgadmin.browser.node', [ $(pnlDependencies).removeData('node-prop'); if (pnlDependents) $(pnlDependents).removeData('node-prop'); + + if(nodeData.success === 0) { + Notify.alert(gettext('Error'), + gettext(nodeData.errormsg) + ); + } } } );