public inbox for [email protected]  
help / color / mirror / Atom feed
PATCH: To fix issue in synonym node (pgAdmin4)
6+ messages / 2 participants
[nested] [flat]

* PATCH: To fix issue in synonym node (pgAdmin4)
@ 2016-10-05 08:53 Murtuza Zabuawala <[email protected]>
  2016-10-05 12:08 ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Murtuza Zabuawala @ 2016-10-05 08:53 UTC (permalink / raw)
  To: pgadmin-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


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PATCH: To fix issue in synonym node (pgAdmin4)
  2016-10-05 08:53 PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
@ 2016-10-05 12:08 ` Dave Page <[email protected]>
  2016-10-05 12:28   ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Dave Page @ 2016-10-05 12:08 UTC (permalink / raw)
  To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers

Hi

On Wed, Oct 5, 2016 at 9:53 AM, Murtuza Zabuawala
<[email protected]> wrote:
> 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

That doesn't seem like a reliable way to get the correct parent ID -
what if there are multiple synonyms in different schemas but with the
same name?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PATCH: To fix issue in synonym node (pgAdmin4)
  2016-10-05 08:53 PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
  2016-10-05 12:08 ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
@ 2016-10-05 12:28   ` Murtuza Zabuawala <[email protected]>
  2016-10-05 13:23     ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Murtuza Zabuawala @ 2016-10-05 12:28 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

Hi Dave,

PFA updated patch, Added schema filter in sql.
Please review.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Oct 5, 2016 at 5:38 PM, Dave Page <[email protected]> wrote:

