Fix refresh of Synonyms. Fixes #1611

This commit is contained in:
Murtuza Zabuawala 2016-10-07 12:08:19 +01:00 committed by Dave Page
parent a0aaa80029
commit c931d715ac
4 changed files with 33 additions and 26 deletions

View File

@ -391,10 +391,18 @@ class SynonymView(PGChildNodeView):
if not status:
return internal_server_error(errormsg=res)
# Find parent oid to add properly in tree browser
SQL = render_template("/".join([self.template_path,
'get_parent_oid.sql']),
data=data, conn=self.conn)
status, parent_id = self.conn.execute_scalar(SQL)
if not status:
return internal_server_error(errormsg=res)
return jsonify(
node=self.blueprint.generate_browser_node(
data['name'],
scid,
int(parent_id),
data['name'],
icon="icon-synonym"
)
@ -483,24 +491,13 @@ class SynonymView(PGChildNodeView):
if not status:
return internal_server_error(errormsg=res)
return make_json_response(
success=1,
info="Synonym updated",
data={
'id': syid,
'scid': scid,
'did': did
}
return jsonify(
node=self.blueprint.generate_browser_node(
syid,
scid,
syid,
icon="icon-synonym"
)
else:
return make_json_response(
success=1,
info="Nothing to update",
data={
'id': syid,
'scid': scid,
'did': did
}
)
except Exception as e:

View File

@ -96,13 +96,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
select2: { width: "50%", allowClear: false },
options: function(obj) {
return [
{label: "Table", value: "r"},
{label: "Sequence", value: "S"},
{label: "View", value: "v"},
{label: "Function", value: "f"},
{label: "Procedure", value: "p"},
{label: "Package", value: "P"},
{label: "Public Synonym", value: "s"}
{label: "{{ _('Function') }}", value: "f"},
{label: "{{ _('Package') }}", value: "P"},
{label: "{{ _('Procedure') }}", value: "p"},
{label: "{{ _('Public Synonym') }}", value: "s"},
{label: "{{ _('Sequence') }}", value: "S"},
{label: "{{ _('Table') }}", value: "r"},
{label: "{{ _('View') }}", value: "v"}
]
},
control: 'select2'

View File

@ -0,0 +1,5 @@
SELECT synnamespace as scid
FROM pg_synonym s
WHERE synname = {{ data.name|qtLiteral }}
AND synnamespace IN
( SELECT oid FROM pg_namespace WHERE nspname = {{ data.schema|qtLiteral }} );

View File

@ -0,0 +1,5 @@
SELECT synnamespace as scid
FROM pg_synonym s
WHERE synname = {{ data.name|qtLiteral }}
AND synnamespace IN
( SELECT oid FROM pg_namespace WHERE nspname = {{ data.schema|qtLiteral }} );