mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix error when refreshing table node. Fixes #1686
This commit is contained in:
parent
d848e9cefe
commit
071b609a44
@ -23,7 +23,7 @@ from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
|
|||||||
parse_priv_to_db
|
parse_priv_to_db
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
from pgadmin.browser.utils import PGChildNodeView
|
||||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||||
make_response as ajax_response
|
make_response as ajax_response, gone
|
||||||
from pgadmin.utils.driver import get_driver
|
from pgadmin.utils.driver import get_driver
|
||||||
|
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
@ -349,6 +349,46 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
|||||||
status=200
|
status=200
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@check_precondition
|
||||||
|
def node(self, gid, sid, did, scid, tid):
|
||||||
|
"""
|
||||||
|
This function is used to list all the table nodes within that collection.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
gid: Server group ID
|
||||||
|
sid: Server ID
|
||||||
|
did: Database ID
|
||||||
|
scid: Schema ID
|
||||||
|
tid: Table ID
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
JSON of available table nodes
|
||||||
|
"""
|
||||||
|
res = []
|
||||||
|
SQL = render_template("/".join([self.template_path,
|
||||||
|
'nodes.sql']),
|
||||||
|
scid=scid, tid=tid)
|
||||||
|
status, rset = self.conn.execute_2darray(SQL)
|
||||||
|
if not status:
|
||||||
|
return internal_server_error(errormsg=rset)
|
||||||
|
if len(rset['rows']) == 0:
|
||||||
|
return gone(gettext("Could not find the table."))
|
||||||
|
|
||||||
|
res = self.blueprint.generate_browser_node(
|
||||||
|
rset['rows'][0]['oid'],
|
||||||
|
scid,
|
||||||
|
rset['rows'][0]['name'],
|
||||||
|
icon="icon-table",
|
||||||
|
tigger_count=rset['rows'][0]['triggercount'],
|
||||||
|
has_enable_triggers=rset['rows'][0]['has_enable_triggers']
|
||||||
|
)
|
||||||
|
|
||||||
|
return make_json_response(
|
||||||
|
data=res,
|
||||||
|
status=200
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@check_precondition
|
@check_precondition
|
||||||
def nodes(self, gid, sid, did, scid):
|
def nodes(self, gid, sid, did, scid):
|
||||||
"""
|
"""
|
||||||
|
@ -3,4 +3,5 @@ SELECT rel.oid, rel.relname AS name,
|
|||||||
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers
|
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers
|
||||||
FROM pg_class rel
|
FROM pg_class rel
|
||||||
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
|
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
|
||||||
|
{% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
|
||||||
ORDER BY rel.relname;
|
ORDER BY rel.relname;
|
@ -3,4 +3,5 @@ SELECT rel.oid, rel.relname AS name,
|
|||||||
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers
|
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers
|
||||||
FROM pg_class rel
|
FROM pg_class rel
|
||||||
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
|
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
|
||||||
|
{% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
|
||||||
ORDER BY rel.relname;
|
ORDER BY rel.relname;
|
Loading…
Reference in New Issue
Block a user