> Hi
>
> On Wed, Oct 5, 2016 at 9:53 AM, Murtuza Zabuawala
> <[email protected]> wrote:
> > 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
>
> That doesn't seem like a reliable way to get the correct parent ID -
> what if there are multiple synonyms in different schemas but with the
> same name?
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: 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_v1.patch (3.6K, 3-RM_1611_v1.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..97df5f5 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']),
+                                  data=data, 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..08f07e0
--- /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,5 @@
+SELECT synnamespace as scid
+    FROM pg_synonym s
+WHERE synname = {{ data.name|qtLiteral }}
+AND synnamespace IN
+    ( SELECT oid FROM pg_namespace WHERE nspname = {{ data.schema|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..08f07e0
--- /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,5 @@
+SELECT synnamespace as scid
+    FROM pg_synonym s
+WHERE synname = {{ data.name|qtLiteral }}
+AND synnamespace IN
+    ( SELECT oid FROM pg_namespace WHERE nspname = {{ data.schema|qtLiteral }} );
\ No newline at end of file


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PATCH: To fix issue in synonym node (pgAdmin4)
  2016-10-05 08:53 PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
  2016-10-05 12:08 ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
  2016-10-05 12:28   ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
@ 2016-10-05 13:23     ` Dave Page <[email protected]>
  2016-10-06 09:42       ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Dave Page @ 2016-10-05 13:23 UTC (permalink / raw)
  To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers

Hi

I created a synonym from within the "dave" schema, but selected
"public" (which wasn't expanded), and it placed the synonym as a
direct child of "public". See the attached screenshot.

On Wed, Oct 5, 2016 at 1:28 PM, Murtuza Zabuawala
<[email protected]> wrote:
> Hi Dave,
>
> PFA updated patch, Added schema filter in sql.
> Please review.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Oct 5, 2016 at 5:38 PM, Dave Page <[email protected]> wrote:
>>
>> Hi
>>
>> On Wed, Oct 5, 2016 at 9:53 AM, Murtuza Zabuawala
>> <[email protected]> wrote:
>> > 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
>>
>> That doesn't seem like a reliable way to get the correct parent ID -
>> what if there are multiple synonyms in different schemas but with the
>> same name?
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

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

  [image/png] Screen Shot 2016-10-05 at 14.21.29.png (44.0K, 2-Screen%20Shot%202016-10-05%20at%2014.21.29.png)
  download | view image

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PATCH: To fix issue in synonym node (pgAdmin4)
  2016-10-05 08:53 PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
  2016-10-05 12:08 ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
  2016-10-05 12:28   ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
  2016-10-05 13:23     ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
@ 2016-10-06 09:42       ` Murtuza Zabuawala <[email protected]>
  2016-10-07 11:08         ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Murtuza Zabuawala @ 2016-10-06 09:42 UTC (permalink / raw)
  To: Dave Page <[email protected]>; +Cc: pgadmin-hackers

Hi Dave,

The issue you mentioned is different issue and not related to synonyms node.
I will create separate ticket & work on it mean while you can commit
changes for RM#1611

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Wed, Oct 5, 2016 at 6:53 PM, Dave Page <[email protected]> wrote:

> Hi
>
> I created a synonym from within the "dave" schema, but selected
> "public" (which wasn't expanded), and it placed the synonym as a
> direct child of "public". See the attached screenshot.
>
> On Wed, Oct 5, 2016 at 1:28 PM, Murtuza Zabuawala
> <[email protected]> wrote:
> > Hi Dave,
> >
> > PFA updated patch, Added schema filter in sql.
> > Please review.
> >
> > --
> > Regards,
> > Murtuza Zabuawala
> > EnterpriseDB: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Wed, Oct 5, 2016 at 5:38 PM, Dave Page <[email protected]> wrote:
> >>
> >> Hi
> >>
> >> On Wed, Oct 5, 2016 at 9:53 AM, Murtuza Zabuawala
> >> <[email protected]> wrote:
> >> > 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
> >>
> >> That doesn't seem like a reliable way to get the correct parent ID -
> >> what if there are multiple synonyms in different schemas but with the
> >> same name?
> >>
> >> --
> >> Dave Page
> >> Blog: http://pgsnake.blogspot.com
> >> Twitter: @pgsnake
> >>
> >> EnterpriseDB UK: http://www.enterprisedb.com
> >> The Enterprise PostgreSQL Company
> >
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: PATCH: To fix issue in synonym node (pgAdmin4)
  2016-10-05 08:53 PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
  2016-10-05 12:08 ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
  2016-10-05 12:28   ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
  2016-10-05 13:23     ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Dave Page <[email protected]>
  2016-10-06 09:42       ` Re: PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
@ 2016-10-07 11:08         ` Dave Page <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Dave Page @ 2016-10-07 11:08 UTC (permalink / raw)
  To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Thu, Oct 6, 2016 at 10:42 AM, Murtuza Zabuawala
<[email protected]> wrote:
> Hi Dave,
>
> The issue you mentioned is different issue and not related to synonyms node.
> I will create separate ticket & work on it mean while you can commit changes
> for RM#1611
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Oct 5, 2016 at 6:53 PM, Dave Page <[email protected]> wrote:
>>
>> Hi
>>
>> I created a synonym from within the "dave" schema, but selected
>> "public" (which wasn't expanded), and it placed the synonym as a
>> direct child of "public". See the attached screenshot.
>>
>> On Wed, Oct 5, 2016 at 1:28 PM, Murtuza Zabuawala
>> <[email protected]> wrote:
>> > Hi Dave,
>> >
>> > PFA updated patch, Added schema filter in sql.
>> > Please review.
>> >
>> > --
>> > Regards,
>> > Murtuza Zabuawala
>> > EnterpriseDB: http://www.enterprisedb.com
>> > The Enterprise PostgreSQL Company
>> >
>> > On Wed, Oct 5, 2016 at 5:38 PM, Dave Page <[email protected]> wrote:
>> >>
>> >> Hi
>> >>
>> >> On Wed, Oct 5, 2016 at 9:53 AM, Murtuza Zabuawala
>> >> <[email protected]> wrote:
>> >> > 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
>> >>
>> >> That doesn't seem like a reliable way to get the correct parent ID -
>> >> what if there are multiple synonyms in different schemas but with the
>> >> same name?
>> >>
>> >> --
>> >> Dave Page
>> >> Blog: http://pgsnake.blogspot.com
>> >> Twitter: @pgsnake
>> >>
>> >> EnterpriseDB UK: http://www.enterprisedb.com
>> >> The Enterprise PostgreSQL Company
>> >
>> >
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

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




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2016-10-07 11:08 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-10-05 08:53 PATCH: To fix issue in synonym node (pgAdmin4) Murtuza Zabuawala <[email protected]>
2016-10-05 12:08 ` Dave Page <[email protected]>
2016-10-05 12:28   ` Murtuza Zabuawala <[email protected]>
2016-10-05 13:23     ` Dave Page <[email protected]>
2016-10-06 09:42       ` Murtuza Zabuawala <[email protected]>
2016-10-07 11:08         ` Dave Page <[email protected]>

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