Hi,

PFA updated patch for RM1878

Issues fixed:

1. ProgrammingError: can't adapt type 'Undefined' for schedule
2. Fixed malformed array literal issue raised by postgres while creating
schedule
3. Fixed update of schedule.
4. Fixed update of step.
5. disabled sql tab (create sql tab) for step.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Oct 21, 2016 at 4:11 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Please ignore this patch as I haven't fixed same issue for schedule. Also
> there is issue "malformed array literal" when we try to save schedule.
>
> I'll be sending updated patch.
>
> Thanks Harshal,
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, Oct 21, 2016 at 2:51 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA attached patch for pgagent issue RM1878
>>
>> issue fixed: ProgrammingError: can't adapt type 'Undefined'
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py
index 24ea1ba..4dd82e8 100644
--- a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py
@@ -219,8 +219,8 @@ class JobScheduleView(PGChildNodeView):
         res = []
         sql = render_template(
             "/".join([self.template_path, 'nodes.sql']),
-            jscid = jscid,
-            jid = jid
+            jscid=jscid,
+            jid=jid
         )
 
         status, result = self.conn.execute_2darray(sql)
@@ -298,13 +298,22 @@ class JobScheduleView(PGChildNodeView):
             jid: Job ID
         """
         data = {}
-        for k, v in request.args.items():
-            try:
-                data[k] = json.loads(
-                    v.decode('utf-8') if hasattr(v, 'decode') else v
-                )
-            except ValueError:
-                data[k] = v
+        if request.args:
+            for k, v in request.args.items():
+                try:
+                    data[k] = json.loads(
+                        v.decode('utf-8') if hasattr(v, 'decode') else v
+                    )
+                except ValueError:
+                    data[k] = v
+        else:
+            data = json.loads(request.data.decode())
+            # convert python list literal to postgres array literal.
+            data['jscminutes'] = data['jscminutes'].replace("[", "{").replace("]", "}")
+            data['jschours'] = data['jschours'].replace("[", "{").replace("]", "}")
+            data['jscweekdays'] = data['jscweekdays'].replace("[", "{").replace("]", "}")
+            data['jscmonthdays'] = data['jscmonthdays'].replace("[", "{").replace("]", "}")
+            data['jscmonths'] = data['jscmonths'].replace("[", "{").replace("]", "}")
 
         sql = render_template(
             "/".join([self.template_path, 'create.sql']),
@@ -327,8 +336,8 @@ class JobScheduleView(PGChildNodeView):
         self.conn.execute_void('END')
         sql = render_template(
             "/".join([self.template_path, 'nodes.sql']),
-            jscid = res,
-            jid = jid
+            jscid=res,
+            jid=jid
         )
         status, res = self.conn.execute_2darray(sql)
 
@@ -357,17 +366,36 @@ class JobScheduleView(PGChildNodeView):
             jscid: JobSchedule ID
         """
         data = {}
-        for k, v in request.args.items():
-            try:
-                data[k] = json.loads(
-                    v.decode('utf-8') if hasattr(v, 'decode') else v
-                )
-            except ValueError:
-                data[k] = v
+        if request.args:
+            for k, v in request.args.items():
+                try:
+                    data[k] = json.loads(
+                        v.decode('utf-8') if hasattr(v, 'decode') else v
+                    )
+                except ValueError:
+                    data[k] = v
+        else:
+            data = json.loads(request.data.decode())
+            # convert python list literal to postgres array literal.
+            if 'jscminutes' in data:
+                data['jscminutes'] = data['jscminutes'].replace("[", "{").replace("]", "}")
+
+            if 'jschours' in data:
+                data['jschours'] = data['jschours'].replace("[", "{").replace("]", "}")
+
+            if 'jscweekdays' in data:
+                data['jscweekdays'] = data['jscweekdays'].replace("[", "{").replace("]", "}")
+
+            if 'jscmonthdays' in data:
+                data['jscmonthdays'] = data['jscmonthdays'].replace("[", "{").replace("]", "}")
+
+            if 'jscmonths' in data:
+                data['jscmonths'] = data['jscmonths'].replace("[", "{").replace("]", "}")
 
         sql = render_template(
             "/".join([self.template_path, 'update.sql']),
             jid=jid,
+            jscid=jscid,
             data=data
         )
 
