Fixed code smell 'Functions, methods, and lambdas should not have too many parameters' reported by SonarQube.

This commit is contained in:
Akshay Joshi 2020-07-07 19:39:06 +05:30
parent 36a2c073bd
commit b4c25bdc0a
12 changed files with 184 additions and 148 deletions

View File

@ -597,7 +597,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
return gone(gettext("The specified table could not be found.")) return gone(gettext("The specified table could not be found."))
return super(TableView, self).properties( return super(TableView, self).properties(
gid, sid, did, scid, tid, res gid, sid, did, scid, tid, res=res
) )
def _fetch_properties(self, did, scid, tid): def _fetch_properties(self, did, scid, tid):
@ -1082,7 +1082,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
return res return res
return super(TableView, self).update( return super(TableView, self).update(
gid, sid, did, scid, tid, data, res) gid, sid, did, scid, tid, data=data, res=res)
except Exception as e: except Exception as e:
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
@ -1282,7 +1282,8 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
data['schema'] = diff_schema data['schema'] = diff_schema
sql, partition_sql = BaseTableView.get_reverse_engineered_sql( sql, partition_sql = BaseTableView.get_reverse_engineered_sql(
self, did, scid, tid, main_sql, data, json_resp) self, did=did, scid=scid, tid=tid, main_sql=main_sql,
data=data, json_resp=json_resp)
return sql return sql
@ -1390,7 +1391,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
data = res['rows'][0] data = res['rows'][0]
return BaseTableView.get_reverse_engineered_sql( return BaseTableView.get_reverse_engineered_sql(
self, did, scid, tid, main_sql, data) self, did=did, scid=scid, tid=tid, main_sql=main_sql, data=data)
@BaseTableView.check_precondition @BaseTableView.check_precondition
def select_sql(self, gid, sid, did, scid, tid): def select_sql(self, gid, sid, did, scid, tid):
@ -1682,7 +1683,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
return False return False
data = super(TableView, self).properties( data = super(TableView, self).properties(
0, sid, did, scid, tid, data, False 0, sid, did, scid, tid, res=data, return_ajax_response=False
) )
return data return data
@ -1701,7 +1702,8 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
if status: if status:
data = super(TableView, self).properties( data = super(TableView, self).properties(
0, sid, did, scid, row['oid'], data, False 0, sid, did, scid, row['oid'], res=data,
return_ajax_response=False
) )
# Get sub module data of a specified table for object # Get sub module data of a specified table for object

View File

@ -751,8 +751,8 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
try: try:
SQL = compound_trigger_utils.get_reverse_engineered_sql( SQL = compound_trigger_utils.get_reverse_engineered_sql(
self.conn, self.schema, self.table, tid, trid, self.conn, schema=self.schema, table=self.table, tid=tid,
self.datlastsysoid) trid=trid, datlastsysoid=self.datlastsysoid)
except Exception as e: except Exception as e:
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))

View File

@ -143,19 +143,20 @@ def get_sql(conn, data, tid, trid, datlastsysoid, template_path=None):
@get_template_path @get_template_path
def get_reverse_engineered_sql(conn, schema, table, tid, trid, def get_reverse_engineered_sql(conn, **kwargs):
datlastsysoid, template_path=None):
""" """
This function will return reverse engineered sql for trigger(s). This function will return reverse engineered sql for trigger(s).
:param conn: Connection Object :param conn: Connection Object
:param schema: Schema :param kwargs
:param table: Table
:param tid: Table ID
:param trid: Trigger ID
:param datlastsysoid:
:param template_path: Optional template path
:return: :return:
""" """
schema = kwargs.get('schema')
table = kwargs.get('table')
tid = kwargs.get('tid')
trid = kwargs.get('trid')
datlastsysoid = kwargs.get('datlastsysoid')
template_path = kwargs.get('template_path', None)
SQL = render_template("/".join([template_path, 'properties.sql']), SQL = render_template("/".join([template_path, 'properties.sql']),
tid=tid, trid=trid, tid=tid, trid=trid,
datlastsysoid=datlastsysoid) datlastsysoid=datlastsysoid)

View File

