mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed code smells having rule 'Functions, methods and lambdas should not have too many parameters'.
This commit is contained in:
parent
80ab596992
commit
0d92059155
@ -470,7 +470,7 @@ class UserMappingView(PGChildNodeView):
|
||||
request.data, encoding='utf-8'
|
||||
)
|
||||
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
|
||||
if not isinstance(sql, str):
|
||||
return sql
|
||||
@ -596,7 +596,7 @@ class UserMappingView(PGChildNodeView):
|
||||
except ValueError:
|
||||
data[k] = v
|
||||
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
|
||||
if not isinstance(sql, str):
|
||||
return sql
|
||||
@ -609,19 +609,16 @@ class UserMappingView(PGChildNodeView):
|
||||
except Exception as 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.
|
||||
|
||||
Args:
|
||||
gid: 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
|
||||
kwargs: Server Group ID
|
||||
"""
|
||||
fsid = kwargs.get('fsid')
|
||||
data = kwargs.get('data')
|
||||
umid = kwargs.get('umid', None)
|
||||
|
||||
required_args = [
|
||||
'name'
|
||||
|
@ -817,21 +817,21 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -919,21 +919,21 @@ AND relkind != 'c'))"""
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -666,7 +666,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
"""
|
||||
try:
|
||||
# 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
|
||||
if not isinstance(SQL, str):
|
||||
return SQL
|
||||
@ -787,7 +788,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
"""
|
||||
|
||||
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
|
||||
if not isinstance(SQL, str):
|
||||
return SQL
|
||||
@ -893,7 +895,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
SQL statements to create/update the Foreign Table.
|
||||
"""
|
||||
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
|
||||
if not isinstance(SQL, str):
|
||||
return SQL
|
||||
@ -908,19 +911,21 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
def get_sql(self, gid, sid, did, scid, data, foid=None,
|
||||
is_schema_diff=False):
|
||||
def get_sql(self, **kwargs):
|
||||
"""
|
||||
Genrates the SQL statements to create/update the Foreign Table.
|
||||
Generates the SQL statements to create/update the Foreign Table.
|
||||
|
||||
Args:
|
||||
gid: 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
|
||||
kwargs: Server Group Id
|
||||
"""
|
||||
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:
|
||||
status, old_data = self._fetch_properties(gid, sid, did, scid,
|
||||
foid, inherits=True)
|
||||
@ -1447,21 +1452,21 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -1007,21 +1007,21 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -918,21 +918,21 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -950,21 +950,21 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -831,21 +831,21 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -807,7 +807,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
||||
"""
|
||||
|
||||
# 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:
|
||||
return internal_server_error(errormsg=sql)
|
||||
|
||||
@ -918,8 +919,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
||||
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:
|
||||
return internal_server_error(errormsg=sql)
|
||||
|
||||
@ -1165,7 +1166,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
||||
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:
|
||||
sql = re.sub('\n{2,}', '\n\n', sql)
|
||||
@ -1330,21 +1332,21 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
||||
)
|
||||
return sql
|
||||
|
||||
def _get_sql(self, gid, sid, did, scid, data, fnid=None, is_sql=False,
|
||||
is_schema_diff=False):
|
||||
def _get_sql(self, **kwargs):
|
||||
"""
|
||||
Generates the SQL statements to create/update the Function.
|
||||
|
||||
Args:
|
||||
gid: Server Group Id
|
||||
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
|
||||
kwargs:
|
||||
"""
|
||||
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'}
|
||||
parallel_dict = {'u': 'UNSAFE', 's': 'SAFE', 'r': 'RESTRICTED'}
|
||||
@ -1707,13 +1709,27 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
||||
status=200
|
||||
)
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
status, sql = self._get_sql(gid, sid, did, scid, data, oid, False,
|
||||
True)
|
||||
status, sql = self._get_sql(gid=gid, sid=sid, did=did, scid=scid,
|
||||
data=data, fnid=oid, is_sql=False,
|
||||
is_schema_diff=True)
|
||||
# Check if return type is changed then we need to drop the
|
||||
# function first and then recreate it.
|
||||
if 'prorettypename' in data:
|
||||
|
@ -381,7 +381,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
)
|
||||
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)
|
||||
if not status:
|
||||
@ -503,7 +503,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
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
|
||||
if not isinstance(sql, str):
|
||||
return sql
|
||||
@ -558,7 +558,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
).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
|
||||
if not isinstance(sql, str):
|
||||
return sql
|
||||
@ -571,21 +571,19 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
status=200
|
||||
)
|
||||
|
||||
def getSQL(self, gid, sid, did, data, scid, pkgid=None, sqltab=False,
|
||||
diff_schema=None):
|
||||
def getSQL(self, **kwargs):
|
||||
"""
|
||||
This function will generate sql from model data.
|
||||
|
||||
Args:
|
||||
gid: Server Group ID
|
||||
sid: Server ID
|
||||
did: Database ID
|
||||
scid: Schema ID
|
||||
pkgid: Package ID
|
||||
sqltab: True
|
||||
diff_schema: Target Schema
|
||||
:param kwargs
|
||||
:return:
|
||||
"""
|
||||
|
||||
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:
|
||||
data['schema'] = diff_schema
|
||||
else:
|
||||
@ -714,8 +712,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
res['rows'][0].setdefault(row['deftype'], []).append(priv)
|
||||
|
||||
result = res['rows'][0]
|
||||
sql, name = self.getSQL(gid, sid, did, result, scid, pkgid, True,
|
||||
diff_schema)
|
||||
sql, name = self.getSQL(data=result, scid=scid, pkgid=pkgid,
|
||||
sqltab=True, diff_schema=diff_schema)
|
||||
# Most probably this is due to error
|
||||
if not isinstance(sql, str):
|
||||
return sql
|
||||
@ -826,25 +824,25 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 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:
|
||||
if drop_sql:
|
||||
sql = self.delete(gid=gid, sid=sid, did=did,
|
||||
|
@ -940,20 +940,21 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -769,21 +769,21 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -875,8 +875,22 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, tid, oid,
|
||||
data=None, diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
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:
|
||||
sql, name = compound_trigger_utils.get_sql(self.conn,
|
||||
data,
|
||||
|
@ -594,15 +594,28 @@ class RowSecurityView(PGChildNodeView):
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, tid, plid, data=None,
|
||||
diff_schema=None, drop_req=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
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 = ''
|
||||
if data:
|
||||
data['schema'] = self.schema
|
||||
data['table'] = self.table
|
||||
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)
|
||||
|
||||
sql = sql.strip('\n').strip(' ')
|
||||
@ -612,7 +625,7 @@ class RowSecurityView(PGChildNodeView):
|
||||
|
||||
sql = row_security_policies_utils.get_reverse_engineered_sql(
|
||||
self.conn, schema,
|
||||
self.table, did, scid, tid, plid,
|
||||
self.table, did, scid, tid, oid,
|
||||
self.datlastsysoid,
|
||||
template_path=None, with_header=False)
|
||||
|
||||
@ -620,7 +633,7 @@ class RowSecurityView(PGChildNodeView):
|
||||
if drop_req:
|
||||
drop_sql = '\n' + self.delete(gid=1, sid=sid, did=did,
|
||||
scid=scid, tid=tid,
|
||||
plid=plid, only_sql=True)
|
||||
plid=oid, only_sql=True)
|
||||
if drop_sql != '':
|
||||
sql = drop_sql + '\n\n' + sql
|
||||
return sql
|
||||
|
@ -518,9 +518,22 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return SQL, data['name'] if 'name' in data else old_data['name']
|
||||
|
||||
@check_precondition
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, tid, oid, data=None,
|
||||
source_schema=None, diff_schema=None,
|
||||
drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
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:
|
||||
SQL = self.delete(gid=gid, sid=sid, did=did,
|
||||
|
@ -790,8 +790,22 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return ajax_response(response=SQL)
|
||||
|
||||
@check_precondition
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, tid, oid,
|
||||
data=None, diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
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:
|
||||
SQL, name = trigger_utils.get_sql(
|
||||
self.conn, data, tid, oid,
|
||||
|
@ -1492,21 +1492,21 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
This function is used to get the DDL/DML statements.
|
||||
:param gid: Group ID
|
||||
: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
|
||||
:param kwargs
|
||||
: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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
@ -1526,9 +1526,21 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
|
||||
|
||||
return res
|
||||
|
||||
def get_sql_from_diff(self, gid, sid, did, scid, oid, data=None,
|
||||
diff_schema=None, drop_sql=False):
|
||||
sql = ''
|
||||
def get_sql_from_diff(self, **kwargs):
|
||||
"""
|
||||
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 diff_schema:
|
||||
data['schema'] = diff_schema
|
||||
|
Loading…
Reference in New Issue
Block a user