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,6 +334,16 @@ class SynonymView(PGChildNodeView):
except ValueError:
data[k] = v
is_valid_request = True
if 'trgTyp' not in data or data['trgTyp'] is None or \
data['trgTyp'].strip() == '':
is_valid_request = False
if 'trgSchema' not in data or data['trgSchema'] is None or \
data['trgSchema'].strip() == '':
is_valid_request = False
if is_valid_request:
sql = render_template("/".join([self.template_path,
'get_objects.sql']),
trgTyp=data['trgTyp'],
@ -384,14 +394,8 @@ class SynonymView(PGChildNodeView):
status=200
)
else:
return make_json_response(
success=410,
errormsg=gettext(
'Error: Object not found.'
),
info=gettext(
'The specified synonym could not be found.\n'
)
return gone(
gettext('The specified synonym could not be found.')
)
except Exception as e:
@ -483,14 +487,8 @@ class SynonymView(PGChildNodeView):
if len(res['rows']) > 0:
data = res['rows'][0]
else:
return make_json_response(
success=0,
errormsg=gettext(
'Error: Object not found.'
),
info=gettext(
'The specified synonym could not be found.\n'
)
return gone(
gettext('The specified synonym could not be found.')
)
SQL = render_template("/".join([self.template_path,
@ -646,14 +644,8 @@ class SynonymView(PGChildNodeView):
if len(res['rows']) > 0:
data = res['rows'][0]
else:
return make_json_response(
success=0,
errormsg=gettext(
'Error: Object not found.'
),
info=gettext(
'The specified synonym could not be found.\n'
)
return gone(
gettext('The specified synonym could not be found.')
)
SQL = render_template("/".join([self.template_path,