Fixes issues specific to SYNONYMS

- On droping a synonyms - the query should be modified in SQL pane.
- A proper message should be given on trying to drop an already dropped
  synonyms.
- Handle the synonyms with special characters.

Fixes #1607, #1608, #1609
This commit is contained in:
Murtuza Zabuawala
2016-08-29 20:25:11 +05:30
committed by Ashesh Vashi
parent b6f307256b
commit 689ef8d8d1
3 changed files with 38 additions and 12 deletions

View File

@@ -332,10 +332,21 @@ class SynonymView(PGChildNodeView):
if not status:
return internal_server_error(errormsg=res)
return ajax_response(
response=res['rows'][0],
status=200
)
if len(res['rows']) > 0:
return ajax_response(
response=res['rows'][0],
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'
)
)
except Exception as e:
return internal_server_error(errormsg=str(e))
@@ -414,9 +425,9 @@ class SynonymView(PGChildNodeView):
if not status:
return internal_server_error(errormsg=res)
data = res['rows'][0]
if data['name'] is None:
if len(res['rows']) > 0:
data = res['rows'][0]
else:
return make_json_response(
success=0,
errormsg=gettext(
@@ -578,7 +589,18 @@ class SynonymView(PGChildNodeView):
if not status:
return internal_server_error(errormsg=res)
data = res['rows'][0]
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'
)
)
SQL = render_template("/".join([self.template_path,
'create.sql']),

View File

@@ -3,9 +3,13 @@
{% set is_public = True %}
{% endif %}
{% if comment %}
-- {% if is_public %}Public{% else %}Private{% endif %} synonym: {{ conn|qtIdent(data.schema, data.name) }};
-- {% if is_public %}Public{% else %}Private{% endif %} synonym: {% if is_public %}{{ conn|qtIdent(data.name) }};
{% else %}{{ conn|qtIdent(data.schema, data.name) }};
{% endif %}
-- DROP {% if is_public %}PUBLIC {% endif %}SYNONYM {{ conn|qtIdent(data.schema, data.name) }};
-- DROP {% if is_public %}PUBLIC {% endif %}SYNONYM {% if is_public %}{{ conn|qtIdent(data.name) }};
{% else %}{{ conn|qtIdent(data.schema, data.name) }};
{% endif %}
{% endif %}
CREATE OR REPLACE {% if is_public %}