Fixed a schema diff issue in which user mappings were not compared correctly. Fixes #6956

This commit is contained in:
Akshay Joshi
2022-03-04 17:21:30 +05:30
parent 4033bf3748
commit 1af431dcc2
5 changed files with 42 additions and 6 deletions

View File

@@ -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

View File

@@ -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 %}