Handle missing/dropped synonyms gracefully. Fixes #2503

This commit is contained in:
Murtuza Zabuawala 2017-06-21 16:59:43 +01:00 committed by Dave Page
parent 5cfa22cf23
commit b9736cbd74

View File

@ -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,