mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-30 20:43:50 -06:00
Handle missing/dropped synonyms gracefully. Fixes #2503
This commit is contained in:
parent
5cfa22cf23
commit
b9736cbd74
@ -334,18 +334,28 @@ class SynonymView(PGChildNodeView):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
data[k] = v
|
data[k] = v
|
||||||
|
|
||||||
sql = render_template("/".join([self.template_path,
|
is_valid_request = True
|
||||||
'get_objects.sql']),
|
if 'trgTyp' not in data or data['trgTyp'] is None or \
|
||||||
trgTyp=data['trgTyp'],
|
data['trgTyp'].strip() == '':
|
||||||
trgSchema=data['trgSchema'])
|
is_valid_request = False
|
||||||
status, rset = self.conn.execute_dict(sql)
|
|
||||||
|
|
||||||
if not status:
|
if 'trgSchema' not in data or data['trgSchema'] is None or \
|
||||||
return internal_server_error(errormsg=rset)
|
data['trgSchema'].strip() == '':
|
||||||
|
is_valid_request = False
|
||||||
|
|
||||||
for row in rset['rows']:
|
if is_valid_request:
|
||||||
res.append({'label': row['name'],
|
sql = render_template("/".join([self.template_path,
|
||||||
'value': row['name']})
|
'get_objects.sql']),
|
||||||
|
trgTyp=data['trgTyp'],
|
||||||
|
trgSchema=data['trgSchema'])
|
||||||
|
status, rset = self.conn.execute_dict(sql)
|
||||||
|
|
||||||
|
if not status:
|
||||||
|
return internal_server_error(errormsg=rset)
|
||||||
|
|
||||||
|
for row in rset['rows']:
|
||||||
|
res.append({'label': row['name'],
|
||||||
|
'value': row['name']})
|
||||||
|
|
||||||
return make_json_response(
|
return make_json_response(
|
||||||
data=res,
|
data=res,
|
||||||
@ -384,14 +394,8 @@ class SynonymView(PGChildNodeView):
|
|||||||
status=200
|
status=200
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return make_json_response(
|
return gone(
|
||||||
success=410,
|
gettext('The specified synonym could not be found.')
|
||||||
errormsg=gettext(
|
|
||||||
'Error: Object not found.'
|
|
||||||
),
|
|
||||||
info=gettext(
|
|
||||||
'The specified synonym could not be found.\n'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -483,14 +487,8 @@ class SynonymView(PGChildNodeView):
|
|||||||
if len(res['rows']) > 0:
|
if len(res['rows']) > 0:
|
||||||
data = res['rows'][0]
|
data = res['rows'][0]
|
||||||
else:
|
else:
|
||||||
return make_json_response(
|
return gone(
|
||||||
success=0,
|
gettext('The specified synonym could not be found.')
|
||||||
errormsg=gettext(
|
|
||||||
'Error: Object not found.'
|
|
||||||
),
|
|
||||||
info=gettext(
|
|
||||||
'The specified synonym could not be found.\n'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SQL = render_template("/".join([self.template_path,
|
SQL = render_template("/".join([self.template_path,
|
||||||
@ -646,14 +644,8 @@ class SynonymView(PGChildNodeView):
|
|||||||
if len(res['rows']) > 0:
|
if len(res['rows']) > 0:
|
||||||
data = res['rows'][0]
|
data = res['rows'][0]
|
||||||
else:
|
else:
|
||||||
return make_json_response(
|
return gone(
|
||||||
success=0,
|
gettext('The specified synonym could not be found.')
|
||||||
errormsg=gettext(
|
|
||||||
'Error: Object not found.'
|
|
||||||
),
|
|
||||||
info=gettext(
|
|
||||||
'The specified synonym could not be found.\n'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SQL = render_template("/".join([self.template_path,
|
SQL = render_template("/".join([self.template_path,
|
||||||
|
Loading…
Reference in New Issue
Block a user