public inbox for [email protected]  
help / color / mirror / Atom feed
From: Murtuza Zabuawala <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: PATCH: To fix issue in synonym node (pgAdmin4)
Date: Wed, 5 Oct 2016 14:23:26 +0530
Message-ID: <CAKKotZT8huV=9w7vy_8MWyUa1J6GCJ3-830HbB3LJeQVGJT3-A@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi,

PFA patch to fix the issue in synonym node, where it was not horning parent
node while creating in different node, issue was that we were not sending
node properly.
RM#1611

Please review.

--
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:

  [application/octet-stream] RM_1611.patch (3.4K, 3-RM_1611.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
index 95e58b6..630ff56 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py
@@ -391,10 +391,18 @@ class SynonymView(PGChildNodeView):
             if not status:
                 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']),
+                                  name=data['name'], conn=self.conn)
+            status, parent_id = self.conn.execute_scalar(SQL)
+            if not status:
+                return internal_server_error(errormsg=res)
+
             return jsonify(
                 node=self.blueprint.generate_browser_node(
                     data['name'],
-                    scid,
+                    int(parent_id),
                     data['name'],
                     icon="icon-synonym"
                 )
@@ -483,25 +491,14 @@ class SynonymView(PGChildNodeView):
                 if not status:
                     return internal_server_error(errormsg=res)
 
-                return make_json_response(
-                    success=1,
-                    info="Synonym updated",
-                    data={
-                        'id': syid,
-                        'scid': scid,
-                        'did': did
-                    }
-                )
-            else:
-                return make_json_response(
-                    success=1,
-                    info="Nothing to update",
-                    data={
-                        'id': syid,
-                        'scid': scid,
-                        'did': did
-                    }
+            return jsonify(
+                node=self.blueprint.generate_browser_node(
+                    syid,
+                    scid,
+                    syid,
+                    icon="icon-synonym"
                 )
+            )
 
         except Exception as e:
             return internal_server_error(errormsg=str(e))
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.1_plus/get_parent_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.1_plus/get_parent_oid.sql
new file mode 100644
index 0000000..3246940
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.1_plus/get_parent_oid.sql
@@ -0,0 +1,3 @@
+SELECT synnamespace as scid
+    FROM pg_synonym s
+WHERE synname = {{ name|qtLiteral }};
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/get_parent_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/get_parent_oid.sql
new file mode 100644
index 0000000..3246940
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/get_parent_oid.sql
@@ -0,0 +1,3 @@
+SELECT synnamespace as scid
+    FROM pg_synonym s
+WHERE synname = {{ name|qtLiteral }};
\ No newline at end of file


view thread (6+ 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 issue in synonym node (pgAdmin4)
  In-Reply-To: <CAKKotZT8huV=9w7vy_8MWyUa1J6GCJ3-830HbB3LJeQVGJT3-A@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