Fixed code smells having rule 'Functions, methods and lambdas should not have too many parameters'.

This commit is contained in:
Akshay Joshi 2020-07-03 18:37:37 +05:30
parent 80ab596992
commit 0d92059155
18 changed files with 275 additions and 192 deletions

View File

@ -470,7 +470,7 @@ class UserMappingView(PGChildNodeView):
request.data, encoding='utf-8' request.data, encoding='utf-8'
) )
try: try:
sql, name = self.get_sql(gid, sid, data, did, fid, fsid, umid) sql, name = self.get_sql(data=data, fsid=fsid, umid=umid)
# Most probably this is due to error # Most probably this is due to error
if not isinstance(sql, str): if not isinstance(sql, str):
return sql return sql
@ -596,7 +596,7 @@ class UserMappingView(PGChildNodeView):
except ValueError: except ValueError:
data[k] = v data[k] = v
try: try:
sql, name = self.get_sql(gid, sid, data, did, fid, fsid, umid) sql, name = self.get_sql(data=data, fsid=fsid, umid=umid)
# Most probably this is due to error # Most probably this is due to error
if not isinstance(sql, str): if not isinstance(sql, str):
return sql return sql
@ -609,19 +609,16 @@ class UserMappingView(PGChildNodeView):
except Exception as e: except Exception as e:
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
def get_sql(self, gid, sid, data, did, fid, fsid, umid=None): def get_sql(self, **kwargs):
""" """
This function will generate sql from model data. This function will generate sql from model data.
Args: Args:
gid: Server Group ID kwargs: Server Group ID
sid: Server ID
did: Database ID
data: Contains the data of the selected user mapping node
fid: foreign data wrapper ID
fsid: foreign server ID
umid: User mapping ID
""" """
fsid = kwargs.get('fsid')
data = kwargs.get('data')
umid = kwargs.get('umid', None)
required_args = [ required_args = [
'name' 'name'

View File

@ -817,21 +817,21 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the collation
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -919,21 +919,21 @@ AND relkind != 'c'))"""
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the domains
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -666,7 +666,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
""" """
try: try:
# Get SQL to create Foreign Table # Get SQL to create Foreign Table
SQL, name = self.get_sql(gid, sid, did, scid, self.request) SQL, name = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=self.request)
# Most probably this is due to error # Most probably this is due to error
if not isinstance(SQL, str): if not isinstance(SQL, str):
return SQL return SQL
@ -787,7 +788,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
""" """
try: try:
SQL, name = self.get_sql(gid, sid, did, scid, self.request, foid) SQL, name = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=self.request, foid=foid)
# Most probably this is due to error # Most probably this is due to error
if not isinstance(SQL, str): if not isinstance(SQL, str):
return SQL return SQL
@ -893,7 +895,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
SQL statements to create/update the Foreign Table. SQL statements to create/update the Foreign Table.
""" """
try: try:
SQL, name = self.get_sql(gid, sid, did, scid, self.request, foid) SQL, name = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=self.request, foid=foid)
# Most probably this is due to error # Most probably this is due to error
if not isinstance(SQL, str): if not isinstance(SQL, str):
return SQL return SQL
@ -908,19 +911,21 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
except Exception as e: except Exception as e:
return internal_server_error(errormsg=str(e)) return internal_server_error(errormsg=str(e))
def get_sql(self, gid, sid, did, scid, data, foid=None, def get_sql(self, **kwargs):
is_schema_diff=False):
""" """
Genrates the SQL statements to create/update the Foreign Table. Generates the SQL statements to create/update the Foreign Table.
Args: Args:
gid: Server Group Id kwargs: Server Group Id
sid: Server Id
did: Database Id
scid: Schema Id
foid: Foreign Table Id
is_schema_diff: True is function gets called from schema diff
""" """
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
data = kwargs.get('data')
foid = kwargs.get('foid', None)
is_schema_diff = kwargs.get('is_schema_diff', False)
if foid is not None: if foid is not None:
status, old_data = self._fetch_properties(gid, sid, did, scid, status, old_data = self._fetch_properties(gid, sid, did, scid,
foid, inherits=True) foid, inherits=True)
@ -1447,21 +1452,21 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the domains
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -1007,21 +1007,21 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the fts configuration
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -918,21 +918,21 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the fts configuration
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -950,21 +950,21 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the fts configuration
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -831,21 +831,21 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the fts configuration
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -807,7 +807,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
""" """
# Get SQL to create Function # Get SQL to create Function
status, sql = self._get_sql(gid, sid, did, scid, self.request) status, sql = self._get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=self.request)
if not status: if not status:
return internal_server_error(errormsg=sql) return internal_server_error(errormsg=sql)
@ -918,8 +919,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
fnid: Function Id fnid: Function Id
""" """
status, sql = self._get_sql(gid, sid, did, scid, self.request, fnid) status, sql = self._get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=self.request, fnid=fnid)
if not status: if not status:
return internal_server_error(errormsg=sql) return internal_server_error(errormsg=sql)
@ -1165,7 +1166,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
SQL statements to create/update the Domain. SQL statements to create/update the Domain.
""" """
status, sql = self._get_sql(gid, sid, did, scid, self.request, fnid) status, sql = self._get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=self.request, fnid=fnid)
if status: if status:
sql = re.sub('\n{2,}', '\n\n', sql) sql = re.sub('\n{2,}', '\n\n', sql)
@ -1330,21 +1332,21 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
) )
return sql return sql
def _get_sql(self, gid, sid, did, scid, data, fnid=None, is_sql=False, def _get_sql(self, **kwargs):
is_schema_diff=False):
""" """
Generates the SQL statements to create/update the Function. Generates the SQL statements to create/update the Function.
Args: Args:
gid: Server Group Id kwargs:
sid: Server Id
did: Database Id
scid: Schema Id
data: Function data
fnid: Function Id
is_sql: sql flag
is_schema_diff: schema diff flag
""" """
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
data = kwargs.get('data')
fnid = kwargs.get('fnid', None)
is_sql = kwargs.get('is_sql', False)
is_schema_diff = kwargs.get('is_schema_diff', False)
vol_dict = {'v': 'VOLATILE', 's': 'STABLE', 'i': 'IMMUTABLE'} vol_dict = {'v': 'VOLATILE', 's': 'STABLE', 'i': 'IMMUTABLE'}
parallel_dict = {'u': 'UNSAFE', 's': 'SAFE', 'r': 'RESTRICTED'} parallel_dict = {'u': 'UNSAFE', 's': 'SAFE', 'r': 'RESTRICTED'}
@ -1707,13 +1709,27 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
status=200 status=200
) )
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False): """
This function is used to get the DDL/DML statements.
:param kwargs
:return:
"""
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema
status, sql = self._get_sql(gid, sid, did, scid, data, oid, False, status, sql = self._get_sql(gid=gid, sid=sid, did=did, scid=scid,
True) data=data, fnid=oid, is_sql=False,
is_schema_diff=True)
# Check if return type is changed then we need to drop the # Check if return type is changed then we need to drop the
# function first and then recreate it. # function first and then recreate it.
if 'prorettypename' in data: if 'prorettypename' in data:

View File

@ -381,7 +381,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
) )
data['schema'] = self.schema data['schema'] = self.schema
sql, name = self.getSQL(gid, sid, did, data, scid, None) sql, name = self.getSQL(data=data, scid=scid, pkgid=None)
status, msg = self.conn.execute_scalar(sql) status, msg = self.conn.execute_scalar(sql)
if not status: if not status:
@ -503,7 +503,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
request.data, encoding='utf-8' request.data, encoding='utf-8'
) )
sql, name = self.getSQL(gid, sid, did, data, scid, pkgid) sql, name = self.getSQL(data=data, scid=scid, pkgid=pkgid)
# Most probably this is due to error # Most probably this is due to error
if not isinstance(sql, str): if not isinstance(sql, str):
return sql return sql
@ -558,7 +558,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
).format(arg) ).format(arg)
) )
sql, name = self.getSQL(gid, sid, did, data, scid, pkgid) sql, name = self.getSQL(data=data, scid=scid, pkgid=pkgid)
# Most probably this is due to error # Most probably this is due to error
if not isinstance(sql, str): if not isinstance(sql, str):
return sql return sql
@ -571,21 +571,19 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
status=200 status=200
) )
def getSQL(self, gid, sid, did, data, scid, pkgid=None, sqltab=False, def getSQL(self, **kwargs):
diff_schema=None):
""" """
This function will generate sql from model data. This function will generate sql from model data.
:param kwargs
Args: :return:
gid: Server Group ID
sid: Server ID
did: Database ID
scid: Schema ID
pkgid: Package ID
sqltab: True
diff_schema: Target Schema
""" """
scid = kwargs.get('scid')
data = kwargs.get('data')
pkgid = kwargs.get('pkgid', None)
sqltab = kwargs.get('sqltab', False)
diff_schema = kwargs.get('diff_schema', None)
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema
else: else:
@ -714,8 +712,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
res['rows'][0].setdefault(row['deftype'], []).append(priv) res['rows'][0].setdefault(row['deftype'], []).append(priv)
result = res['rows'][0] result = res['rows'][0]
sql, name = self.getSQL(gid, sid, did, result, scid, pkgid, True, sql, name = self.getSQL(data=result, scid=scid, pkgid=pkgid,
diff_schema) sqltab=True, diff_schema=diff_schema)
# Most probably this is due to error # Most probably this is due to error
if not isinstance(sql, str): if not isinstance(sql, str):
return sql return sql
@ -826,25 +824,25 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Package ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the domains
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema
sql, name = self.getSQL(gid, sid, did, data, scid, oid) sql, name = self.getSQL(data=data, scid=scid, pkgid=oid)
else: else:
if drop_sql: if drop_sql:
sql = self.delete(gid=gid, sid=sid, did=did, sql = self.delete(gid=gid, sid=sid, did=did,

View File

@ -940,20 +940,21 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Sequence ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the domains
:return: :return:
""" """
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -769,21 +769,21 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Synonyms ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the domains
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -875,8 +875,22 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
) )
@check_precondition @check_precondition
def get_sql_from_diff(self, gid, sid, did, scid, tid, oid, def get_sql_from_diff(self, **kwargs):
data=None, diff_schema=None, drop_sql=False): """
This function is used to get the DDL/DML statements.
:param kwargs
:return:
"""
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
tid = kwargs.get('oid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
sql, name = compound_trigger_utils.get_sql(self.conn, sql, name = compound_trigger_utils.get_sql(self.conn,
data, data,

View File

@ -594,15 +594,28 @@ class RowSecurityView(PGChildNodeView):
) )
@check_precondition @check_precondition
def get_sql_from_diff(self, gid, sid, did, scid, tid, plid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_req=False): """
This function is used to get the DDL/DML statements.
:param kwargs
:return:
"""
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
tid = kwargs.get('tid')
oid = kwargs.get('oid')
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['table'] = self.table data['table'] = self.table
sql, name = row_security_policies_utils.get_sql( sql, name = row_security_policies_utils.get_sql(
self.conn, data, did, scid, tid, plid, self.datlastsysoid, self.conn, data, did, scid, tid, oid, self.datlastsysoid,
self.schema, self.table) self.schema, self.table)
sql = sql.strip('\n').strip(' ') sql = sql.strip('\n').strip(' ')
@ -612,7 +625,7 @@ class RowSecurityView(PGChildNodeView):
sql = row_security_policies_utils.get_reverse_engineered_sql( sql = row_security_policies_utils.get_reverse_engineered_sql(
self.conn, schema, self.conn, schema,
self.table, did, scid, tid, plid, self.table, did, scid, tid, oid,
self.datlastsysoid, self.datlastsysoid,
template_path=None, with_header=False) template_path=None, with_header=False)
@ -620,7 +633,7 @@ class RowSecurityView(PGChildNodeView):
if drop_req: if drop_req:
drop_sql = '\n' + self.delete(gid=1, sid=sid, did=did, drop_sql = '\n' + self.delete(gid=1, sid=sid, did=did,
scid=scid, tid=tid, scid=scid, tid=tid,
plid=plid, only_sql=True) plid=oid, only_sql=True)
if drop_sql != '': if drop_sql != '':
sql = drop_sql + '\n\n' + sql sql = drop_sql + '\n\n' + sql
return sql return sql

View File

@ -518,9 +518,22 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
return SQL, data['name'] if 'name' in data else old_data['name'] return SQL, data['name'] if 'name' in data else old_data['name']
@check_precondition @check_precondition
def get_sql_from_diff(self, gid, sid, did, scid, tid, oid, data=None, def get_sql_from_diff(self, **kwargs):
source_schema=None, diff_schema=None, """
drop_sql=False): This function is used to get the DDL/DML statements.
:param kwargs
:return:
"""
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
tid = kwargs.get('oid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
source_schema = kwargs.get('source_schema', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if drop_sql: if drop_sql:
SQL = self.delete(gid=gid, sid=sid, did=did, SQL = self.delete(gid=gid, sid=sid, did=did,

View File

@ -790,8 +790,22 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return ajax_response(response=SQL) return ajax_response(response=SQL)
@check_precondition @check_precondition
def get_sql_from_diff(self, gid, sid, did, scid, tid, oid, def get_sql_from_diff(self, **kwargs):
data=None, diff_schema=None, drop_sql=False): """
This function is used to get the DDL/DML statements.
:param kwargs
:return:
"""
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
tid = kwargs.get('oid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
SQL, name = trigger_utils.get_sql( SQL, name = trigger_utils.get_sql(
self.conn, data, tid, oid, self.conn, data, tid, oid,

View File

@ -1492,21 +1492,21 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False):
""" """
This function is used to get the DDL/DML statements. This function is used to get the DDL/DML statements.
:param gid: Group ID :param kwargs
:param sid: Serve ID
:param did: Database ID
:param scid: Schema ID
:param oid: Collation ID
:param data: Difference data
:param diff_schema: Target Schema
:param drop_sql: True if need to drop the types
:return: :return:
""" """
sql = '' gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema

View File

@ -1526,9 +1526,21 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
return res return res
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None, def get_sql_from_diff(self, **kwargs):
diff_schema=None, drop_sql=False): """
sql = '' This function is used to get the DDL/DML statements.
:param kwargs
:return:
"""
gid = kwargs.get('gid')
sid = kwargs.get('sid')
did = kwargs.get('did')
scid = kwargs.get('scid')
oid = kwargs.get('oid')
data = kwargs.get('data', None)
diff_schema = kwargs.get('diff_schema', None)
drop_sql = kwargs.get('drop_sql', False)
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema