Ensure that both columns and partitions can be edited at the same time in the table dialog. Fixes #4380

This commit is contained in:
Khushboo Vashi 2019-06-20 13:37:36 +01:00 committed by Dave Page
parent 78d55c7cc0
commit c07e52b9de
2 changed files with 24 additions and 23 deletions

View File

@ -38,4 +38,5 @@ Bug fixes
| `Bug #4360 <https://redmine.postgresql.org/issues/4360>`_ - Ensure the debugger control buttons are only enabled once initialisation is complete.
| `Bug #4362 <https://redmine.postgresql.org/issues/4362>`_ - Remove additional "SETOF" included when generating CREATE scripts for trigger functions.
| `Bug #4365 <https://redmine.postgresql.org/issues/4365>`_ - Fix help links for backup globals and backup server.
| `Bug #4367 <https://redmine.postgresql.org/issues/4367>`_ - Fix an XSS issue seen in View/Edit data mode if a column name includes HTML.
| `Bug #4367 <https://redmine.postgresql.org/issues/4367>`_ - Fix an XSS issue seen in View/Edit data mode if a column name includes HTML.
| `Bug #4380 <https://redmine.postgresql.org/issues/4380>`_ - Ensure that both columns and partitions can be edited at the same time in the table dialog.

View File

@ -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(