diff --git a/docs/en_US/release_notes_4_13.rst b/docs/en_US/release_notes_4_13.rst index 664e5730d..e6e61860c 100644 --- a/docs/en_US/release_notes_4_13.rst +++ b/docs/en_US/release_notes_4_13.rst @@ -55,6 +55,7 @@ Bug fixes | `Issue #4663 `_ - Fix exception in query history for python 2.7. | `Issue #4674 `_ - Fix query tool launch error if user name contain html characters. | `Issue #4681 `_ - Increase cache control max age for static files to improve performance over longer run. +| `Issue #4698 `_ - Fix SQL issue of length and precision when changing the data type of Column. | `Issue #4702 `_ - Fix modified SQL for Index when reset the value of Fill factor and Clustered?. | `Issue #4703 `_ - Fix reversed engineered SQL for btree Index when provided sort order and NULLs. | `Issue #4726 `_ - Ensure sequence with negative value should be created. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/__init__.py index cfa653c7c..462d7978f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/__init__.py @@ -524,10 +524,20 @@ class ColumnsView(PGChildNodeView, DataTypeReader): Returns: Converted data """ - if 'attlen' in data and data['attlen'] is not None: + + # We need to handle the below case because jquery has changed + # undefined/null values to empty strings + # https://github.com/jquery/jquery/commit/36d2d9ae937f626d98319ed850905e8d1cbfd078 + if 'attlen' in data and data['attlen'] == '': + data['attlen'] = None + elif 'attlen' in data and data['attlen'] is not None: data['attlen'] = str(data['attlen']) - if 'attprecision' in data and data['attprecision'] is not None: + + if 'attprecision' in data and data['attprecision'] == '': + data['attprecision'] = None + elif 'attprecision' in data and data['attprecision'] is not None: data['attprecision'] = str(data['attprecision']) + return data @check_precondition @@ -791,6 +801,18 @@ class ColumnsView(PGChildNodeView, DataTypeReader): old_data['cltype'] = self._cltype_formatter(old_data['cltype']) old_data['hasSqrBracket'] = self.hasSqrBracket + if 'cltype' in data and data['cltype'] != old_data['cltype']: + length, precision, typeval = \ + self.get_length_precision(data['cltype']) + + # if new datatype does not have length or precision + # then we cannot apply length or precision of old + # datatype to new one. + if not length: + old_data['attlen'] = -1 + if not precision: + old_data['attprecision'] = None + # If name is not present in data then # we will fetch it from old data, we also need schema & table name if 'name' not in data: