public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch] - RM 5885 - Macro Support - Not able to change the Name
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch] - RM 5885 - Macro Support - Not able to change the Name
@ 2020-10-05 07:49 Khushboo Vashi <[email protected]>
  2020-10-05 09:11 ` Re: [pgAdmin4][Patch] - RM 5885 - Macro Support - Not able to change the Name Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Khushboo Vashi @ 2020-10-05 07:49 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

Please find the attached patch to fix the RM #5885 - Macro Support - Not
able to change the Name.

Thanks,
Khushboo


Attachments:

  [application/octet-stream] RM_5885.patch (3.1K, 3-RM_5885.patch)
  download | inline diff:
diff --git a/web/pgadmin/tools/sqleditor/tests/test_macros.py b/web/pgadmin/tools/sqleditor/tests/test_macros.py
index cbc43edec..80d5c8bf4 100644
--- a/web/pgadmin/tools/sqleditor/tests/test_macros.py
+++ b/web/pgadmin/tools/sqleditor/tests/test_macros.py
@@ -29,7 +29,7 @@ class TestMacros(BaseTestGenerator):
          dict(
              url='set_macros',
              method='put',
-             operation='update',
+             operation='set',
              data={
                  'changed': [
                      {'id': 1,
@@ -47,6 +47,26 @@ class TestMacros(BaseTestGenerator):
                  ]
              }
          )),
+        ('Update Macros',
+         dict(
+             url='set_macros',
+             method='put',
+             operation='update',
+             data={
+                 'changed': [
+                     {'id': 1,
+                      'name': 'Test Macro 1 updated',
+                      },
+                     {'id': 2,
+                      'sql': 'SELECT 22;'
+                      },
+                     {'id': 3,
+                      'name': 'Test Macro 3 updated',
+                      'sql': 'SELECT 33;'
+                      },
+                 ]
+             }
+         )),
         ('Clear Macros',
          dict(
              url='set_macros',
@@ -113,12 +133,20 @@ class TestMacros(BaseTestGenerator):
 
                 if self.operation == 'clear':
                     self.assertEqual(response.status_code, 410)
-                else:
+                elif self.operation == 'set':
                     self.assertEqual(response.status_code, 200)
 
                     response_data = json.loads(response.data.decode('utf-8'))
                     self.assertEqual(response_data['name'], m['name'])
                     self.assertEqual(response_data['sql'], m['sql'])
+                elif self.operation == 'update':
+                    self.assertEqual(response.status_code, 200)
+
+                    response_data = json.loads(response.data.decode('utf-8'))
+                    if 'name' in m:
+                        self.assertEqual(response_data['name'], m['name'])
+                    if 'sql' in m:
+                        self.assertEqual(response_data['sql'], m['sql'])
 
     def tearDown(self):
         # Disconnect the database
diff --git a/web/pgadmin/tools/sqleditor/utils/macros.py b/web/pgadmin/tools/sqleditor/utils/macros.py
index 10ad95811..2b33502d1 100644
--- a/web/pgadmin/tools/sqleditor/utils/macros.py
+++ b/web/pgadmin/tools/sqleditor/utils/macros.py
@@ -165,10 +165,10 @@ def update_macro(data, macro):
     name = data.get('name', None)
     sql = data.get('sql', None)
 
-    if name or sql and macro.sql and 'name' in data and name is None:
+    if (name or sql) and macro.sql and 'name' in data and name is None:
         return False, gettext(
             "Could not find the required parameter (name).")
-    elif name or sql and macro.name and 'sql' in data and sql is None:
+    elif (name or sql) and macro.name and 'sql' in data and sql is None:
         return False, gettext(
             "Could not find the required parameter (sql).")
 


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

* Re: [pgAdmin4][Patch] - RM 5885 - Macro Support - Not able to change the Name
  2020-10-05 07:49 [pgAdmin4][Patch] - RM 5885 - Macro Support - Not able to change the Name Khushboo Vashi <[email protected]>
@ 2020-10-05 09:11 ` Akshay Joshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2020-10-05 09:11 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Mon, Oct 5, 2020 at 1:20 PM Khushboo Vashi <
[email protected]> wrote:

> Hi,
>
> Please find the attached patch to fix the RM #5885 - Macro Support - Not
> able to change the Name.
>
> Thanks,
> Khushboo
>
>

-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


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


end of thread, other threads:[~2020-10-05 09:11 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05 07:49 [pgAdmin4][Patch] - RM 5885 - Macro Support - Not able to change the Name Khushboo Vashi <[email protected]>
2020-10-05 09:11 ` Akshay Joshi <[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