mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
Fixed a schema diff issue in which user mappings were not compared correctly. Fixes #6956
This commit is contained in:
parent
4033bf3748
commit
1af431dcc2
@ -20,6 +20,7 @@ Housekeeping
|
|||||||
Bug fixes
|
Bug fixes
|
||||||
*********
|
*********
|
||||||
|
|
||||||
|
| `Issue #6956 <https://redmine.postgresql.org/issues/6956>`_ - Fixed a schema diff issue in which user mappings were not compared correctly.
|
||||||
| `Issue #6991 <https://redmine.postgresql.org/issues/6991>`_ - Fixed an issue where pgadmin cannot connect to LDAP when STARTTLS is required before bind.
|
| `Issue #6991 <https://redmine.postgresql.org/issues/6991>`_ - Fixed an issue where pgadmin cannot connect to LDAP when STARTTLS is required before bind.
|
||||||
| `Issue #6999 <https://redmine.postgresql.org/issues/6999>`_ - Fixed an issue where a warning is flashed every time for an email address when authentication sources are internal and ldap.
|
| `Issue #6999 <https://redmine.postgresql.org/issues/6999>`_ - Fixed an issue where a warning is flashed every time for an email address when authentication sources are internal and ldap.
|
||||||
| `Issue #7124 <https://redmine.postgresql.org/issues/7124>`_ - Fixed the schema diff issue where tables have different column positions and a column has a default value.
|
| `Issue #7124 <https://redmine.postgresql.org/issues/7124>`_ - Fixed the schema diff issue where tables have different column positions and a column has a default value.
|
||||||
|
@ -25,6 +25,7 @@ from pgadmin.utils.driver import get_driver
|
|||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
|
||||||
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
from pgadmin.tools.schema_diff.compare import SchemaDiffObjectCompare
|
||||||
|
from pgadmin.utils.constants import PGADMIN_STRING_SEPARATOR
|
||||||
|
|
||||||
|
|
||||||
class UserMappingModule(CollectionNodeModule):
|
class UserMappingModule(CollectionNodeModule):
|
||||||
@ -916,7 +917,14 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
# the empty list.
|
# the empty list.
|
||||||
if 'umoptions' in data and data['umoptions'] is None:
|
if 'umoptions' in data and data['umoptions'] is None:
|
||||||
data['umoptions'] = []
|
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
|
return res
|
||||||
|
|
||||||
|
@ -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)
|
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
|
WHERE srv.oid = {{fserid}}::oid
|
||||||
{% elif fsid or umid %}
|
{% 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
|
FROM pg_catalog.pg_user_mappings u
|
||||||
LEFT JOIN pg_catalog.pg_foreign_server fs ON fs.oid = u.srvid
|
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 %}
|
{% if fsid %} WHERE u.srvid = {{fsid}}::oid {% endif %} {% if umid %} WHERE u.umid= {{umid}}::oid {% endif %}
|
||||||
|
@ -14,6 +14,7 @@ import string
|
|||||||
from pgadmin.tools.schema_diff.model import SchemaDiffModel
|
from pgadmin.tools.schema_diff.model import SchemaDiffModel
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from pgadmin.utils.preferences import Preferences
|
from pgadmin.utils.preferences import Preferences
|
||||||
|
from pgadmin.utils.constants import PGADMIN_STRING_SEPARATOR
|
||||||
|
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
@ -22,6 +23,19 @@ list_keys_array = ['name', 'colname', 'argid', 'token', 'option', 'conname',
|
|||||||
'fsrvoption', 'umoption']
|
'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):
|
def _get_source_list(**kwargs):
|
||||||
"""
|
"""
|
||||||
Get only source list.
|
Get only source list.
|
||||||
@ -74,11 +88,15 @@ def _get_source_list(**kwargs):
|
|||||||
view_object.conn, source_object_id, where=None,
|
view_object.conn, source_object_id, where=None,
|
||||||
show_system_objects=None, is_schema_diff=True)
|
show_system_objects=None, is_schema_diff=True)
|
||||||
|
|
||||||
|
title = item
|
||||||
|
if node == 'user_mapping':
|
||||||
|
title = _get_user_mapping_name(item)
|
||||||
|
|
||||||
source_only.append({
|
source_only.append({
|
||||||
'id': count,
|
'id': count,
|
||||||
'type': node,
|
'type': node,
|
||||||
'label': node_label,
|
'label': node_label,
|
||||||
'title': item,
|
'title': title,
|
||||||
'oid': source_object_id,
|
'oid': source_object_id,
|
||||||
'status': SchemaDiffModel.COMPARISON_STATUS['source_only'],
|
'status': SchemaDiffModel.COMPARISON_STATUS['source_only'],
|
||||||
'source_ddl': source_ddl,
|
'source_ddl': source_ddl,
|
||||||
@ -151,11 +169,15 @@ def _get_target_list(removed, target_dict, node, target_params, view_object,
|
|||||||
{'drop_sql': True})
|
{'drop_sql': True})
|
||||||
diff_ddl = view_object.get_sql_from_diff(**temp_tgt_params)
|
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({
|
target_only.append({
|
||||||
'id': count,
|
'id': count,
|
||||||
'type': node,
|
'type': node,
|
||||||
'label': node_label,
|
'label': node_label,
|
||||||
'title': item,
|
'title': title,
|
||||||
'oid': target_object_id,
|
'oid': target_object_id,
|
||||||
'status': SchemaDiffModel.COMPARISON_STATUS['target_only'],
|
'status': SchemaDiffModel.COMPARISON_STATUS['target_only'],
|
||||||
'source_ddl': '',
|
'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})
|
{'data': diff_dict, 'target_schema': target_schema})
|
||||||
diff_ddl = view_object.get_sql_from_diff(**temp_tgt_params)
|
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({
|
different.append({
|
||||||
'id': count,
|
'id': count,
|
||||||
'type': node,
|
'type': node,
|
||||||
'label': node_label,
|
'label': node_label,
|
||||||
'title': key,
|
'title': title,
|
||||||
'oid': source_object_id,
|
'oid': source_object_id,
|
||||||
'source_oid': source_object_id,
|
'source_oid': source_object_id,
|
||||||
'target_oid': target_object_id,
|
'target_oid': target_object_id,
|
||||||
@ -699,7 +725,7 @@ def parse_acl(source, target, diff_dict):
|
|||||||
:param target: Target Dict
|
:param target: Target Dict
|
||||||
:param diff_dict: Difference 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)
|
key = is_key_exists(acl_keys, source)
|
||||||
|
|
||||||
# If key is not found in source then check the key is available
|
# If key is not found in source then check the key is available
|
||||||
|
@ -26,6 +26,7 @@ PREF_LABEL_RESULTS_GRID = gettext('Results grid')
|
|||||||
PREF_LABEL_SQL_FORMATTING = gettext('SQL formatting')
|
PREF_LABEL_SQL_FORMATTING = gettext('SQL formatting')
|
||||||
PREF_LABEL_TABS_SETTINGS = gettext('Tab settings')
|
PREF_LABEL_TABS_SETTINGS = gettext('Tab settings')
|
||||||
|
|
||||||
|
PGADMIN_STRING_SEPARATOR = '_$PGADMIN$_'
|
||||||
PGADMIN_NODE = 'pgadmin.node.%s'
|
PGADMIN_NODE = 'pgadmin.node.%s'
|
||||||
UNAUTH_REQ = "Unauthorized request."
|
UNAUTH_REQ = "Unauthorized request."
|
||||||
SERVER_CONNECTION_CLOSED = gettext(
|
SERVER_CONNECTION_CLOSED = gettext(
|
||||||
|
Loading…
Reference in New Issue
Block a user