From c07e52b9de6ed53b9f43be7ab12092596e12ea05 Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Thu, 20 Jun 2019 13:37:36 +0100 Subject: [PATCH] Ensure that both columns and partitions can be edited at the same time in the table dialog. Fixes #4380 --- docs/en_US/release_notes_4_9.rst | 3 +- .../servers/databases/schemas/tables/utils.py | 44 +++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/docs/en_US/release_notes_4_9.rst b/docs/en_US/release_notes_4_9.rst index 334764f51..7bf210494 100644 --- a/docs/en_US/release_notes_4_9.rst +++ b/docs/en_US/release_notes_4_9.rst @@ -38,4 +38,5 @@ Bug fixes | `Bug #4360 `_ - Ensure the debugger control buttons are only enabled once initialisation is complete. | `Bug #4362 `_ - Remove additional "SETOF" included when generating CREATE scripts for trigger functions. | `Bug #4365 `_ - Fix help links for backup globals and backup server. -| `Bug #4367 `_ - Fix an XSS issue seen in View/Edit data mode if a column name includes HTML. \ No newline at end of file +| `Bug #4367 `_ - Fix an XSS issue seen in View/Edit data mode if a column name includes HTML. +| `Bug #4380 `_ - Ensure that both columns and partitions can be edited at the same time in the table dialog. \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py index 639e252bc..e12d4e50a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py @@ -1765,21 +1765,21 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): status, res = self.conn.execute_dict(properties_sql) if not status: return internal_server_error(errormsg=res) - old_data = res['rows'][0] + old_col_data = res['rows'][0] - old_data['cltype'], old_data['hasSqrBracket'] = \ - self._cltype_formatter(old_data['cltype']) - old_data = \ + old_col_data['cltype'], old_col_data['hasSqrBracket'] = \ + self._cltype_formatter(old_col_data['cltype']) + old_col_data = \ BaseTableView.convert_length_precision_to_string( - old_data + old_col_data ) fulltype = self.get_full_type( - old_data['typnspname'], - old_data['typname'], - old_data['isdup'], - old_data['attndims'], - old_data['atttypmod'] + old_col_data['typnspname'], + old_col_data['typname'], + old_col_data['isdup'], + old_col_data['attndims'], + old_col_data['atttypmod'] ) def get_type_attr(key, data): @@ -1790,9 +1790,9 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): # If the column data type has not changed then fetch # old length and precision - if 'elemoid' in old_data and 'cltype' not in c: + if 'elemoid' in old_col_data and 'cltype' not in c: length, precision, typeval = \ - self.get_length_precision(old_data['elemoid']) + self.get_length_precision(old_col_data['elemoid']) # If we have length & precision both if length and precision: @@ -1828,25 +1828,25 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): # datatype to new one. if not length: - old_data['attlen'] = -1 + old_col_data['attlen'] = -1 if not precision: - old_data['attprecision'] = None + old_col_data['attprecision'] = None - old_data['cltype'] = DataTypeReader.parse_type_name( - old_data['cltype'] + old_col_data['cltype'] = DataTypeReader.parse_type_name( + old_col_data['cltype'] ) - if int(old_data['attlen']) == -1: - old_data['attlen'] = None - if 'attprecision' not in old_data: - old_data['attprecision'] = None + if int(old_col_data['attlen']) == -1: + old_col_data['attlen'] = None + if 'attprecision' not in old_col_data: + old_col_data['attprecision'] = None # Sql for alter column if 'inheritedfrom' not in c: column_sql += render_template("/".join( [self.column_template_path, 'update.sql']), - data=c, o_data=old_data, conn=self.conn + data=c, o_data=old_col_data, conn=self.conn ).strip('\n') + '\n\n' # If column(s) is/are added @@ -1911,7 +1911,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable): self.get_partitions_sql(temp_data).strip('\n') + '\n\n' # Combine all the SQL together - SQL += partitions_sql.strip('\n') + SQL += '\n' + partitions_sql.strip('\n') # Check if index constraints are added/changed/deleted index_constraint_sql = self.get_index_constraint_sql(