@@ -378,8 +406,8 @@ class JobScheduleView(PGChildNodeView):
 
         sql = render_template(
             "/".join([self.template_path, 'nodes.sql']),
-            jscid = jscid,
-            jid = jid
+            jscid=jscid,
+            jid=jid
         )
         status, res = self.conn.execute_2darray(sql)
 
diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py b/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py
index ccded7a..4def636 100644
--- a/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py
@@ -232,8 +232,8 @@ SELECT EXISTS(
         res = []
         sql = render_template(
             "/".join([self.template_path, 'nodes.sql']),
-            jstid = jstid,
-            jid = jid
+            jstid=jstid,
+            jid=jid
         )
 
         status, result = self.conn.execute_2darray(sql)
@@ -315,13 +315,16 @@ SELECT EXISTS(
             jid: Job ID
         """
         data = {}
-        for k, v in request.args.items():
-            try:
-                data[k] = json.loads(
-                    v.decode('utf-8') if hasattr(v, 'decode') else v
-                )
-            except ValueError:
-                data[k] = v
+        if request.args:
+            for k, v in request.args.items():
+                try:
+                    data[k] = json.loads(
+                        v.decode('utf-8') if hasattr(v, 'decode') else v
+                    )
+                except ValueError:
+                    data[k] = v
+        else:
+            data = json.loads(request.data.decode())
 
         sql = render_template(
             "/".join([self.template_path, 'create.sql']),
@@ -337,8 +340,8 @@ SELECT EXISTS(
 
         sql = render_template(
             "/".join([self.template_path, 'nodes.sql']),
-            jstid = res,
-            jid = jid
+            jstid=res,
+            jid=jid
         )
         status, res = self.conn.execute_2darray(sql)
 
@@ -417,8 +420,8 @@ SELECT EXISTS(
 
         sql = render_template(
             "/".join([self.template_path, 'nodes.sql']),
-            jstid = jstid,
-            jid = jid
+            jstid=jstid,
+            jid=jid
         )
         status, res = self.conn.execute_2darray(sql)
 
diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js b/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
index a38d338..f82d7be 100644
--- a/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
+++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/js/pga_jobstep.js
@@ -23,7 +23,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify, Backform) {
       parent_type: 'pga_job',
       type: 'pga_jobstep',
       dialogHelp: '{{ url_for('help.static', filename='pgagent_jobs.html') }}',
-      hasSQL: true,
+      hasSQL: false,
       hasDepends: false,
       hasStatistics: true,
       hasCollectiveStatistics: true,
diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_schedule.macros b/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_schedule.macros
index e8f129c..e80492c 100644
--- a/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_schedule.macros
+++ b/web/pgadmin/browser/server_groups/servers/pgagent/templates/macros/pga_schedule.macros
@@ -23,7 +23,7 @@ INSERT INTO pgagent.pga_schedule(
     {{ data.jscmonthdays|qtLiteral }}::boolean[],
     -- Months
     {{ data.jscmonths|qtLiteral }}::boolean[]
-) RETURNING jscid INTO scid;{% if 'jscexceptions' in data %}
+) RETURNING jscid {% if not jid %}INTO scid;{% endif %}{% if 'jscexceptions' in data %}
 {% for exc in data.jscexceptions %}
 
 {{ EXCEPTIONS.INSERT(None, exc) }}{% endfor %}{% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/templates/pga_schedule/sql/pre3.4/create.sql b/web/pgadmin/browser/server_groups/servers/pgagent/templates/pga_schedule/sql/pre3.4/create.sql
index e9f657f..6d63581 100644
--- a/web/pgadmin/browser/server_groups/servers/pgagent/templates/pga_schedule/sql/pre3.4/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/pgagent/templates/pga_schedule/sql/pre3.4/create.sql
@@ -1,10 +1,2 @@
 {% import 'macros/pga_schedule.macros' as SCHEDULE %}
-DO $$
-DECLARE
-  jscid integer;
-BEGIN
 {{ SCHEDULE.INSERT(jid, data) }}
-END
-$$ LANGUAGE 'plpgsql';{% if fetch_id %}
-
-{{ SCHEDULE.FETCH_CURRENT() }}{% endif %}
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to