@ -745,7 +745,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
data['table'] = self.table data['table'] = self.table
try: try:
SQL, name = index_utils.get_sql( SQL, name = index_utils.get_sql(
self.conn, data, did, tid, idx, self.datlastsysoid) self.conn, data=data, did=did, tid=tid, idx=idx,
datlastsysoid=self.datlastsysoid)
if not isinstance(SQL, str): if not isinstance(SQL, str):
return SQL return SQL
SQL = SQL.strip('\n').strip(' ') SQL = SQL.strip('\n').strip(' ')
@ -795,8 +796,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
sql, name = index_utils.get_sql( sql, name = index_utils.get_sql(
self.conn, data, did, tid, idx, self.datlastsysoid, self.conn, data=data, did=did, tid=tid, idx=idx,
mode='create') datlastsysoid=self.datlastsysoid, mode='create')
if not isinstance(sql, str): if not isinstance(sql, str):
return sql return sql
sql = sql.strip('\n').strip(' ') sql = sql.strip('\n').strip(' ')
@ -824,24 +825,36 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = index_utils.get_reverse_engineered_sql( SQL = index_utils.get_reverse_engineered_sql(
self.conn, self.schema, self.table, did, tid, idx, self.conn, schema=self.schema, table=self.table, did=did,
self.datlastsysoid) tid=tid, idx=idx, datlastsysoid=self.datlastsysoid)
return ajax_response(response=SQL) return ajax_response(response=SQL)
@check_precondition @check_precondition
def get_sql_from_index_diff(self, sid, did, scid, tid, idx, data=None, def get_sql_from_index_diff(self, **kwargs):
diff_schema=None, drop_req=False): """
This function get the sql from index diff.
:param kwargs:
:return:
"""
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
tid = kwargs.get('tid')
idx = kwargs.get('idx')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_req = kwargs.get('drop_req', False)
sql = '' sql = ''
if data: if data:
data['schema'] = self.schema data['schema'] = self.schema
data['nspname'] = self.schema data['nspname'] = self.schema
data['table'] = self.table data['table'] = self.table
sql, name = index_utils.get_sql( sql, name = index_utils.get_sql(
self.conn, data, did, tid, idx, self.datlastsysoid, self.conn, data=data, did=did, tid=tid, idx=idx,
mode='create') datlastsysoid=self.datlastsysoid, mode='create')
sql = sql.strip('\n').strip(' ') sql = sql.strip('\n').strip(' ')

View File

