Resolve issue with properties refreshing. Fixes #1728

1) If we create/update a node with non-default schema, It should return selected schema id in return response. but default schema id is returned every time due to which it throws error in properties panel.
Fixed in Domains, Collation, Types, Views & Table node.

2) Incorrect parent id of object node is returned from nodes method due to which wrong parent id is passed while updating object and
thus node didn't get refreshed.
Fixed in FTS Configuration, FTS Parser nodes.
This commit is contained in:
Surinder Kumar 2016-10-14 12:19:00 -07:00 committed by Dave Page
parent 404d4efd2e
commit 0df968f679
13 changed files with 84 additions and 17 deletions

View File

@ -443,6 +443,13 @@ class CollationView(PGChildNodeView):
if not status: if not status:
return internal_server_error(errormsg=coid) return internal_server_error(errormsg=coid)
# Get updated schema oid
SQL = render_template("/".join([self.template_path,
'get_oid.sql']), coid=coid)
status, scid = self.conn.execute_scalar(SQL)
if not status:
return internal_server_error(errormsg=coid)
return jsonify( return jsonify(
node=self.blueprint.generate_browser_node( node=self.blueprint.generate_browser_node(
coid, coid,

View File

@ -546,6 +546,14 @@ AND relkind != 'c'))"""
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
# Get updated schema oid
SQL = render_template("/".join([self.template_path,
'get_oid.sql']),
doid=doid)
status, scid = 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(
doid, doid,
@ -640,12 +648,10 @@ AND relkind != 'c'))"""
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), 'get_oid.sql']),
doid=doid) doid=doid)
status, res = self.conn.execute_2darray(SQL) status, scid = self.conn.execute_scalar(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
scid = res['rows'][0]['scid']
return jsonify( return jsonify(
node=self.blueprint.generate_browser_node( node=self.blueprint.generate_browser_node(
doid, doid,

View File

@ -286,7 +286,7 @@ class FtsConfigurationView(PGChildNodeView):
res.append( res.append(
self.blueprint.generate_browser_node( self.blueprint.generate_browser_node(
row['oid'], row['oid'],
did, scid,
row['name'], row['name'],
icon="icon-fts_configuration" icon="icon-fts_configuration"
)) ))

View File

@ -256,7 +256,7 @@ class FtsParserView(PGChildNodeView):
res.append( res.append(
self.blueprint.generate_browser_node( self.blueprint.generate_browser_node(
row['oid'], row['oid'],
did, scid,
row['name'], row['name'],
icon="icon-fts_parser" icon="icon-fts_parser"
)) ))

View File

@ -0,0 +1,7 @@
{# ===== fetch new assigned schema id ===== #}
SELECT
c.relnamespace as scid
FROM
pg_class c
WHERE
c.oid = {{syid|qtLiteral}}::oid;

View File

@ -1442,9 +1442,17 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
# Get updated schema oid
SQL = render_template("/".join([self.template_path,
'get_schema_oid.sql']), tname=data['name'])
status, scid = self.conn.execute_scalar(SQL)
if not status:
return internal_server_error(errormsg=scid)
# we need oid to to add object in tree at browser # we need oid to to add object in tree at browser
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), scid=scid, data=data) 'get_oid.sql']), scid=scid, data=data)
status, tid = self.conn.execute_scalar(SQL) status, tid = self.conn.execute_scalar(SQL)
if not status: if not status:
return internal_server_error(errormsg=tid) return internal_server_error(errormsg=tid)

View File

@ -1,9 +1,11 @@
{# ===== fetch new assigned schema oid ===== #} {# ===== fetch new assigned schema oid ===== #}
{% if tid %}
SELECT SELECT
c.relnamespace as scid c.relnamespace as scid
FROM FROM
pg_class c pg_class c
WHERE WHERE
{% if tid %}
c.oid = {{tid}}::oid; c.oid = {{tid}}::oid;
{% else %}
c.relname = {{tname|qtLiteral}}::text;
{% endif %} {% endif %}

View File

@ -1,9 +1,11 @@
{# ===== fetch new assigned schema oid ===== #} {# ===== fetch new assigned schema oid ===== #}
{% if tid %}
SELECT SELECT
c.relnamespace as scid c.relnamespace as scid
FROM FROM
pg_class c pg_class c
WHERE WHERE
{% if tid %}
c.oid = {{tid}}::oid; c.oid = {{tid}}::oid;
{% else %}
c.relname = {{tname|qtLiteral}}::text;
{% endif %} {% endif %}

View File

@ -902,10 +902,17 @@ class TypeView(PGChildNodeView, DataTypeReader):
try: try:
SQL = render_template("/".join([self.template_path, 'create.sql']), SQL = render_template("/".join([self.template_path, 'create.sql']),
data=data, conn=self.conn) data=data, conn=self.conn)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
# we need scid to update in browser tree
SQL = render_template("/".join([self.template_path,
'get_scid.sql']), tname=data['name'])
status, scid = self.conn.execute_scalar(SQL)
if not status:
return internal_server_error(errormsg=scid)
# we need oid to to add object in tree at browser # we need oid to to add object in tree at browser
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), 'get_oid.sql']),
@ -948,6 +955,14 @@ class TypeView(PGChildNodeView, DataTypeReader):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
SQL = render_template("/".join([self.template_path,
'get_scid.sql']), tname=data['name'])
# Get updated schema oid
status, scid = 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(
tid, tid,

View File

@ -8,4 +8,4 @@ WHERE t.typtype != 'd' AND t.typname NOT LIKE E'\\_%' AND t.typnamespace = {{sci
{% if data %} {% if data %}
AND t.typname = {{data.name|qtLiteral}} AND t.typname = {{data.name|qtLiteral}}
{% endif %} {% endif %}
ORDER BY t.typname; ORDER BY t.typname;

View File

@ -0,0 +1,6 @@
SELECT
t.typnamespace as scid
FROM
pg_type t
WHERE
t.typname = {{tname|qtLiteral}}::text;

View File

@ -487,12 +487,24 @@ class ViewNode(PGChildNodeView, VacuumSettings):
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'sql/view_id.sql']), data=data) [self.template_path, 'sql/view_id.sql']), data=data)
status, view_id = self.conn.execute_scalar(SQL) status, view_id = self.conn.execute_scalar(SQL)
if not status:
return internal_server_error(errormsg=res)
# Get updated schema oid
SQL = render_template("/".join(
[self.template_path, 'sql/get_oid.sql']), vid=view_id)
status, scid = 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(
view_id, view_id,
scid, scid,
data['name'], data['name'],
icon="icon-%s" % self.node_type icon="icon-view"
) )
) )
except Exception as e: except Exception as e:
@ -525,15 +537,13 @@ class ViewNode(PGChildNodeView, VacuumSettings):
view_id = res_data['rows'][0]['oid'] view_id = res_data['rows'][0]['oid']
new_view_name = res_data['rows'][0]['relname'] new_view_name = res_data['rows'][0]['relname']
# Get updated schema oid
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'sql/get_oid.sql']), vid=view_id) [self.template_path, 'sql/get_oid.sql']), vid=view_id)
status, res = self.conn.execute_2darray(SQL) status, scid = self.conn.execute_scalar(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
# new schema id
scid = res['rows'][0]['scid']
return jsonify( return jsonify(
node=self.blueprint.generate_browser_node( node=self.blueprint.generate_browser_node(
view_id, view_id,

View File

@ -1148,7 +1148,8 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
if ( if (
this.i && this.d && this.new._type == this.d._type this.i && this.d && this.new._type == this.d._type
) { ) {
var _id = this.d._id; var self = this,
_id = this.d._id;
if (this.new._id != this.d._id) { if (this.new._id != this.d._id) {
// Found the new oid, update its node_id // Found the new oid, update its node_id
var node_data = this.t.itemData(ctx.i); var node_data = this.t.itemData(ctx.i);
@ -1162,7 +1163,10 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
this.t.setId(ctx.id, {id: this.new.id}); this.t.setId(ctx.id, {id: this.new.id});
this.t.openPath(this.i); this.t.openPath(this.i);
this.t.deselect(this.i); this.t.deselect(this.i);
this.t.select(this.i); // select tree item after few milliseconds
setTimeout(function() {
self.t.select(self.i);
}, 10);
} }
} }
var success = this.o && this.o.success; var success = this.o && this.o.success;