diff --git a/docs/en_US/release_notes_6_6.rst b/docs/en_US/release_notes_6_6.rst index df4707fd5..cdaab3b12 100644 --- a/docs/en_US/release_notes_6_6.rst +++ b/docs/en_US/release_notes_6_6.rst @@ -20,6 +20,7 @@ Housekeeping Bug fixes ********* +| `Issue #6956 `_ - Fixed a schema diff issue in which user mappings were not compared correctly. | `Issue #6991 `_ - Fixed an issue where pgadmin cannot connect to LDAP when STARTTLS is required before bind. | `Issue #6999 `_ - Fixed an issue where a warning is flashed every time for an email address when authentication sources are internal and ldap. | `Issue #7124 `_ - Fixed the schema diff issue where tables have different column positions and a column has a default value. diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py index f3ffb66e9..38938503d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/__init__.py @@ -25,6 +25,7 @@ from pgadmin.utils.driver import get_driver from config import PG_DEFAULT_DRIVER from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare +from pgadmin.utils.constants import PGADMIN_STRING_SEPARATOR class UserMappingModule(CollectionNodeModule): @@ -916,7 +917,14 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare): # the empty list. if 'umoptions' in data and data['umoptions'] is None: data['umoptions'] = [] - res[row['name']] = data + + mapping_name = row['name'] + if 'srvname' in data: + mapping_name = \ + row['name'] + PGADMIN_STRING_SEPARATOR + \ + data['srvname'] + + res[mapping_name] = data return res diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/templates/user_mappings/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/templates/user_mappings/sql/default/properties.sql index aedf5600d..5a9b364bc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/templates/user_mappings/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/templates/user_mappings/sql/default/properties.sql @@ -5,7 +5,7 @@ FROM pg_catalog.pg_foreign_server srv LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass) WHERE srv.oid = {{fserid}}::oid {% elif fsid or umid %} -SELECT u.umid AS oid, u.usename AS name, u.srvid AS fsid, umoptions AS umoptions, fs.srvfdw AS fdwid +SELECT u.umid AS oid, u.usename AS name, fs.srvname, u.srvid AS fsid, umoptions AS umoptions, fs.srvfdw AS fdwid FROM pg_catalog.pg_user_mappings u LEFT JOIN pg_catalog.pg_foreign_server fs ON fs.oid = u.srvid {% if fsid %} WHERE u.srvid = {{fsid}}::oid {% endif %} {% if umid %} WHERE u.umid= {{umid}}::oid {% endif %} diff --git a/web/pgadmin/tools/schema_diff/directory_compare.py b/web/pgadmin/tools/schema_diff/directory_compare.py index 34fbc3757..7ea0c374f 100644 --- a/web/pgadmin/tools/schema_diff/directory_compare.py +++ b/web/pgadmin/tools/schema_diff/directory_compare.py @@ -14,6 +14,7 @@ import string from pgadmin.tools.schema_diff.model import SchemaDiffModel from flask import current_app from pgadmin.utils.preferences import Preferences +from pgadmin.utils.constants import PGADMIN_STRING_SEPARATOR count = 1 @@ -22,6 +23,19 @@ list_keys_array = ['name', 'colname', 'argid', 'token', 'option', 'conname', 'fsrvoption', 'umoption'] +def _get_user_mapping_name(user_mapping_name): + """ + This function is used to check the pgadmin string separator in the + specific string and split that. + """ + mapping_name = user_mapping_name + + if mapping_name.find(PGADMIN_STRING_SEPARATOR): + mapping_name = mapping_name.split(PGADMIN_STRING_SEPARATOR)[0] + + return mapping_name + + def _get_source_list(**kwargs): """ Get only source list. @@ -74,11 +88,15 @@ def _get_source_list(**kwargs): view_object.conn, source_object_id, where=None, show_system_objects=None, is_schema_diff=True) + title = item + if node == 'user_mapping': + title = _get_user_mapping_name(item) + source_only.append({ 'id': count, 'type': node, 'label': node_label, - 'title': item, + 'title': title, 'oid': source_object_id, 'status': SchemaDiffModel.COMPARISON_STATUS['source_only'], 'source_ddl': source_ddl, @@ -151,11 +169,15 @@ def _get_target_list(removed, target_dict, node, target_params, view_object, {'drop_sql': True}) diff_ddl = view_object.get_sql_from_diff(**temp_tgt_params) + title = item + if node == 'user_mapping': + title = _get_user_mapping_name(item) + target_only.append({ 'id': count, 'type': node, 'label': node_label, - 'title': item, + 'title': title, 'oid': target_object_id, 'status': SchemaDiffModel.COMPARISON_STATUS['target_only'], 'source_ddl': '', @@ -315,11 +337,15 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict, {'data': diff_dict, 'target_schema': target_schema}) diff_ddl = view_object.get_sql_from_diff(**temp_tgt_params) + title = key + if node == 'user_mapping': + title = _get_user_mapping_name(key) + different.append({ 'id': count, 'type': node, 'label': node_label, - 'title': key, + 'title': title, 'oid': source_object_id, 'source_oid': source_object_id, 'target_oid': target_object_id, @@ -699,7 +725,7 @@ def parse_acl(source, target, diff_dict): :param target: Target Dict :param diff_dict: Difference Dict """ - acl_keys = ['datacl', 'relacl', 'typacl', 'pkgacl'] + acl_keys = ['datacl', 'relacl', 'typacl', 'pkgacl', 'fsrvacl'] key = is_key_exists(acl_keys, source) # If key is not found in source then check the key is available diff --git a/web/pgadmin/utils/constants.py b/web/pgadmin/utils/constants.py index 83f6f1b77..9873371d2 100644 --- a/web/pgadmin/utils/constants.py +++ b/web/pgadmin/utils/constants.py @@ -26,6 +26,7 @@ PREF_LABEL_RESULTS_GRID = gettext('Results grid') PREF_LABEL_SQL_FORMATTING = gettext('SQL formatting') PREF_LABEL_TABS_SETTINGS = gettext('Tab settings') +PGADMIN_STRING_SEPARATOR = '_$PGADMIN$_' PGADMIN_NODE = 'pgadmin.node.%s' UNAUTH_REQ = "Unauthorized request." SERVER_CONNECTION_CLOSED = gettext(