@ -193,21 +193,23 @@ def _get_sql_with_index_none(data, template_path, conn, mode, name):
@get_template_path @get_template_path
def get_sql(conn, data, did, tid, idx, datlastsysoid, def get_sql(conn, **kwargs):
mode=None, template_path=None):
""" """
This function will generate sql from model data. This function will generate sql from model data.
:param conn: Connection Object :param conn: Connection Object
:param data: Data :param kwargs:
:param did:
:param tid: Table ID
:param idx: Index ID
:param datlastsysoid:
:param mode:
:param template_path: Optional template path
:return: :return:
""" """
data = kwargs.get('data')
did = kwargs.get('did')
tid = kwargs.get('tid')
idx = kwargs.get('idx')
datlastsysoid = kwargs.get('datlastsysoid')
mode = kwargs.get('mode', None)
template_path = kwargs.get('template_path', None)
name = data['name'] if 'name' in data else None name = data['name'] if 'name' in data else None
if idx is not None: if idx is not None:
sql = render_template("/".join([template_path, 'properties.sql']), sql = render_template("/".join([template_path, 'properties.sql']),
@ -249,23 +251,23 @@ def get_sql(conn, data, did, tid, idx, datlastsysoid,
@get_template_path @get_template_path
def get_reverse_engineered_sql(conn, schema, table, did, tid, idx, def get_reverse_engineered_sql(conn, **kwargs):
datlastsysoid,
template_path=None, with_header=True):
""" """
This function will return reverse engineered sql for specified trigger. This function will return reverse engineered sql for specified trigger.
:param conn: Connection Object :param conn: Connection Object
:param schema: Schema :param kwargs:
:param table: Table
:param tid: Table ID
:param idx: Index ID
:param datlastsysoid:
:param template_path: Optional template path
:param with_header: Optional parameter to decide whether the SQL will be
returned with header or not
:return: :return:
""" """
schema = kwargs.get('schema')
table = kwargs.get('table')
did = kwargs.get('did')
tid = kwargs.get('tid')
idx = kwargs.get('idx')
datlastsysoid = kwargs.get('datlastsysoid')
template_path = kwargs.get('template_path', None)
with_header = kwargs.get('with_header', True)
SQL = render_template("/".join([template_path, 'properties.sql']), SQL = render_template("/".join([template_path, 'properties.sql']),
did=did, tid=tid, idx=idx, did=did, tid=tid, idx=idx,
datlastsysoid=datlastsysoid) datlastsysoid=datlastsysoid)
@ -289,7 +291,8 @@ def get_reverse_engineered_sql(conn, schema, table, did, tid, idx,
if conn.manager.version >= 110000: if conn.manager.version >= 110000:
data = get_include_details(conn, idx, data) data = get_include_details(conn, idx, data)
SQL, name = get_sql(conn, data, did, tid, None, datlastsysoid) SQL, name = get_sql(conn, data=data, did=did, tid=tid, idx=None,
datlastsysoid=datlastsysoid)
if with_header: if with_header:
sql_header = u"-- Index: {0}\n\n-- ".format(data['name']) sql_header = u"-- Index: {0}\n\n-- ".format(data['name'])

View File

@ -458,8 +458,8 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
data = res['rows'][0] data = res['rows'][0]
return BaseTableView.get_reverse_engineered_sql(self, did, scid, ptid, return BaseTableView.get_reverse_engineered_sql(
main_sql, data) self, did=did, scid=scid, tid=ptid, main_sql=main_sql, data=data)
@BaseTableView.check_precondition @BaseTableView.check_precondition
def get_sql_from_diff(self, **kwargs): def get_sql_from_diff(self, **kwargs):

View File

@ -64,13 +64,16 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare):
len(source_tables) <= 0 and len(target_tables) <= 0): len(source_tables) <= 0 and len(target_tables) <= 0):
return None return None
return compare_dictionaries(self, source_params, target_params, return compare_dictionaries(view_object=self,
target_schema, source_tables, source_params=source_params,
target_tables, target_params=target_params,
self.node_type, target_schema=target_schema,
self.blueprint.COLLECTION_LABEL, source_dict=source_tables,
ignore_whitespaces, target_dict=target_tables,
self.keys_to_ignore) node=self.node_type,
node_label=self.blueprint.COLLECTION_LABEL,
ignore_whitespaces=ignore_whitespaces,
ignore_keys=self.keys_to_ignore)
def ddl_compare(self, **kwargs): def ddl_compare(self, **kwargs):
""" """
@ -226,22 +229,22 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare):
return different return different
def get_sql_from_submodule_diff(self, source_params, target_params, def get_sql_from_submodule_diff(self, **kwargs):
target_schema, source, target, diff_dict,
ignore_whitespaces):
""" """
This function returns the DDL/DML statements of the This function returns the DDL/DML statements of the
submodules of table based on the comparison status. submodules of table based on the comparison status.
:param source_params: :param kwargs:
:param target_params:
:param target_schema:
:param source:
:param target:
:param diff_dict:
:param ignore_whitespaces:
:return: :return:
""" """
source_params = kwargs.get('source_params')
target_params = kwargs.get('target_params')
target_schema = kwargs.get('target_schema')
source = kwargs.get('source')
target = kwargs.get('target')
diff_dict = kwargs.get('diff_dict')
ignore_whitespaces = kwargs.get('ignore_whitespaces')
# Get the difference result for source and target columns # Get the difference result for source and target columns
col_diff = self.table_col_comp(source, target) col_diff = self.table_col_comp(source, target)
diff_dict.update(col_diff) diff_dict.update(col_diff)

View File

