Ensure that proper error should be displayed for the deleted node. Fixes #3669

pull/33/head
Satish V 2020-06-03 11:26:26 +05:30 committed by Akshay Joshi
parent 3d0319dba7
commit d22e276586
24 changed files with 186 additions and 52 deletions

View File

@ -19,6 +19,7 @@ Housekeeping
Bug fixes Bug fixes
********* *********
| `Issue #3669 <https://redmine.postgresql.org/issues/3669>`_ - Ensure that proper error should be displayed for the deleted node.
| `Issue #3787 <https://redmine.postgresql.org/issues/3787>`_ - Disabled the Stop process button after clicking it and added a message 'Terminating the process...' to notify the user. | `Issue #3787 <https://redmine.postgresql.org/issues/3787>`_ - Disabled the Stop process button after clicking it and added a message 'Terminating the process...' to notify the user.
| `Issue #5416 <https://redmine.postgresql.org/issues/5416>`_ - Ensure that the query tool panel gets closed when clicking on the 'Don't Save' button. | `Issue #5416 <https://redmine.postgresql.org/issues/5416>`_ - Ensure that the query tool panel gets closed when clicking on the 'Don't Save' button.
| `Issue #5465 <https://redmine.postgresql.org/issues/5465>`_ - Fixed an issue where the Edge browser version is showing wrong and warning message gets displayed. | `Issue #5465 <https://redmine.postgresql.org/issues/5465>`_ - Fixed an issue where the Edge browser version is showing wrong and warning message gets displayed.

View File

@ -405,7 +405,10 @@ class ForeignServerView(PGChildNodeView):
status, res1 = self.conn.execute_dict(sql) status, res1 = self.conn.execute_dict(sql)
if not status: if not status:
return internal_server_error(errormsg=res1) return internal_server_error(errormsg=res1)
if len(res1['rows']) == 0:
return gone(
gettext("The specified foreign server could not be found.")
)
fdw_data = res1['rows'][0] fdw_data = res1['rows'][0]
is_valid_options = False is_valid_options = False

View File

@ -411,6 +411,9 @@ class UserMappingView(PGChildNodeView):
if not status: if not status:
return internal_server_error(errormsg=res1) return internal_server_error(errormsg=res1)
if len(res1['rows']) == 0:
return gone(
gettext("The specified user mappings could not be found."))
fdw_data = res1['rows'][0] fdw_data = res1['rows'][0]

View File

@ -23,6 +23,7 @@ from pgadmin.browser.utils import PGChildNodeView
from pgadmin.utils.ajax import make_json_response, internal_server_error, \ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
make_response as ajax_response, gone make_response as ajax_response, gone
from pgadmin.utils.driver import get_driver from pgadmin.utils.driver import get_driver
from web.pgadmin.utils.exception import ObjectGone
class DomainConstraintModule(CollectionNodeModule): class DomainConstraintModule(CollectionNodeModule):
@ -450,6 +451,8 @@ class DomainConstraintView(PGChildNodeView):
icon=icon icon=icon
) )
) )
except ObjectGone:
raise
except Exception as e: except Exception as e:
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
@ -686,6 +689,8 @@ class DomainConstraintView(PGChildNodeView):
return True, SQL.strip('\n'), data['name'] return True, SQL.strip('\n'), data['name']
else: else:
return True, SQL.strip('\n'), old_data['name'] return True, SQL.strip('\n'), old_data['name']
except ObjectGone:
raise
except Exception as e: except Exception as e:
return False, internal_server_error(errormsg=str(e)), None return False, internal_server_error(errormsg=str(e)), None
@ -704,6 +709,9 @@ class DomainConstraintView(PGChildNodeView):
if not status: if not status:
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0:
raise ObjectGone(
gettext("The specified domain could not be found."))
return res['rows'][0]['schema'], res['rows'][0]['domain'] return res['rows'][0]['schema'], res['rows'][0]['domain']

View File

