public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch]: Fixed RM 2381 - "Create Script" for view assigns incorrect schema to trigger functions in "public" schema.
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch]: Fixed RM 2381 - "Create Script" for view assigns incorrect schema to trigger functions in "public" schema.
@ 2017-06-05 10:26  Khushboo Vashi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Khushboo Vashi @ 2017-06-05 10:26 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

Please find the attached patch to fix RM 2381: "Create Script" for view
assigns incorrect schema to trigger functions in "public" schema.

Fixed the trigger function schema name in the view SQL tab.


Thanks,
Khushboo


-- 
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_2381.patch (1.9K, 3-RM_2381.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
index 836018b..17a7df6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
@@ -896,15 +896,26 @@ class ViewNode(PGChildNodeView, VacuumSettings):
                     trigger['oid'], columns)
             res_rows = trigger_definition(res_rows)
 
-            res_rows['schema'] = res_rows['nspname']
-
             # It should be relname and not table, but in create.sql
             # (which is referred from many places) we have used
             # data.table and not data.relname so compatibility add new key as
             # table in res_rows.
             res_rows['table'] = res_rows['relname']
 
-            res_rows['tfunction'] = self.qtIdent(self.conn, res_rows['schema'], res_rows['tfunction'])
+            # Get trigger function with its schema name
+            SQL = render_template("/".join([self.trigger_temp_path,
+                                            'sql/#{0}#/get_triggerfunctions.sql'.format(self.manager.version)]),
+                                  tgfoid=res_rows['tgfoid'],
+                                  show_system_objects=self.blueprint.show_system_objects)
+
+            status, result = self.conn.execute_dict(SQL)
+            if not status:
+                return internal_server_error(errormsg=result)
+
+            # Update the trigger function which we have fetched with schema name
+            if 'rows' in result and len(result['rows']) > 0 and \
+                            'tfunctions' in result['rows'][0]:
+                res_rows['tfunction'] = result['rows'][0]['tfunctions']
 
             # Format arguments
             if len(res_rows['custom_tgargs']) > 1:


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

* Re: [pgAdmin4][Patch]: Fixed RM 2381 - "Create Script" for view assigns incorrect schema to trigger functions in "public" schema.
@ 2017-06-07 12:40  Dave Page <[email protected]>
  parent: Khushboo Vashi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Page @ 2017-06-07 12:40 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Mon, Jun 5, 2017 at 11:26 AM, Khushboo Vashi
<[email protected]> wrote:
> Hi,
>
> Please find the attached patch to fix RM 2381: "Create Script" for view
> assigns incorrect schema to trigger functions in "public" schema.
>
> Fixed the trigger function schema name in the view SQL tab.
>
>
> Thanks,
> Khushboo
>
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>



-- 
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] 2+ messages in thread


end of thread, other threads:[~2017-06-07 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 10:26 [pgAdmin4][Patch]: Fixed RM 2381 - "Create Script" for view assigns incorrect schema to trigger functions in "public" schema. Khushboo Vashi <[email protected]>
2017-06-07 12:40 ` 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