@ -672,8 +672,9 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
data['table'] = self.table data['table'] = self.table
SQL, name = trigger_utils.get_sql( SQL, name = trigger_utils.get_sql(
self.conn, data, tid, trid, self.datlastsysoid, self.conn, data=data, tid=tid, trid=trid,
self.blueprint.show_system_objects) datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects)
if not isinstance(SQL, str): if not isinstance(SQL, str):
return SQL return SQL
@ -754,8 +755,9 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
sql, name = trigger_utils.get_sql( sql, name = trigger_utils.get_sql(
self.conn, data, tid, trid, self.datlastsysoid, self.conn, data=data, tid=tid, trid=trid,
self.blueprint.show_system_objects) datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects)
if not isinstance(sql, str): if not isinstance(sql, str):
return sql return sql
sql = sql.strip('\n').strip(' ') sql = sql.strip('\n').strip(' ')
@ -784,8 +786,9 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = trigger_utils.get_reverse_engineered_sql( SQL = trigger_utils.get_reverse_engineered_sql(
self.conn, self.schema, self.table, tid, trid, self.conn, schema=self.schema, table=self.table, tid=tid,
self.datlastsysoid, self.blueprint.show_system_objects) trid=trid, datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects)
return ajax_response(response=SQL) return ajax_response(response=SQL)
@ -808,9 +811,10 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
if data: if data:
SQL, name = trigger_utils.get_sql( SQL, name = trigger_utils.get_sql(
self.conn, data, tid, oid, self.conn, data=data, tid=tid, trid=oid,
self.datlastsysoid, datlastsysoid=self.datlastsysoid,
self.blueprint.show_system_objects, True) show_system_objects=self.blueprint.show_system_objects,
is_schema_diff=True)
if not isinstance(SQL, str): if not isinstance(SQL, str):
return SQL return SQL
@ -825,10 +829,9 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
if diff_schema: if diff_schema:
schema = diff_schema schema = diff_schema
SQL = trigger_utils.get_reverse_engineered_sql( SQL = trigger_utils.get_reverse_engineered_sql(
self.conn, schema, self.conn, schema=schema, table=self.table, tid=tid,
self.table, tid, oid, trid=oid, datlastsysoid=self.datlastsysoid,
self.datlastsysoid, show_system_objects=self.blueprint.show_system_objects,
self.blueprint.show_system_objects,
template_path=None, with_header=False) template_path=None, with_header=False)
return SQL return SQL

View File

