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).")
 
