Subject: [pgAdmin4][PATCH] To fix the spacing issue in SQL for Event trigger

From: Murtuza Zabuawala <[email-masked]>
Date: Fri, 2 Jun 2017 10:43:02 +0530

Hi,

PFA minor patch to fix the issue of extra spacing in generated SQL in Event
trigger.
RM#1229

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
index 671b6f4..e574d7a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
@@ -548,6 +548,7 @@ class EventTriggerView(PGChildNodeView):
             if not isinstance(sql, (str, unicode)):
                 return sql
             sql = sql.strip('\n').strip(' ')
+            sql = re.sub('\n{2,}', '\n\n', sql)
             if sql == '':
                 sql = "--modified SQL"
             return make_json_response(
@@ -661,6 +662,7 @@ class EventTriggerView(PGChildNodeView):
         sql_header += "\n"
 
         sql = sql_header + sql
+        sql = re.sub('\n{2,}', '\n\n', sql)
 
         return ajax_response(response=sql)
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js
index 1291cfb..a5e5d21 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js
@@ -58,10 +58,10 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
           name: undefined,
           eventowner: undefined,
           comment: undefined,
-          enabled: undefined,
+          enabled: "O",
           eventfuncoid: undefined,
           eventfunname: undefined,
-          eventname: undefined,
+          eventname: "DDL_COMMAND_START",
           when: undefined,
           xmin: undefined,
           source: undefined,

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

---

From: Dave Page <[email-masked]>
Date: Tue, 6 Jun 2017 11:20:02 +0100

Thanks, applied.

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

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company