Fixed an issue where the user is unable to change the macro name. Fixes #5885
parent
542be2b2d4
commit
c28509ac28
|
@ -36,4 +36,5 @@ Bug fixes
|
|||
| `Issue #5843 <https://redmine.postgresql.org/issues/5843>`_ - Fixed an issue where the 'PARALLEL UNSAFE' option is missing from reverse engineering SQL of function/procedure.
|
||||
| `Issue #5845 <https://redmine.postgresql.org/issues/5845>`_ - Fixed an issue where the query tool is not fetching more than 1000 rows for the table does not have any primary key.
|
||||
| `Issue #5861 <https://redmine.postgresql.org/issues/5861>`_ - Ensure that the 'Remove Server' option should be visible in the context menu.
|
||||
| `Issue #5867 <https://redmine.postgresql.org/issues/5867>`_ - Fixed an issue where some properties are not being updated correctly for the shared server.
|
||||
| `Issue #5867 <https://redmine.postgresql.org/issues/5867>`_ - Fixed an issue where some properties are not being updated correctly for the shared server.
|
||||
| `Issue #5885 <https://redmine.postgresql.org/issues/5885>`_ - Fixed an issue where the user is unable to change the macro name.
|
|
@ -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
|
||||
|
|
|
@ -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).")
|
||||
|
||||
|
|
Loading…
Reference in New Issue