public inbox for [email protected]  
help / color / mirror / Atom feed
From: Aditya Toshniwal <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][RM3837] Trigger when option syntax error
Date: Wed, 16 Jan 2019 13:17:06 +0530
Message-ID: <CAM9w-_nB-P0aM3fC-d5+_Q_gTxttFGqU5FJAJ5U5FAFp8sj1pQ@mail.gmail.com> (raw)
In-Reply-To: <CAM9w-_nfYz1vxxt1yoZVc__gPdPD9FszJ14a3OQfQX==f_Ee-w@mail.gmail.com>
References: <CAM9w-_k8ovykJ3ze5pNeTLKZBLrgafG9D0nS9m7jv6dCdBWTXQ@mail.gmail.com>
	<CANxoLDcmy9ECt552Bo84ONZsGNUYtkOcj=Noac-krt33+udO8g@mail.gmail.com>
	<CAM9w-_nfYz1vxxt1yoZVc__gPdPD9FszJ14a3OQfQX==f_Ee-w@mail.gmail.com>

Hi Hackers,

Kindly ignore the previous patch, some typo mistake in filename. Apologies.
Attached is the updated patch.

On Wed, Jan 16, 2019 at 11:19 AM Aditya Toshniwal <
[email protected]> wrote:

> Hi Hackers,
>
> Please find the updated patch. Kindly review.
>
> On Tue, Jan 15, 2019 at 6:05 PM Akshay Joshi <
> [email protected]> wrote:
>
>> Hi Aditya
>>
>> Facing issue when tested on EPAS 10, please verify it on EPAS.
>>
>> On Mon, Jan 14, 2019 at 6:26 PM Aditya Toshniwal <
>> [email protected]> wrote:
>>
>>> Hi Hackers,
>>>
>>> Attached is the patch to fix the syntax error if when clause is given.
>>> Kindly review.
>>>
>>> --
>>> Thanks and Regards,
>>> Aditya Toshniwal
>>> Software Engineer | EnterpriseDB Software Solutions | Pune
>>> "Don't Complain about Heat, Plant a tree"
>>>
>>
>>
>> --
>> *Akshay Joshi*
>>
>> *Sr. Software Architect *
>>
>>
>>
>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>
>
>
> --
> Thanks and Regards,
> Aditya Toshniwal
> Software Engineer | EnterpriseDB Software Solutions | Pune
> "Don't Complain about Heat, Plant a tree"
>


-- 
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"


