Hi,

PFA patch to fix the issue where user tries to refresh on Table collection
node it was throwing error.
RM#1686

Issue: Nodes method was not implemented properly to handle such request in
Table node.

Also attaching a separate patch for typo in browser.js file due to which
this error was displaying on console and not on GUI.

@Ashesh, Would you please review this minor patch (File:
misc_typo_fix.patch), I hope it does not affect anything else :)


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index 82c343d..040afb8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -23,7 +23,7 @@ from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
     parse_priv_to_db
 from pgadmin.browser.utils import PGChildNodeView
 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 config import PG_DEFAULT_DRIVER
@@ -350,6 +350,46 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
         )
 
     @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
     def nodes(self, gid, sid, did, scid):
         """
         This function is used to list all the table nodes within that collection.
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/nodes.sql
index 43f14cb..409247c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/nodes.sql
@@ -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
 FROM pg_class rel
     WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
-    ORDER BY rel.relname;
\ No newline at end of file
+    {% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
+    ORDER BY rel.relname;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/nodes.sql
index 43f14cb..409247c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/nodes.sql
@@ -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
 FROM pg_class rel
     WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
-    ORDER BY rel.relname;
\ No newline at end of file
+    {% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
+    ORDER BY rel.relname;
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 7a202e8..b91eefd 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -1430,10 +1430,10 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
                   success();
                 }
               },
-              error: function(jqx, error, status) {
+              error: function(xhr, error, status) {
                 if (
                   !Alertify.pgHandleItemError(
-                    xhr, error, message, {item: _i, info: info}
+                    xhr, error, status, {item: _i, info: info}
                   )
                 ) {
                   var msg = xhr.responseText,
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to