@ -140,21 +140,22 @@ def get_trigger_function_and_columns(conn, data, tid,
@get_template_path @get_template_path
def get_sql(conn, data, tid, trid, datlastsysoid, def get_sql(conn, **kwargs):
show_system_objects, is_schema_diff=False, template_path=None):
""" """
This function will generate sql from model data. This function will generate sql from model data.
:param conn: Connection Object :param conn: Connection Object
:param data: Data :param kwargs
:param tid: Table ID
:param trid: Trigger ID
:param datlastsysoid:
:param show_system_objects: Show System Object value True or False
:param is_schema_diff:
:param template_path: Optional template path
:return: :return:
""" """
data = kwargs.get('data')
tid = kwargs.get('tid')
trid = kwargs.get('trid')
datlastsysoid = kwargs.get('datlastsysoid')
show_system_objects = kwargs.get('show_system_objects')
is_schema_diff = kwargs.get('is_schema_diff', False)
template_path = kwargs.get('template_path', None)
name = data['name'] if 'name' in data else None name = data['name'] if 'name' in data else None
if trid is not None: if trid is not None:
sql = render_template("/".join([template_path, 'properties.sql']), sql = render_template("/".join([template_path, 'properties.sql']),
@ -232,24 +233,23 @@ def get_sql(conn, data, tid, trid, datlastsysoid,
@get_template_path @get_template_path
def get_reverse_engineered_sql(conn, schema, table, tid, trid, def get_reverse_engineered_sql(conn, **kwargs):
datlastsysoid, show_system_objects,
template_path=None, with_header=True):
""" """
This function will return reverse engineered sql for specified trigger. This function will return reverse engineered sql for specified trigger.
:param conn: Connection Object :param conn: Connection Object
:param schema: Schema :param kwargs:
:param table: Table
:param tid: Table ID
:param trid: Trigger ID
:param datlastsysoid:
:param show_system_objects: Show System Object value True or False
:param template_path: Optional template path
:param with_header: Optional parameter to decide whether the SQL will be
returned with header or not
:return: :return:
""" """
schema = kwargs.get('schema')
table = kwargs.get('table')
tid = kwargs.get('tid')
trid = kwargs.get('trid')
datlastsysoid = kwargs.get('datlastsysoid')
show_system_objects = kwargs.get('show_system_objects')
template_path = kwargs.get('template_path', None)
with_header = kwargs.get('with_header', True)
SQL = render_template("/".join([template_path, 'properties.sql']), SQL = render_template("/".join([template_path, 'properties.sql']),
tid=tid, trid=trid, tid=tid, trid=trid,
datlastsysoid=datlastsysoid) datlastsysoid=datlastsysoid)
@ -272,8 +272,9 @@ def get_reverse_engineered_sql(conn, schema, table, tid, trid,
data = trigger_definition(data) data = trigger_definition(data)
SQL, name = get_sql(conn, data, tid, None, datlastsysoid, SQL, name = get_sql(conn, data=data, tid=tid, trid=None,
show_system_objects) datlastsysoid=datlastsysoid,
show_system_objects=show_system_objects)
if with_header: if with_header:
sql_header = u"-- Trigger: {0}\n\n-- ".format(data['name']) sql_header = u"-- Trigger: {0}\n\n-- ".format(data['name'])

View File

@ -414,22 +414,22 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
status=200 status=200
) )
def get_reverse_engineered_sql(self, did, scid, tid, main_sql, data, def get_reverse_engineered_sql(self, **kwargs):
json_resp=True, diff_partition_sql=False):
""" """
This function will creates reverse engineered sql for This function will creates reverse engineered sql for
the table object the table object
Args: Args:
did: Database ID kwargs
scid: Schema ID
tid: Table ID
main_sql: List contains all the reversed engineered sql
data: Table's Data
json_resp: Json response or plain SQL
diff_partition_sql: In Schema diff, the Partition sql should be
return separately to perform further task
""" """
did = kwargs.get('did')
scid = kwargs.get('scid')
tid = kwargs.get('tid')
main_sql = kwargs.get('main_sql')
data = kwargs.get('data')
json_resp = kwargs.get('json_resp', True)
diff_partition_sql = kwargs.get('diff_partition_sql', False)
""" """
##################################### #####################################
# 1) Reverse engineered sql for TABLE # 1) Reverse engineered sql for TABLE
@ -508,8 +508,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
tables.indexes import utils as index_utils tables.indexes import utils as index_utils
for row in rset['rows']: for row in rset['rows']:
index_sql = index_utils.get_reverse_engineered_sql( index_sql = index_utils.get_reverse_engineered_sql(
self.conn, schema, table, did, tid, row['oid'], self.conn, schema=schema, table=table, did=did, tid=tid,
self.datlastsysoid, idx=row['oid'], datlastsysoid=self.datlastsysoid,
template_path=None, with_header=json_resp) template_path=None, with_header=json_resp)
index_sql = u"\n" + index_sql index_sql = u"\n" + index_sql
@ -533,10 +533,10 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
for row in rset['rows']: for row in rset['rows']:
policy_sql = row_security_policies_utils. \ policy_sql = row_security_policies_utils.\
get_reverse_engineered_sql( get_reverse_engineered_sql(
self.conn, schema, table, did, scid, tid, row['oid'], self.conn, schema=schema, table=table, scid=scid,
self.datlastsysoid, plid=row['oid'], datlastsysoid=self.datlastsysoid,
template_path=None, with_header=json_resp) template_path=None, with_header=json_resp)
policy_sql = u"\n" + policy_sql policy_sql = u"\n" + policy_sql
@ -558,8 +558,9 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
for row in rset['rows']: for row in rset['rows']:
trigger_sql = trigger_utils.get_reverse_engineered_sql( trigger_sql = trigger_utils.get_reverse_engineered_sql(
self.conn, schema, table, tid, row['oid'], self.conn, schema=schema, table=table, tid=tid,
self.datlastsysoid, self.blueprint.show_system_objects, trid=row['oid'], datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects,
template_path=None, with_header=json_resp) template_path=None, with_header=json_resp)
trigger_sql = u"\n" + trigger_sql trigger_sql = u"\n" + trigger_sql
@ -585,8 +586,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
for row in rset['rows']: for row in rset['rows']:
compound_trigger_sql = \ compound_trigger_sql = \
compound_trigger_utils.get_reverse_engineered_sql( compound_trigger_utils.get_reverse_engineered_sql(
self.conn, schema, table, tid, row['oid'], self.conn, schema=schema, table=table, tid=tid,
self.datlastsysoid) trid=row['oid'], datlastsysoid=self.datlastsysoid)
compound_trigger_sql = u"\n" + compound_trigger_sql compound_trigger_sql = u"\n" + compound_trigger_sql
# Add into main sql # Add into main sql
@ -1084,7 +1085,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
return SQL, data['name'] if 'name' in data else old_data['name'] return SQL, data['name'] if 'name' in data else old_data['name']
def update(self, gid, sid, did, scid, tid, data, res, parent_id=None): def update(self, gid, sid, did, scid, tid, **kwargs):
""" """
This function will update an existing table object This function will update an existing table object
@ -1099,6 +1100,10 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
parent_id: parent table id if current table is partition of parent parent_id: parent table id if current table is partition of parent
table else none table else none
""" """
data = kwargs.get('data')
res = kwargs.get('res')
parent_id = kwargs.get('parent_id', None)
# checking the table existence using the function of the same class # checking the table existence using the function of the same class
schema_name, table_name = self.get_schema_and_table_name(tid) schema_name, table_name = self.get_schema_and_table_name(tid)
@ -1221,8 +1226,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
except Exception as e: except Exception as e:
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
def properties(self, gid, sid, did, scid, tid, res, def properties(self, gid, sid, did, scid, tid, **kwargs):
return_ajax_response=True):
""" """
This function will show the properties of the selected table node. This function will show the properties of the selected table node.
@ -1233,12 +1237,13 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
scid: Schema ID scid: Schema ID
scid: Schema ID scid: Schema ID
tid: Table ID tid: Table ID
res: Table/Partition table properties
return_ajax_response: If True then return the ajax response
Returns: Returns:
JSON of selected table node JSON of selected table node
""" """
res = kwargs.get('res')
return_ajax_response = kwargs.get('return_ajax_response', True)
data = res['rows'][0] data = res['rows'][0]
data['vacuum_settings_str'] = '' data['vacuum_settings_str'] = ''

View File

@ -85,12 +85,16 @@ class SchemaDiffObjectCompare:
len(source) <= 0 and len(target) <= 0): len(source) <= 0 and len(target) <= 0):
return None return None
return compare_dictionaries(self, source_params, target_params, return compare_dictionaries(view_object=self,
target_schema, source, target, source_params=source_params,
self.node_type, target_params=target_params,
gettext(self.blueprint.COLLECTION_LABEL), target_schema=target_schema,
ignore_whitespaces, source_dict=source,
self.keys_to_ignore) target_dict=target,
node=self.node_type,
node_label=self.blueprint.COLLECTION_LABEL,
ignore_whitespaces=ignore_whitespaces,
ignore_keys=self.keys_to_ignore)
def ddl_compare(self, **kwargs): def ddl_compare(self, **kwargs):
""" """

View File

@ -19,25 +19,23 @@ list_keys_array = ['name', 'colname', 'argid', 'token', 'option', 'conname',
'member_name', 'label', 'attname'] 'member_name', 'label', 'attname']
def compare_dictionaries(view_object, source_params, target_params, def compare_dictionaries(**kwargs):
target_schema, source_dict, target_dict, node,
node_label, ignore_whitespaces,
ignore_keys=None):
""" """
This function will compare the two dictionaries. This function will compare the two dictionaries.
:param view_object: View Object :param kwargs:
:param source_params: Source Parameters
:param target_params: Target Parameters
:param target_schema: Target Schema Name
:param source_dict: First Dictionary
:param target_dict: Second Dictionary
:param node: node type
:param node_label: node label
:param ignore_whitespaces: If set the True then ignore whitespaces
:param ignore_keys: List of keys that will be ignored while comparing
:return: :return:
""" """
view_object = kwargs.get('view_object')
source_params = kwargs.get('source_params')
target_params = kwargs.get('target_params')
target_schema = kwargs.get('target_schema')
source_dict = kwargs.get('source_dict')
target_dict = kwargs.get('target_dict')
node = kwargs.get('node')
node_label = kwargs.get('node_label')
ignore_whitespaces = kwargs.get('ignore_whitespaces')
ignore_keys = kwargs.get('ignore_keys', None)
dict1 = copy.deepcopy(source_dict) dict1 = copy.deepcopy(source_dict)
dict2 = copy.deepcopy(target_dict) dict2 = copy.deepcopy(target_dict)
@ -179,8 +177,11 @@ def compare_dictionaries(view_object, source_params, target_params,
target_ddl = \ target_ddl = \
view_object.get_sql_from_table_diff(**temp_tgt_params) view_object.get_sql_from_table_diff(**temp_tgt_params)
diff_ddl = view_object.get_sql_from_submodule_diff( diff_ddl = view_object.get_sql_from_submodule_diff(
temp_src_params, temp_tgt_params, target_schema, source_params=temp_src_params,
dict1[key], dict2[key], diff_dict, ignore_whitespaces) target_params=temp_tgt_params,
target_schema=target_schema,
source=dict1[key], target=dict2[key], diff_dict=diff_dict,
ignore_whitespaces=ignore_whitespaces)
else: else:
temp_src_params = copy.deepcopy(source_params) temp_src_params = copy.deepcopy(source_params)
temp_tgt_params = copy.deepcopy(target_params) temp_tgt_params = copy.deepcopy(target_params)