Attachments:

  [application/octet-stream] RM3837.patch (6.3K, 3-RM3837.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
index 28d10ad1..4a6ba6da 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/10_plus/properties.sql
@@ -1,7 +1,6 @@
 SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable,
     nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction,
-    COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'),
-    substring(pg_get_triggerdef(t.oid), 'WHEN (.*)  \\$trigger')) AS whenclause,
+    trim(pg_catalog.pg_get_expr(t.tgqual, t.tgrelid), '()') AS whenclause
     -- We need to convert tgargs column bytea datatype to array datatype
     (string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs,
 {% if datlastsysoid %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/properties.sql
index 2d34accf..7b124bc5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/9.1_plus/properties.sql
@@ -1,7 +1,6 @@
 SELECT t.oid,t.tgname AS name, t.xmin, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable,
     nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction,
-    COALESCE(substring(pg_get_triggerdef(t.oid), 'WHEN (.*) EXECUTE PROCEDURE'),
-    substring(pg_get_triggerdef(t.oid), 'WHEN (.*)  \\$trigger')) AS whenclause,
+    trim(pg_catalog.pg_get_expr(t.tgqual, t.tgrelid),'()') AS whenclause,
     -- We need to convert tgargs column bytea datatype to array datatype
     (string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs,
 {% if datlastsysoid %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/create.sql
index 611a593b..4cffc920 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/trigger/sql/default/create.sql
@@ -21,7 +21,7 @@ CREATE{% if data.is_constraint_trigger %} CONSTRAINT{% endif %} TRIGGER {{ conn|
     FOR EACH{% if data.is_row_trigger %} ROW{% else %} STATEMENT{% endif %}
 {% if data.whenclause %}
 
-    WHEN {{ data.whenclause }}{% endif %}
+    WHEN ({{ data.whenclause }}){% endif %}
 
     {% if data.prosrc is defined and
     (data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL') %}{{ data.prosrc }}{% else %}EXECUTE PROCEDURE {{ data.tfunction }}{% if data.tgargs %}({{ data.tgargs }}){% else %}(){% endif%}{% endif%};
@@ -29,4 +29,4 @@ CREATE{% if data.is_constraint_trigger %} CONSTRAINT{% endif %} TRIGGER {{ conn|
 {% if data.description %}
 COMMENT ON TRIGGER {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }}
     IS {{data.description|qtLiteral}};
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
index 7e53254f..8b29d417 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
@@ -17,11 +17,10 @@ define('pgadmin.node.trigger', [
   gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify,
   SchemaChildTreeNode
 ) {
-
   Backform.CustomSwitchControl = Backform.SwitchControl.extend({
     template: _.template([
-      '<label class="<%=Backform.controlLabelClassName%> custom_switch_label_class"><%=label%></label>',
-      '<div class="<%=Backform.controlsClassName%> custom_switch_control_class">',
+      '<label class="control-label pg-el-sm-6 pg-el-12"><%=label%></label>',
+      '<div class="pgadmin-controls pg-el-sm-6 pg-el-12">',
       '  <div class="checkbox">',
       '    <label>',
       '      <input type="checkbox" class="<%=extraClasses.join(\' \')%>"',
@@ -34,7 +33,7 @@ define('pgadmin.node.trigger', [
       '  <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
       '<% } %>',
     ].join('\n')),
-    className: 'pgadmin-control-group form-group col-6',
+    className: 'pgadmin-control-group form-group col-6 row',
   });
 
   if (!pgBrowser.Nodes['coll-trigger']) {
@@ -57,7 +56,7 @@ define('pgadmin.node.trigger', [
       label: gettext('Trigger'),
       hasSQL:  true,
       hasDepends: true,
-      width: '650px',
+      width: pgBrowser.stdW.sm + 'px',
       sqlAlterHelp: 'sql-altertrigger.html',
       sqlCreateHelp: 'sql-createtrigger.html',
       dialogHelp: url_for('help.static', {'filename': 'trigger_dialog.html'}),
@@ -391,7 +390,7 @@ define('pgadmin.node.trigger', [
           },
         },{
           type: 'nested', control: 'fieldset', mode: ['create','edit', 'properties'],
-          label: gettext('Events'), group: gettext('Events'),
+          label: gettext('Events'), group: gettext('Events'), contentClass: 'row',
           schema:[{
             id: 'evnt_insert', label: gettext('INSERT'),
             type: 'switch', mode: ['create','edit', 'properties'],
diff --git a/web/pgadmin/static/scss/_pgadmin.style.scss b/web/pgadmin/static/scss/_pgadmin.style.scss
index 1ad4b91f..3253c846 100644
--- a/web/pgadmin/static/scss/_pgadmin.style.scss
+++ b/web/pgadmin/static/scss/_pgadmin.style.scss
@@ -420,6 +420,9 @@
   border: $panel-border;
   border-radius: $card-border-radius;
   background-color: $color-bg-theme;
+  fieldset.inline-fieldset {
+    background: $color-bg-theme;
+  }
 }
 
 fieldset.inline-fieldset {


view thread (5+ 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], [email protected]
  Subject: Re: [pgAdmin4][RM3837] Trigger when option syntax error
  In-Reply-To: <CAM9w-_nB-P0aM3fC-d5+_Q_gTxttFGqU5FJAJ5U5FAFp8sj1pQ@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