public inbox for [email protected]  
help / color / mirror / Atom feed
From: Murtuza Zabuawala <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: PATCH: To fix the issue on Table collection node refresh (pgAdmin4)
Date: Tue, 13 Sep 2016 13:28:23 +0530
Message-ID: <CAKKotZQwk0w_cxacMgXG3bKf1F3ufH=f1-i1UHqA+XukM8_rSQ@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

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


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [text/x-patch] RM_1686.patch (4.0K, 3-RM_1686.patch)
  download | inline diff:
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;


  [text/x-patch] misc_typo_fix.patch (821B, 4-misc_typo_fix.patch)
  download | inline diff:
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,


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: PATCH: To fix the issue on Table collection node refresh (pgAdmin4)
  In-Reply-To: <CAKKotZQwk0w_cxacMgXG3bKf1F3ufH=f1-i1UHqA+XukM8_rSQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox