public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch] - RM 5885 - Macro Support - Not able to change the Name
Date: Mon, 5 Oct 2020 13:19:50 +0530
Message-ID: <CAFOhELcxCcOcJkPVjWYwfrF7dBRRSfhxwnP=UQoYzRqCgNnD6Q@mail.gmail.com> (raw)
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).")
view thread (2+ 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]
Subject: Re: [pgAdmin4][Patch] - RM 5885 - Macro Support - Not able to change the Name
In-Reply-To: <CAFOhELcxCcOcJkPVjWYwfrF7dBRRSfhxwnP=UQoYzRqCgNnD6Q@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