From 024cfd2fab969df0ed4062177451b83eb814f4b8 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Fri, 12 Apr 2019 15:07:07 +0530 Subject: [PATCH] 1) Ensure that JSON strings as comments should be added properly for all the objects. Fixes #3582 2) Fixed alignment issue of columns in definition section of Index node. Fixes #4121 --- docs/en_US/release_notes_4_6.rst | 2 ++ .../servers/databases/__init__.py | 7 ++++++- .../foreign_data_wrappers/__init__.py | 7 ++++++- .../foreign_servers/__init__.py | 7 ++++++- .../servers/databases/languages/__init__.py | 7 ++++++- .../servers/databases/schemas/__init__.py | 7 ++++++- .../databases/schemas/collations/__init__.py | 7 ++++++- .../schemas/fts_configurations/__init__.py | 7 ++++++- .../schemas/fts_dictionaries/__init__.py | 7 ++++++- .../databases/schemas/fts_parsers/__init__.py | 7 ++++++- .../schemas/fts_templates/__init__.py | 7 ++++++- .../databases/schemas/sequences/__init__.py | 7 ++++++- .../databases/schemas/tables/__init__.py | 21 ++++++++++++++++--- .../constraints/check_constraint/__init__.py | 14 +++++++++++-- .../exclusion_constraint/__init__.py | 14 +++++++++++-- .../constraints/foreign_key/__init__.py | 14 +++++++++++-- .../constraints/index_constraint/__init__.py | 14 +++++++++++-- .../schemas/tables/indexes/__init__.py | 14 +++++++++++-- .../schemas/tables/indexes/static/js/index.js | 1 + .../schemas/tables/triggers/__init__.py | 14 +++++++++++-- .../databases/schemas/views/__init__.py | 7 ++++++- .../servers/tablespaces/__init__.py | 7 ++++++- 22 files changed, 171 insertions(+), 28 deletions(-) diff --git a/docs/en_US/release_notes_4_6.rst b/docs/en_US/release_notes_4_6.rst index 8c671ca42..2cd056677 100644 --- a/docs/en_US/release_notes_4_6.rst +++ b/docs/en_US/release_notes_4_6.rst @@ -15,7 +15,9 @@ Features Bug fixes ********* +| `Bug #3582 `_ - Ensure that JSON strings as comments should be added properly for all the objects. | `Bug #3938 `_ - Added support for Default Partition. | `Bug #4104 `_ - Ensure that record should be add/edited for root partition table with primary keys. +| `Bug #4121 `_ - Fixed alignment issue of columns in definition section of Index node. | `Bug #4138 `_ - Fix an issue where the dropdown becomes misaligned/displaced. | `Bug #4161 `_ - Ensure that parameters of procedures for EPAS server 10 and below should be set/reset properly. \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py index 731620592..53a322d48 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py @@ -805,7 +805,12 @@ class DatabaseView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comments',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v status, res = self.get_sql(gid, sid, data, did) diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py index c69ee4643..f9966975e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py @@ -555,7 +555,12 @@ class ForeignDataWrapperView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v try: diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py index 9d3f6990f..10f919c95 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py @@ -578,7 +578,12 @@ class ForeignServerView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v try: diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py index 25c5f5440..11f835c7d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py @@ -558,7 +558,12 @@ class LanguageView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v try: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py index 2ace75738..5404c5022 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py @@ -724,7 +724,12 @@ It may have been removed by another user. data = dict() for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py index e61f90f64..51f530a71 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py @@ -602,7 +602,12 @@ class CollationView(PGChildNodeView): data = dict() for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py index 685587661..df9bb4e46 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py @@ -612,7 +612,12 @@ class FtsConfigurationView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py index 0d8bc2156..e95d8abd9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py @@ -607,7 +607,12 @@ class FtsDictionaryView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/__init__.py index 281a77d38..62d93768c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/__init__.py @@ -534,7 +534,12 @@ class FtsParserView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py index feb590d2c..604256240 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py @@ -507,7 +507,12 @@ class FtsTemplateView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py index 5baeac08e..a778240fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py @@ -538,7 +538,12 @@ class SequenceView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py index 6fa25b29a..0f017e885 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py @@ -909,7 +909,12 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings): for k, v in data.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v @@ -1036,7 +1041,12 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings): for k, v in data.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v @@ -1223,7 +1233,12 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings): res = None for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py index 474487ca1..aa422066a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py @@ -495,7 +495,12 @@ class CheckConstraintView(PGChildNodeView): for k, v in data.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v @@ -762,7 +767,12 @@ class CheckConstraintView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py index 4024e0b52..e204f5e09 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py @@ -558,7 +558,12 @@ class ExclusionConstraintView(PGChildNodeView): for k, v in data.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v @@ -788,7 +793,12 @@ class ExclusionConstraintView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py index 68a211524..e2f04afba 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py @@ -563,7 +563,12 @@ class ForeignKeyConstraintView(PGChildNodeView): for k, v in data.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v @@ -827,7 +832,12 @@ class ForeignKeyConstraintView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py index 6a9162a85..dac45a0d0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py @@ -576,7 +576,12 @@ class IndexConstraintView(PGChildNodeView): for k, v in data.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v @@ -828,7 +833,12 @@ class IndexConstraintView(PGChildNodeView): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py index c9127412c..269df983d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py @@ -621,7 +621,12 @@ class IndexesView(PGChildNodeView): for k, v in data.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v @@ -826,7 +831,12 @@ class IndexesView(PGChildNodeView): data = dict() for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js index f075d5d9b..0220a9410 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js @@ -230,6 +230,7 @@ define('pgadmin.node.index', [ hasSQL: true, hasDepends: true, hasStatistics: true, + width: pgBrowser.stdW.md + 'px', statsPrettifyFields: [gettext('Size'), gettext('Index size')], Init: function() { /* Avoid mulitple registration of menus */ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py index 7d2b0f114..0dc8de6ea 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py @@ -619,7 +619,12 @@ class TriggerView(PGChildNodeView): for k, v in data.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except (ValueError, TypeError, KeyError): data[k] = v @@ -827,7 +832,12 @@ class TriggerView(PGChildNodeView): data = dict() for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py index d5ac0df07..44c3bc9e1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py @@ -647,7 +647,12 @@ class ViewNode(PGChildNodeView, VacuumSettings): data = {} for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('comment',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError: data[k] = v diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py index 8b7e1da9d..46940b4e7 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py @@ -457,7 +457,12 @@ class TablespaceView(PGChildNodeView): data = dict() for k, v in request.args.items(): try: - data[k] = json.loads(v, encoding='utf-8') + # comments should be taken as is because if user enters a + # json comment it is parsed by loads which should not happen + if k in ('description',): + data[k] = v + else: + data[k] = json.loads(v, encoding='utf-8') except ValueError as ve: current_app.logger.exception(ve) data[k] = v