mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix refresh of Synonyms. Fixes #1611
This commit is contained in:
parent
a0aaa80029
commit
c931d715ac
@ -391,10 +391,18 @@ class SynonymView(PGChildNodeView):
|
|||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=res)
|
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(
|
return jsonify(
|
||||||
node=self.blueprint.generate_browser_node(
|
node=self.blueprint.generate_browser_node(
|
||||||
data['name'],
|
data['name'],
|
||||||
scid,
|
int(parent_id),
|
||||||
data['name'],
|
data['name'],
|
||||||
icon="icon-synonym"
|
icon="icon-synonym"
|
||||||
)
|
)
|
||||||
@ -483,25 +491,14 @@ class SynonymView(PGChildNodeView):
|
|||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
|
||||||
return make_json_response(
|
return jsonify(
|
||||||
success=1,
|
node=self.blueprint.generate_browser_node(
|
||||||
info="Synonym updated",
|
syid,
|
||||||
data={
|
scid,
|
||||||
'id': syid,
|
syid,
|
||||||
'scid': scid,
|
icon="icon-synonym"
|
||||||
'did': did
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
return make_json_response(
|
|
||||||
success=1,
|
|
||||||
info="Nothing to update",
|
|
||||||
data={
|
|
||||||
'id': syid,
|
|
||||||
'scid': scid,
|
|
||||||
'did': did
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return internal_server_error(errormsg=str(e))
|
return internal_server_error(errormsg=str(e))
|
||||||
|
@ -96,13 +96,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||||||
select2: { width: "50%", allowClear: false },
|
select2: { width: "50%", allowClear: false },
|
||||||
options: function(obj) {
|
options: function(obj) {
|
||||||
return [
|
return [
|
||||||
{label: "Table", value: "r"},
|
{label: "{{ _('Function') }}", value: "f"},
|
||||||
{label: "Sequence", value: "S"},
|
{label: "{{ _('Package') }}", value: "P"},
|
||||||
{label: "View", value: "v"},
|
{label: "{{ _('Procedure') }}", value: "p"},
|
||||||
{label: "Function", value: "f"},
|
{label: "{{ _('Public Synonym') }}", value: "s"},
|
||||||
{label: "Procedure", value: "p"},
|
{label: "{{ _('Sequence') }}", value: "S"},
|
||||||
{label: "Package", value: "P"},
|
{label: "{{ _('Table') }}", value: "r"},
|
||||||
{label: "Public Synonym", value: "s"}
|
{label: "{{ _('View') }}", value: "v"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
control: 'select2'
|
control: 'select2'
|
||||||
|
@ -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 }} );
|
@ -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 }} );
|
Loading…
Reference in New Issue
Block a user