@ -458,6 +458,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
status, data = self._fetch_properties(gid, sid, did, scid, foid) status, data = self._fetch_properties(gid, sid, did, scid, foid)
if not status: if not status:
return data return data
if not data:
return gone(
gettext("The specified foreign table could not be found."))
return ajax_response( return ajax_response(
response=data, response=data,
@ -833,6 +836,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
inherits=True) inherits=True)
if not status: if not status:
return data return data
if not data:
return gone(
gettext("The specified foreign table could not be found."))
if diff_schema: if diff_schema:
data['basensp'] = diff_schema data['basensp'] = diff_schema
@ -918,6 +924,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
foid, inherits=True) foid, inherits=True)
if not status: if not status:
return old_data return old_data
if not old_data:
return gone(
gettext("The specified foreign table could not be found."))
if is_schema_diff: if is_schema_diff:
data['is_schema_diff'] = True data['is_schema_diff'] = True
@ -1090,7 +1099,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, False return True, False
data = res['rows'][0] data = res['rows'][0]
data['is_sys_obj'] = ( data['is_sys_obj'] = (
@ -1263,6 +1272,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
status, data = self._fetch_properties(gid, sid, did, scid, foid) status, data = self._fetch_properties(gid, sid, did, scid, foid)
if not status: if not status:
return data return data
if not data:
return gone(
gettext("The specified foreign table could not be found."))
columns = [] columns = []
for c in data['columns']: for c in data['columns']:
@ -1298,6 +1310,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
status, data = self._fetch_properties(gid, sid, did, scid, foid) status, data = self._fetch_properties(gid, sid, did, scid, foid)
if not status: if not status:
return data return data
if not data:
return gone(
gettext("The specified foreign table could not be found."))
columns = [] columns = []
values = [] values = []
@ -1338,6 +1353,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
status, data = self._fetch_properties(gid, sid, did, scid, foid) status, data = self._fetch_properties(gid, sid, did, scid, foid)
if not status: if not status:
return data return data
if not data:
return gone(
gettext("The specified foreign table could not be found."))
columns = [] columns = []
@ -1382,6 +1400,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
status, data = self._fetch_properties(gid, sid, did, scid, foid) status, data = self._fetch_properties(gid, sid, did, scid, foid)
if not status: if not status:
return data return data
if not data:
return gone(
gettext("The specified foreign table could not be found."))
sql = u"DELETE FROM {0}\n\tWHERE <condition>;".format( sql = u"DELETE FROM {0}\n\tWHERE <condition>;".format(
self.qtIdent(self.conn, data['basensp'], data['name']) self.qtIdent(self.conn, data['basensp'], data['name'])

View File

@ -1508,6 +1508,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
status, res = self.conn.execute_2darray(SQL) status, res = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(gettext("The specified function could not be found."))
name = self.qtIdent( name = self.qtIdent(
self.conn, res['rows'][0]['nspname'], self.conn, res['rows'][0]['nspname'],

View File

@ -593,6 +593,8 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
status, res = self._fetch_properties(did, scid, tid) status, res = self._fetch_properties(did, scid, tid)
if not status: if not status:
return res return res
if not res['rows']:
return gone(gettext("The specified table could not be found."))
return super(TableView, self).properties( return super(TableView, self).properties(
gid, sid, did, scid, tid, res gid, sid, did, scid, tid, res
@ -1151,6 +1153,9 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(gettext("The specified table could not be found."))
return super(TableView, self).truncate( return super(TableView, self).truncate(
gid, sid, did, scid, tid, res gid, sid, did, scid, tid, res
) )
@ -1370,6 +1375,9 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
if not status: if not status:
return res return res
if len(res['rows']) == 0:
return gone(gettext("The specified table could not be found."))
data = res['rows'][0] data = res['rows'][0]
return BaseTableView.get_reverse_engineered_sql( return BaseTableView.get_reverse_engineered_sql(
@ -1399,6 +1407,9 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(gettext("The specified table could not be found."))
data = res['rows'][0] data = res['rows'][0]
data = self._formatter(did, scid, tid, data) data = self._formatter(did, scid, tid, data)
@ -1444,6 +1455,9 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(gettext("The specified table could not be found."))
data = res['rows'][0] data = res['rows'][0]
data = self._formatter(did, scid, tid, data) data = self._formatter(did, scid, tid, data)
@ -1492,6 +1506,9 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(gettext("The specified table could not be found."))
data = res['rows'][0] data = res['rows'][0]
data = self._formatter(did, scid, tid, data) data = self._formatter(did, scid, tid, data)
@ -1542,6 +1559,9 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(gettext("The specified table could not be found."))
data = res['rows'][0] data = res['rows'][0]
sql = u"DELETE FROM {0}\n\tWHERE <condition>;".format( sql = u"DELETE FROM {0}\n\tWHERE <condition>;".format(
@ -1588,6 +1608,9 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
data['schema'], data['name'] = \ data['schema'], data['name'] = \
super(TableView, self).get_schema_and_table_name(tid) super(TableView, self).get_schema_and_table_name(tid)
if data['name'] is None:
return gone(gettext("The specified table could not be found."))
SQL = render_template( SQL = render_template(
"/".join( "/".join(
[self.table_template_path, 'get_table_row_count.sql'] [self.table_template_path, 'get_table_row_count.sql']

View File

@ -277,7 +277,6 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
if clid is not None: if clid is not None:
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone( return gone(
@ -398,6 +397,8 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
# Adding parent into data dict, will be using it while creating sql # Adding parent into data dict, will be using it while creating sql
data['schema'] = self.schema data['schema'] = self.schema
data['table'] = self.table data['table'] = self.table
if len(data['table']) == 0:
return gone(gettext("The specified table could not be found."))
# check type for '[]' in it # check type for '[]' in it
data['cltype'], data['hasSqrBracket'] = \ data['cltype'], data['hasSqrBracket'] = \

View File

@ -491,6 +491,10 @@ class CheckConstraintView(PGChildNodeView):
data['schema'] = self.schema data['schema'] = self.schema
data['table'] = self.table data['table'] = self.table
# Checking whether the table is deleted via query tool
if len(data['table']) == 0:
return gone(_("The specified table could not be found."))
try: try:
if 'name' not in data or data['name'] == "": if 'name' not in data or data['name'] == "":
SQL = "BEGIN;" SQL = "BEGIN;"

View File

@ -588,6 +588,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
# Adding parent into data dict, will be using it while creating sql # Adding parent into data dict, will be using it while creating sql
data['schema'] = self.schema data['schema'] = self.schema
data['table'] = self.table data['table'] = self.table
if len(data['table']) == 0:
return gone(gettext("The specified table could not be found."))
try: try:
# Start transaction. # Start transaction.

View File

@ -544,6 +544,8 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
# Adding parent into data dict, will be using it while creating sql # Adding parent into data dict, will be using it while creating sql
data['schema'] = self.schema data['schema'] = self.schema
data['table'] = self.table data['table'] = self.table
if len(data['table']) == 0:
return gone(gettext("The specified object could not be found."))
try: try:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,

View File

@ -19,7 +19,7 @@ from flask_babelex import gettext
from pgadmin.browser.server_groups.servers.databases.schemas\ from pgadmin.browser.server_groups.servers.databases.schemas\
.tables.base_partition_table import BasePartitionTable .tables.base_partition_table import BasePartitionTable
from pgadmin.utils.ajax import make_json_response, internal_server_error, \ from pgadmin.utils.ajax import make_json_response, internal_server_error, \
make_response as ajax_response gone, make_response as ajax_response
from pgadmin.browser.server_groups.servers.databases.schemas.utils \ from pgadmin.browser.server_groups.servers.databases.schemas.utils \
import DataTypeReader, parse_rule_definition import DataTypeReader, parse_rule_definition
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \ from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
@ -657,6 +657,13 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
scid: Schema ID scid: Schema ID
tid: Table ID tid: Table ID
""" """
# checking the table existence using the function of the same class
schema_name, table_name = self.get_schema_and_table_name(tid)
if table_name is None:
return gone(gettext("The specified table could not be found."))
# table exist
try: try:
SQL = render_template("/".join([self.table_template_path, SQL = render_template("/".join([self.table_template_path,
'reset_stats.sql']), 'reset_stats.sql']),
@ -1061,6 +1068,13 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
parent_id: parent table id if current table is partition of parent parent_id: parent table id if current table is partition of parent
table else none table else none
""" """
# checking the table existence using the function of the same class
schema_name, table_name = self.get_schema_and_table_name(tid)
if table_name is None:
return gone(gettext("The specified table could not be found."))
# table exists
try: try:
SQL, name = self.get_sql(did, scid, tid, data, res) SQL, name = self.get_sql(did, scid, tid, data, res)
@ -1478,6 +1492,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
'get_schema_oid.sql']), tid=tid)) 'get_schema_oid.sql']), tid=tid))
if not status: if not status:
return internal_server_error(errormsg=scid) return internal_server_error(errormsg=scid)
if scid is None:
return None, None
# Fetch schema name # Fetch schema name
status, schema_name = self.conn.execute_scalar( status, schema_name = self.conn.execute_scalar(

View File

@ -574,6 +574,9 @@ define('pgadmin.node.database', [
return onSuccess(res, obj, data, tree, item, wasConnected); return onSuccess(res, obj, data, tree, item, wasConnected);
} }
}).fail(function(xhr, status, error) { }).fail(function(xhr, status, error) {
if (xhr.status === 410) {
error = gettext('Error: Object not found - %s.', error);
}
return onFailure( return onFailure(
xhr, status, error, obj, data, tree, item, wasConnected xhr, status, error, obj, data, tree, item, wasConnected
); );

View File

@ -763,7 +763,7 @@ rolmembership:{
) )
) )
if res is None: if res is None or (len(res) == 0):
return gone( return gone(
_("Could not generate reversed engineered query for the role.") _("Could not generate reversed engineered query for the role.")
) )

View File

@ -13,7 +13,7 @@ define(
pgAdmin.Browser = pgAdmin.Browser || {}; pgAdmin.Browser = pgAdmin.Browser || {};
_.extend(pgAdmin.Browser, { _.extend(pgAdmin.Browser, {
report_error: function(title, message, info) { report_error: function(title, message, info, callback) {
title = _.escape(title); title = _.escape(title);
message = _.escape(message); message = _.escape(message);
info = _.escape(info); info = _.escape(info);
@ -49,7 +49,14 @@ define(
alertify.alert( alertify.alert(
title, title,
text text
).set('closable', true); )
.set({'closable': true,
'onok': function() {
if(callback) {
callback();
}
},
});
}, },
}); });

View File

@ -815,7 +815,7 @@ define('pgadmin.browser.node', [
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) { if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try { try {
var data = JSON.parse(jqx.responseText); var data = JSON.parse(jqx.responseText);
msg = data.errormsg; msg = data.info || data.errormsg;
} catch (e) { } catch (e) {
console.warn(e.stack || e); console.warn(e.stack || e);
} }

View File

@ -1,3 +1,4 @@
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// //
// pgAdmin 4 - PostgreSQL Tools // pgAdmin 4 - PostgreSQL Tools

View File

@ -158,41 +158,46 @@ define([
alertify.pgRespErrorNotify = (xhr, error, prefixMsg='') => { alertify.pgRespErrorNotify = (xhr, error, prefixMsg='') => {
var contentType = xhr.getResponseHeader('Content-Type'); var contentType = xhr.getResponseHeader('Content-Type');
try { if (xhr.status === 410) {
if (xhr.status === 0) { const pgBrowser = window.pgAdmin.Browser;
error = gettext('Connection to the server has been lost.'); pgBrowser.report_error(gettext('Error: Object not found - %s.', xhr.statusText), xhr.responseJSON.errormsg);
} else { } else {
if(contentType){ try {
if(contentType.indexOf('application/json') >= 0) { if (xhr.status === 0) {
var resp = JSON.parse(xhr.responseText); error = gettext('Connection to the server has been lost.');
error = _.escape(resp.result) || _.escape(resp.errormsg) || gettext('Unknown error'); } else {
if(contentType){
if(contentType.indexOf('application/json') >= 0) {
var resp = JSON.parse(xhr.responseText);
error = _.escape(resp.result) || _.escape(resp.errormsg) || gettext('Unknown error');
}
}
if (contentType.indexOf('text/html') >= 0) {
var alertMessage = '\
<div class="media text-danger text-14">\
<div class="media-body media-middle">\
<div class="alert-text" role="alert">' + gettext('INTERNAL SERVER ERROR') + '</div><br/>\
<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>\
</div>\
</div>';
alertify.notify(
alertMessage, 'error', 0, () => {
alertify.pgIframeDialog()
.show()
.set({frameless: false})
.set('pg_msg', xhr.responseText);
}
);
return;
} }
} }
if (contentType.indexOf('text/html') >= 0) {
var alertMessage = '\
<div class="media text-danger text-14">\
<div class="media-body media-middle">\
<div class="alert-text" role="alert">' + gettext('INTERNAL SERVER ERROR') + '</div><br/>\
<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>\
</div>\
</div>';
alertify.notify(
alertMessage, 'error', 0, () => {
alertify.pgIframeDialog()
.show()
.set({frameless: false})
.set('pg_msg', xhr.responseText);
}
);
return;
}
} }
catch(e){
error = e.message;
}
alertify.error(prefixMsg +' '+error);
} }
catch(e){
error = e.message;
}
alertify.error(prefixMsg +' '+error);
}; };
var alertifyDialogResized = function(stop) { var alertifyDialogResized = function(stop) {

View File

@ -31,6 +31,7 @@ from pgadmin.utils.exception import ConnectionLost, SSHTunnelConnectionLost
from pgadmin.utils.preferences import Preferences from pgadmin.utils.preferences import Preferences
from pgadmin.settings import get_setting from pgadmin.settings import get_setting
from pgadmin.browser.utils import underscore_unescape from pgadmin.browser.utils import underscore_unescape
from web.pgadmin.utils.exception import ObjectGone
MODULE_NAME = 'datagrid' MODULE_NAME = 'datagrid'
@ -180,6 +181,8 @@ def initialize_datagrid(trans_id, cmd_type, obj_type, sgid, sid, did, obj_id):
did=did, obj_id=obj_id, cmd_type=cmd_type, did=did, obj_id=obj_id, cmd_type=cmd_type,
sql_filter=filter_sql sql_filter=filter_sql
) )
except ObjectGone:
raise
except Exception as e: except Exception as e:
app.logger.error(e) app.logger.error(e)
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
@ -434,6 +437,8 @@ def validate_filter(sid, did, obj_id):
# Call validate_filter method to validate the SQL. # Call validate_filter method to validate the SQL.
status, res = sql_filter_obj.validate_filter(filter_sql) status, res = sql_filter_obj.validate_filter(filter_sql)
except ObjectGone:
raise
except Exception as e: except Exception as e:
app.logger.error(e) app.logger.error(e)
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))

View File

@ -241,10 +241,16 @@ function initFilterDialog(alertify, pgBrowser) {
} }
}) })
.fail(function(e) { .fail(function(e) {
alertify.alert( if (e.status === 410){
gettext('Validation Error'), pgBrowser.report_error(gettext('Error filtering rows - %s.', e.statusText), e.responseJSON.errormsg);
e
); } else {
alertify.alert(
gettext('Validation Error'),
e
);
}
}); });
} else if(closeEvent.index == 0) { } else if(closeEvent.index == 0) {
/* help Button */ /* help Button */

View File

@ -24,7 +24,7 @@ from pgadmin.utils import PgAdminModule, \
ACCESSKEY_FIELDS as accesskey_fields ACCESSKEY_FIELDS as accesskey_fields
from pgadmin.utils.ajax import bad_request from pgadmin.utils.ajax import bad_request
from pgadmin.utils.ajax import make_json_response, \ from pgadmin.utils.ajax import make_json_response, \
internal_server_error internal_server_error, gone
from pgadmin.utils.driver import get_driver from pgadmin.utils.driver import get_driver
from pgadmin.settings import get_setting from pgadmin.settings import get_setting
@ -391,6 +391,9 @@ def init_function(node_type, sid, did, scid, fid, trid=None):
"Error retrieving function information from database") "Error retrieving function information from database")
return internal_server_error(errormsg=r_set) return internal_server_error(errormsg=r_set)
if len(r_set['rows']) == 0:
return gone(
gettext("The specified %s could not be found." % node_type))
ret_status = status ret_status = status
# Check that the function is actually debuggable... # Check that the function is actually debuggable...

View File

@ -21,6 +21,7 @@ from pgadmin.tools.sqleditor.utils.is_query_resultset_updatable \
from pgadmin.tools.sqleditor.utils.save_changed_data import save_changed_data from pgadmin.tools.sqleditor.utils.save_changed_data import save_changed_data
from pgadmin.tools.sqleditor.utils.get_column_types import get_columns_types from pgadmin.tools.sqleditor.utils.get_column_types import get_columns_types
from pgadmin.utils.preferences import Preferences from pgadmin.utils.preferences import Preferences
from web.pgadmin.utils.exception import ObjectGone
from config import PG_DEFAULT_DRIVER from config import PG_DEFAULT_DRIVER
@ -187,6 +188,9 @@ class SQLFilter(object):
status, result = conn.execute_dict(query) status, result = conn.execute_dict(query)
if not status: if not status:
raise Exception(result) raise Exception(result)
if len(result['rows']) == 0:
raise ObjectGone(
gettext("The specified object could not be found."))
self.nsp_name = result['rows'][0]['nspname'] self.nsp_name = result['rows'][0]['nspname']
self.object_name = result['rows'][0]['relname'] self.object_name = result['rows'][0]['relname']

View File

@ -2107,9 +2107,18 @@ define('tools.querytool', [
'pgadmin:query_tool:connected:' + self.transId, res.data 'pgadmin:query_tool:connected:' + self.transId, res.data
); );
}).fail((xhr, status, error)=>{ }).fail((xhr, status, error)=>{
pgBrowser.Events.trigger( if (xhr.status === 410) {
'pgadmin:query_tool:connected_fail:' + self.transId, xhr, error //checking for Query tool in new window.
); if(self.preferences.new_browser_tab) {
pgBrowser.report_error(gettext('Error fetching rows - %s.', xhr.statusText), xhr.responseJSON.errormsg, undefined, window.close);
} else {
pgBrowser.report_error(gettext('Error fetching rows - %s.', xhr.statusText), xhr.responseJSON.errormsg, undefined, self.close.bind(self));
}
} else {
pgBrowser.Events.trigger(
'pgadmin:query_tool:connected_fail:' + self.transId, xhr, error
);
}
}); });
}, },
@ -2316,10 +2325,14 @@ define('tools.querytool', [
msg = httpErrorHandler.handleQueryToolAjaxError( msg = httpErrorHandler.handleQueryToolAjaxError(
pgAdmin, self, jqx, null, [], false pgAdmin, self, jqx, null, [], false
); );
if (msg) if (msg) {
pgBrowser.report_error( if(self.preferences.new_browser_tab) {
gettext('Error fetching SQL for script: %s.', msg) pgBrowser.report_error(gettext('Error fetching SQL for script - %s.', jqx.statusText), jqx.responseJSON.errormsg, undefined, window.close);
); } else {
pgBrowser.report_error(gettext('Error fetching SQL for script - %s.', jqx.statusText), jqx.responseJSON.errormsg, undefined, self.close.bind(self));
}
}
}); });
} }
} }

View File

@ -25,6 +25,7 @@ from pgadmin.model import Server, User
from pgadmin.utils.exception import ConnectionLost, SSHTunnelConnectionLost,\ from pgadmin.utils.exception import ConnectionLost, SSHTunnelConnectionLost,\
CryptKeyMissing CryptKeyMissing
from pgadmin.utils.master_password import get_crypt_key from pgadmin.utils.master_password import get_crypt_key
from pgadmin.utils.exception import ObjectGone
if config.SUPPORT_SSH_TUNNEL: if config.SUPPORT_SSH_TUNNEL:
from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError
@ -209,7 +210,7 @@ WHERE db.oid = {0}""".format(did))
database = self.db_info[did]['datname'] database = self.db_info[did]['datname']
if did not in self.db_info: if did not in self.db_info:
raise Exception(gettext( raise ObjectGone(gettext(
"Could not find the specified database." "Could not find the specified database."
)) ))