From c7cbe0ff4a03d2b076b53dcda6e8dc1632fd3c1f Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 21 Jan 2019 14:36:39 +0530 Subject: [PATCH] Data should be updated properly for FTS Configurations, FTS Dictionaries, FTS Parsers and FTS Templates. Fixes #3897 --- docs/en_US/release_notes_4_2.rst | 3 ++- .../databases/schemas/fts_configurations/__init__.py | 4 +++- .../databases/schemas/fts_dictionaries/__init__.py | 2 ++ .../servers/databases/schemas/fts_parser/__init__.py | 11 +++++++++-- .../databases/schemas/fts_templates/__init__.py | 12 ++++++++++-- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/en_US/release_notes_4_2.rst b/docs/en_US/release_notes_4_2.rst index 90986e9c1..9a37b004e 100644 --- a/docs/en_US/release_notes_4_2.rst +++ b/docs/en_US/release_notes_4_2.rst @@ -23,4 +23,5 @@ Bug fixes | `Bug #3837 `_ - Fixed SQL for when clause while creating Trigger. | `Bug #3838 `_ - Proper SQL should be generated when creating/changing column with custom type argument. | `Bug #3846 `_ - Proper SQL should be generated when create procedure with custom type arguments. -| `Bug #3891 `_ - Correct order of Save and Cancel button for json/jsonb editing. \ No newline at end of file +| `Bug #3891 `_ - Correct order of Save and Cancel button for json/jsonb editing. +| `Bug #3897 `_ - Data should be updated properly for FTS Configurations, FTS Dictionaries, FTS Parsers and FTS Templates. \ No newline at end of file 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 c3e5390db..685587661 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 @@ -509,7 +509,7 @@ class FtsConfigurationView(PGChildNodeView): sql = render_template( "/".join([self.template_path, 'nodes.sql']), cfgid=cfgid, - scid=data['schema'] if 'scheam' in data else scid + scid=data['schema'] if 'schema' in data else scid ) status, res = self.conn.execute_dict(sql) @@ -655,6 +655,8 @@ class FtsConfigurationView(PGChildNodeView): return gone(_("Could not find the FTS Configuration node.")) old_data = res['rows'][0] + if 'schema' not in data: + data['schema'] = old_data['schema'] # If user has changed the schema then fetch new schema directly # using its oid otherwise fetch old schema name using its oid 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 4a50788f3..0d8bc2156 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 @@ -651,6 +651,8 @@ class FtsDictionaryView(PGChildNodeView): return gone(_("Could not find the FTS Dictionary node.")) old_data = res['rows'][0] + if 'schema' not in data: + data['schema'] = old_data['schema'] # Handle templates and its schema name properly if old_data['template_schema'] is not None: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py index fbd942841..281a77d38 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py @@ -530,8 +530,13 @@ class FtsParserView(PGChildNodeView): :param scid: schema id :param pid: fts tempate id """ - data = request.args - # Fetch sql query for modified data + # data = request.args + data = {} + for k, v in request.args.items(): + try: + data[k] = json.loads(v, encoding='utf-8') + except ValueError: + data[k] = v # Fetch sql query for modified data SQL, name = self.get_sql(gid, sid, did, scid, data, pid) @@ -572,6 +577,8 @@ class FtsParserView(PGChildNodeView): return gone(_("Could not find the FTS Parser node.")) old_data = res['rows'][0] + if 'schema' not in data: + data['schema'] = old_data['schema'] # If user has changed the schema then fetch new schema directly # using its oid otherwise fetch old schema name with parser oid 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 7d9a38b35..feb590d2c 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 @@ -502,9 +502,15 @@ class FtsTemplateView(PGChildNodeView): :param scid: schema id :param tid: fts tempate id """ - data = request.args - # Fetch sql query for modified data + # data = request.args + data = {} + for k, v in request.args.items(): + try: + data[k] = json.loads(v, encoding='utf-8') + except ValueError: + data[k] = v + # Fetch sql query for modified data SQL, name = self.get_sql(gid, sid, did, scid, data, tid) # Most probably this is due to error @@ -546,6 +552,8 @@ class FtsTemplateView(PGChildNodeView): ) old_data = res['rows'][0] + if 'schema' not in data: + data['schema'] = old_data['schema'] # If user has changed the schema then fetch new schema directly # using its oid otherwise fetch old schema name using