mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-07 22:53:45 -06:00
Fixed Schema Diff issues while comparing Materialized View. #7271
This commit is contained in:
parent
fbbbfe22dd
commit
9f31ec115a
@ -272,8 +272,12 @@ def check_precondition(f):
|
||||
# Template for rules node
|
||||
self.rules_template_path = 'rules/sql'
|
||||
|
||||
# Template for index node
|
||||
self.index_template_path = 'indexes/sql/#{0}#'.format(
|
||||
self.manager.version)
|
||||
|
||||
# Submodule list for schema diff
|
||||
self.view_sub_modules = ['rule', 'trigger']
|
||||
self.view_sub_modules = ['rule', 'trigger', 'index']
|
||||
if (self.manager.server_type == 'ppas' and
|
||||
self.manager.version >= 120000):
|
||||
self.view_sub_modules.append('compound_trigger')
|
||||
@ -1799,6 +1803,8 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffViewCompare):
|
||||
template_path = None
|
||||
if module_name == 'trigger':
|
||||
template_path = self.trigger_template_path
|
||||
elif module_name == 'index':
|
||||
template_path = self.index_template_path
|
||||
elif module_name == 'rule':
|
||||
template_path = self.rules_template_path
|
||||
elif module_name == 'compound_trigger':
|
||||
@ -2395,6 +2401,9 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
for row in rset['rows']:
|
||||
status, data = self._fetch_mview_properties(did, scid, row['oid'])
|
||||
if status:
|
||||
# Fetch the data of sub module
|
||||
self._get_sub_module_data_for_compare(
|
||||
sid, did, scid, data, row['oid'])
|
||||
res[row['name']] = data
|
||||
|
||||
return res
|
||||
|
@ -131,7 +131,7 @@ class SchemaDiffViewCompare(SchemaDiffObjectCompare):
|
||||
target_params['diff_data'] = diff_dict
|
||||
diff = self.get_sql_from_view_diff(**target_params)
|
||||
|
||||
ignore_sub_modules = ['column', 'index']
|
||||
ignore_sub_modules = ['column']
|
||||
if self.manager.server_type == 'pg' or self.manager.version < 120000:
|
||||
ignore_sub_modules.append('compound_trigger')
|
||||
|
||||
|
@ -21,6 +21,9 @@ list_keys_array = ['name', 'colname', 'argid', 'token', 'option', 'conname',
|
||||
'member_name', 'label', 'attname', 'fdwoption',
|
||||
'fsrvoption', 'umoption']
|
||||
|
||||
SPECIAL_NODES = ['table', 'view', 'mview']
|
||||
VIEW_NODES = ['view', 'mview']
|
||||
|
||||
|
||||
def _get_user_mapping_name(user_mapping_name):
|
||||
"""
|
||||
@ -58,21 +61,12 @@ def _get_source_list(**kwargs):
|
||||
if 'oid' in source_dict[item]:
|
||||
source_object_id = source_dict[item]['oid']
|
||||
|
||||
if node == 'table' or node == 'view':
|
||||
if node in SPECIAL_NODES:
|
||||
temp_src_params = copy.deepcopy(source_params)
|
||||
temp_src_params['tid'] = source_object_id
|
||||
temp_src_params['json_resp'] = False
|
||||
temp_src_params['add_not_exists_clause'] = True
|
||||
if node == 'table':
|
||||
source_ddl = \
|
||||
view_object.get_sql_from_table_diff(**temp_src_params)
|
||||
temp_src_params.update({'target_schema': target_schema})
|
||||
diff_ddl = (
|
||||
view_object.get_sql_from_table_diff(**temp_src_params))
|
||||
source_dependencies = \
|
||||
view_object.get_table_submodules_dependencies(
|
||||
**temp_src_params)
|
||||
elif node == 'view':
|
||||
if node in VIEW_NODES:
|
||||
source_ddl = \
|
||||
view_object.get_sql_from_view_diff(**temp_src_params)
|
||||
temp_src_params.update({'target_schema': target_schema})
|
||||
@ -81,6 +75,15 @@ def _get_source_list(**kwargs):
|
||||
source_dependencies = \
|
||||
view_object.get_view_submodules_dependencies(
|
||||
**temp_src_params)
|
||||
else:
|
||||
source_ddl = \
|
||||
view_object.get_sql_from_table_diff(**temp_src_params)
|
||||
temp_src_params.update({'target_schema': target_schema})
|
||||
diff_ddl = (
|
||||
view_object.get_sql_from_table_diff(**temp_src_params))
|
||||
source_dependencies = \
|
||||
view_object.get_table_submodules_dependencies(
|
||||
**temp_src_params)
|
||||
else:
|
||||
temp_src_params = copy.deepcopy(source_params)
|
||||
temp_src_params['oid'] = source_object_id
|
||||
@ -156,23 +159,23 @@ def _get_target_list(removed, target_dict, node, target_params, view_object,
|
||||
if 'oid' in target_dict[item]:
|
||||
target_object_id = target_dict[item]['oid']
|
||||
|
||||
if node == 'table' or node == 'view':
|
||||
if node in SPECIAL_NODES:
|
||||
temp_tgt_params = copy.deepcopy(target_params)
|
||||
temp_tgt_params['tid'] = target_object_id
|
||||
temp_tgt_params['json_resp'] = False
|
||||
temp_tgt_params['add_not_exists_clause'] = True
|
||||
if node == 'table':
|
||||
target_ddl = (
|
||||
view_object.get_sql_from_table_diff(**temp_tgt_params))
|
||||
_delete_keys(temp_tgt_params)
|
||||
diff_ddl = view_object.get_drop_sql(**temp_tgt_params)
|
||||
elif node == 'view':
|
||||
if node in VIEW_NODES:
|
||||
target_ddl = (
|
||||
view_object.get_sql_from_view_diff(**temp_tgt_params))
|
||||
temp_tgt_params.update(
|
||||
{'drop_sql': True})
|
||||
diff_ddl = (
|
||||
view_object.get_sql_from_view_diff(**temp_tgt_params))
|
||||
else:
|
||||
target_ddl = (
|
||||
view_object.get_sql_from_table_diff(**temp_tgt_params))
|
||||
_delete_keys(temp_tgt_params)
|
||||
diff_ddl = view_object.get_drop_sql(**temp_tgt_params)
|
||||
else:
|
||||
temp_tgt_params = copy.deepcopy(target_params)
|
||||
temp_tgt_params['oid'] = target_object_id
|
||||
@ -308,7 +311,7 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
||||
if 'scid' in target_params else 0,
|
||||
})
|
||||
else:
|
||||
if node == 'table' or node == 'view':
|
||||
if node in SPECIAL_NODES:
|
||||
temp_src_params = copy.deepcopy(source_params)
|
||||
temp_tgt_params = copy.deepcopy(target_params)
|
||||
# Add submodules into the ignore keys so that directory
|
||||
@ -329,7 +332,15 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
||||
temp_src_params['tid'] = source_object_id
|
||||
temp_tgt_params['tid'] = target_object_id
|
||||
|
||||
if node == 'table':
|
||||
if node in VIEW_NODES:
|
||||
source_ddl = \
|
||||
view_object.get_sql_from_view_diff(**temp_src_params)
|
||||
diff_dependencies = \
|
||||
view_object.get_view_submodules_dependencies(
|
||||
**temp_src_params)
|
||||
target_ddl = \
|
||||
view_object.get_sql_from_view_diff(**temp_tgt_params)
|
||||
else:
|
||||
temp_src_params['json_resp'] = \
|
||||
temp_tgt_params['json_resp'] = False
|
||||
|
||||
@ -340,14 +351,6 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
||||
**temp_src_params)
|
||||
target_ddl = \
|
||||
view_object.get_sql_from_table_diff(**temp_tgt_params)
|
||||
elif node == 'view':
|
||||
source_ddl = \
|
||||
view_object.get_sql_from_view_diff(**temp_src_params)
|
||||
diff_dependencies = \
|
||||
view_object.get_view_submodules_dependencies(
|
||||
**temp_src_params)
|
||||
target_ddl = \
|
||||
view_object.get_sql_from_view_diff(**temp_tgt_params)
|
||||
|
||||
diff_ddl = view_object.get_sql_from_submodule_diff(
|
||||
source_params=temp_src_params,
|
||||
|
Loading…
Reference in New Issue
Block a user