From c7a6056ee38d70fbc328c26bce46451ad437aedb Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Tue, 28 Oct 2025 16:31:39 +0530 Subject: [PATCH] Fixed an issue where Schema Diff does not ignore Tablespace for indexes. #9117 --- docs/en_US/release_notes_9_10.rst | 3 ++- .../templates/domains/sql/default/properties.sql | 3 +-- .../schemas/tables/schema_diff_table_utils.py | 12 ++++++++++-- web/pgadmin/tools/schema_diff/directory_compare.py | 7 +++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/en_US/release_notes_9_10.rst b/docs/en_US/release_notes_9_10.rst index d30829096..46ef49143 100644 --- a/docs/en_US/release_notes_9_10.rst +++ b/docs/en_US/release_notes_9_10.rst @@ -30,4 +30,5 @@ Housekeeping Bug fixes ********* - | `Issue #8504 `_ - Fixed an issue where data output column resize is not sticking in Safari. \ No newline at end of file + | `Issue #8504 `_ - Fixed an issue where data output column resize is not sticking in Safari. + | `Issue #9117 `_ - Fixed an issue where Schema Diff does not ignore Tablespace for indexes. \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/properties.sql index 8201ad622..8ef6842e4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/properties.sql @@ -5,8 +5,7 @@ SELECT pg_catalog.concat(cn.nspname, '."', c.collname,'"') ELSE '' END AS collname, d.typtypmod, d.typnotnull, d.typdefault, d.typndims, d.typdelim, bn.nspname as basensp, - description, (SELECT COUNT(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=d.typname) > 1 AS domisdup, - (SELECT COUNT(1) FROM pg_catalog.pg_type t3 WHERE t3.typname=b.typname) > 1 AS baseisdup, + description, (SELECT pg_catalog.array_agg(provider || '=' || label) FROM diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/schema_diff_table_utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/schema_diff_table_utils.py index abe23fb56..261d29a69 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/schema_diff_table_utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/schema_diff_table_utils.py @@ -301,6 +301,7 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare): target = kwargs.get('target') diff_dict = kwargs.get('diff_dict') ignore_whitespaces = kwargs.get('ignore_whitespaces') + ignore_tablespace = kwargs.get('ignore_tablespace') # Get the difference result for source and target columns col_diff = self.table_col_comp(source, target) @@ -365,7 +366,8 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare): "source": source, "target": target, "target_schema": target_schema, - "ignore_whitespaces": ignore_whitespaces + "ignore_whitespaces": ignore_whitespaces, + "ignore_tablespace": ignore_tablespace } diff = self._compare_source_and_target( intersect_keys, module_view, source_params, @@ -414,11 +416,17 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare): target = kwargs['target'] target_schema = kwargs['target_schema'] ignore_whitespaces = kwargs.get('ignore_whitespaces') + ignore_tablespace = kwargs.get('ignore_tablespace') + temp_ignore_key = self.keys_to_ignore + # if ignore_tablespace is True then add all the possible tablespace + # keys to the ignore keys. + if ignore_tablespace: + temp_ignore_key = temp_ignore_key + ['spcname', 'spcoid'] for key in intersect_keys: # Recursively Compare the two dictionary if not are_dictionaries_identical( - dict1[key], dict2[key], self.keys_to_ignore, + dict1[key], dict2[key], temp_ignore_key, ignore_whitespaces): diff_ddl = module_view.ddl_compare( source_params=source_params, diff --git a/web/pgadmin/tools/schema_diff/directory_compare.py b/web/pgadmin/tools/schema_diff/directory_compare.py index 09bd77c67..4ab0ac85a 100644 --- a/web/pgadmin/tools/schema_diff/directory_compare.py +++ b/web/pgadmin/tools/schema_diff/directory_compare.py @@ -277,6 +277,7 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict, target_schema = kwargs.get('target_schema') ignore_whitespaces = kwargs.get('ignore_whitespaces') ignore_grants = kwargs.get('ignore_grants', False) + ignore_tablespace = kwargs.get('ignore_tablespace', False) for key in intersect_keys: source_object_id, target_object_id = \ @@ -357,7 +358,8 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict, target_params=temp_tgt_params, source=dict1[key], target=dict2[key], diff_dict=diff_dict, target_schema=target_schema, - ignore_whitespaces=ignore_whitespaces) + ignore_whitespaces=ignore_whitespaces, + ignore_tablespace=ignore_tablespace) else: temp_src_params = copy.deepcopy(source_params) temp_tgt_params = copy.deepcopy(target_params) @@ -491,7 +493,8 @@ def compare_dictionaries(**kwargs): "group_name": group_name, "target_schema": target_schema, "ignore_whitespaces": ignore_whitespaces, - "ignore_grants": ignore_grants + "ignore_grants": ignore_grants, + "ignore_tablespace": ignore_tablespace, } identical, different = _get_identical_and_different_list(