mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-07-07 04:53:25 -05:00
1) Added 'Ignore Grants' option in the schema diff tool. #5759
2) Added 'Ignore Tablespace' option in the schema diff tool. #6004 3) Ensure that Schema Diff comparison results should be displayed in the sorted order. #6595 4) Fixed an issue where the SET directive is excluded from the function header in the schema diff tool. #6651
This commit is contained in:
parent
e80d55e968
commit
3c43aa12af
Binary file not shown.
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 158 KiB |
Binary file not shown.
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 88 KiB |
|
@ -529,9 +529,13 @@ Expand the *Schema Diff* node to specify your display preferences.
|
|||
:alt: Preferences schema diff
|
||||
:align: center
|
||||
|
||||
Use the *Ignore owner* switch to ignores the owner while comparing the objects.
|
||||
Use the *Ignore Grant/Revoke* switch to ignores the grant and revoke command while comparing the objects.
|
||||
|
||||
Use the *Ignore whitespace* switch to ignores the whitespace while comparing
|
||||
Use the *Ignore Owner* switch to ignores the owner while comparing the objects.
|
||||
|
||||
Use the *Ignore Tablespace* switch to ignores the tablespace while comparing the objects.
|
||||
|
||||
Use the *Ignore Whitespace* switch to ignores the whitespace while comparing
|
||||
the string objects. Whitespace includes space, tabs, and CRLF.
|
||||
|
||||
|
||||
|
|
|
@ -22,13 +22,17 @@ New features
|
|||
|
||||
| `Issue #2595 <https://github.com/pgadmin-org/pgadmin4/issues/2595>`_ - Added Expression to CREATE INDEX.
|
||||
| `Issue #3942 <https://github.com/pgadmin-org/pgadmin4/issues/3942>`_ - Added cascade option while creating an extension.
|
||||
| `Issue #5759 <https://github.com/pgadmin-org/pgadmin4/issues/5759>`_ - Added 'Ignore Grants' option in the schema diff tool.
|
||||
| `Issue #6004 <https://github.com/pgadmin-org/pgadmin4/issues/6004>`_ - Added 'Ignore Tablespace' option in the schema diff tool.
|
||||
| `Issue #6375 <https://github.com/pgadmin-org/pgadmin4/issues/6375>`_ - Added support for ALTER INDEX column statistics.
|
||||
| `Issue #6376 <https://github.com/pgadmin-org/pgadmin4/issues/6376>`_ - Added unlogged option while creating a sequence.
|
||||
| `Issue #6377 <https://github.com/pgadmin-org/pgadmin4/issues/6377>`_ - Added all like options while creating a table.
|
||||
| `Issue #6381 <https://github.com/pgadmin-org/pgadmin4/issues/6381>`_ - Added support for SYSTEM, CONCURRENTLY and TABLESPACE options in REINDEX.
|
||||
| `Issue #6382 <https://github.com/pgadmin-org/pgadmin4/issues/6382>`_ - Added WAL option to EXPLAIN ANALYZE command.
|
||||
| `Issue #6397 <https://github.com/pgadmin-org/pgadmin4/issues/6397>`_ - Added new/missing options to the VACUUM command.
|
||||
| `Issue #6415 <https://github.com/pgadmin-org/pgadmin4/issues/6415>`_ - Added SKIP_LOCKED and BUFFER_USAGE_LIMIT option to Analyze command.
|
||||
| `Issue #6448 <https://github.com/pgadmin-org/pgadmin4/issues/6448>`_ - Add support for TRUNCATE trigger in foreign table.
|
||||
| `Issue #6595 <https://github.com/pgadmin-org/pgadmin4/issues/6595>`_ - Ensure that Schema Diff comparison results should be displayed in the sorted order.
|
||||
|
||||
Housekeeping
|
||||
************
|
||||
|
@ -44,3 +48,8 @@ Bug fixes
|
|||
| `Issue #6420 <https://github.com/pgadmin-org/pgadmin4/issues/6420>`_ - Fix the query tool issue where raise Notice from func/proc or code blocks are no longer displayed live.
|
||||
| `Issue #6500 <https://github.com/pgadmin-org/pgadmin4/issues/6500>`_ - Fix the issue where query tool window turns blank if the user tries to generate a graph on the result.
|
||||
| `Issue #6624 <https://github.com/pgadmin-org/pgadmin4/issues/6624>`_ - Fix an issue where changing MFA_SUPPORTED_METHODS breaks the MFA validation.
|
||||
| `Issue #6630 <https://github.com/pgadmin-org/pgadmin4/issues/6630>`_ - Fix an issue where pgAdmin 7.5 fails to render table SQL with extension loaded index method.
|
||||
| `Issue #6639 <https://github.com/pgadmin-org/pgadmin4/issues/6639>`_ - Fix an issue where cycle syntax was not added in SQL when creating new sequence from UI.
|
||||
| `Issue #6651 <https://github.com/pgadmin-org/pgadmin4/issues/6651>`_ - Fix an issue where the SET directive is excluded from the function header in the schema diff tool.
|
||||
| `Issue #6660 <https://github.com/pgadmin-org/pgadmin4/issues/6660>`_ - Fix a query tool error 'pgAdminThread' object has no attribute 'native_id'.
|
||||
| `Issue #6664 <https://github.com/pgadmin-org/pgadmin4/issues/6664>`_ - Ensure keyboard shortcut for query execution is disabled when query execution is in progress.
|
||||
|
|
|
@ -65,11 +65,15 @@ same or different (and within the same server or from different servers).
|
|||
:alt: Schema diff compare button
|
||||
:align: center
|
||||
|
||||
Use the drop-down near to *Compare* button to ignore owner and ignore whitespace.
|
||||
Use the drop-down near to *Compare* button to ignore owner, whitespace, tablespace and grants.
|
||||
|
||||
* Ignore owner – Select to ignores the owner while comparing the objects.
|
||||
* Ignore Owner – Select to ignores the owner while comparing the objects.
|
||||
|
||||
* Ignore whitespace – Select to ignores the whitespace while comparing the string objects. Whitespace includes space, tabs, and CRLF.
|
||||
* Ignore Whitespace – Select to ignores the whitespace while comparing the string objects. Whitespace includes space, tabs, and CRLF.
|
||||
|
||||
* Ignore Tablespace – Select to ignores the tablespace while comparing the objects.
|
||||
|
||||
* Ignore Grant/Revoke – Select to ignores the grant and revoke command while comparing the objects.
|
||||
|
||||
After you select servers, and databases, click on the
|
||||
*Compare* button to obtain the *Comparison Result*.
|
||||
|
|
|
@ -224,8 +224,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||
'compare': [{'get': 'compare'}, {'get': 'compare'}]
|
||||
})
|
||||
|
||||
keys_to_ignore = ['oid', 'basensp', 'oid-2', 'attnum', 'strftoptions',
|
||||
'relacl']
|
||||
keys_to_ignore = ['oid', 'basensp', 'oid-2', 'attnum', 'strftoptions']
|
||||
|
||||
def validate_request(f):
|
||||
"""
|
||||
|
@ -889,9 +888,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||
data['basensp'] = target_schema
|
||||
|
||||
# Parse Privileges
|
||||
if 'acl' in data:
|
||||
data['acl'] = parse_priv_to_db(data['acl'],
|
||||
["a", "r", "w", "x"])
|
||||
if 'relacl' in data:
|
||||
data['relacl'] = parse_priv_to_db(data['relacl'],
|
||||
["a", "r", "w", "x"])
|
||||
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
self._CREATE_SQL]),
|
||||
|
@ -932,9 +931,22 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||
Returns:
|
||||
SQL statements to create/update the Foreign Table.
|
||||
"""
|
||||
data = {}
|
||||
for k, v in self.request.items():
|
||||
try:
|
||||
# comments should be taken as is because if user enters a
|
||||
# json comment it is parsed by loads which should not happen
|
||||
if k in ('description',):
|
||||
data[k] = v
|
||||
else:
|
||||
data[k] = json.loads(v)
|
||||
except ValueError:
|
||||
data[k] = v
|
||||
except TypeError:
|
||||
data[k] = v
|
||||
try:
|
||||
SQL, name = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
|
||||
data=self.request, foid=foid)
|
||||
data=data, foid=foid)
|
||||
# Most probably this is due to error
|
||||
if not isinstance(SQL, str):
|
||||
return SQL
|
||||
|
@ -956,15 +968,15 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||
:param data: Data.
|
||||
:return:
|
||||
"""
|
||||
if 'acl' in data and 'added' in data['acl']:
|
||||
data['acl']['added'] = parse_priv_to_db(data['acl']['added'],
|
||||
["a", "r", "w", "x"])
|
||||
if 'acl' in data and 'changed' in data['acl']:
|
||||
data['acl']['changed'] = parse_priv_to_db(
|
||||
data['acl']['changed'], ["a", "r", "w", "x"])
|
||||
if 'acl' in data and 'deleted' in data['acl']:
|
||||
data['acl']['deleted'] = parse_priv_to_db(
|
||||
data['acl']['deleted'], ["a", "r", "w", "x"])
|
||||
if 'relacl' in data and 'added' in data['relacl']:
|
||||
data['relacl']['added'] = parse_priv_to_db(
|
||||
data['relacl']['added'], ["a", "r", "w", "x"])
|
||||
if 'relacl' in data and 'changed' in data['relacl']:
|
||||
data['relacl']['changed'] = parse_priv_to_db(
|
||||
data['relacl']['changed'], ["a", "r", "w", "x"])
|
||||
if 'relacl' in data and 'deleted' in data['relacl']:
|
||||
data['relacl']['deleted'] = parse_priv_to_db(
|
||||
data['relacl']['deleted'], ["a", "r", "w", "x"])
|
||||
|
||||
@staticmethod
|
||||
def _check_old_col_ops(old_col_frmt_options, option, col):
|
||||
|
@ -1095,9 +1107,9 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||
data['columns'] = self._format_columns(data['columns'])
|
||||
|
||||
# Parse Privileges
|
||||
if 'acl' in data:
|
||||
data['acl'] = parse_priv_to_db(data['acl'],
|
||||
["a", "r", "w", "x"])
|
||||
if 'relacl' in data:
|
||||
data['relacl'] = parse_priv_to_db(data['relacl'],
|
||||
["a", "r", "w", "x"])
|
||||
|
||||
sql = render_template("/".join([self.template_path,
|
||||
self._CREATE_SQL]), data=data,
|
||||
|
@ -1320,7 +1332,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
|||
priv = parse_priv_from_db(row)
|
||||
privileges.append(priv)
|
||||
|
||||
return {"acl": privileges}
|
||||
return {"relacl": privileges}
|
||||
|
||||
def _parse_variables_from_db(self, db_variables):
|
||||
"""
|
||||
|
|
|
@ -33,7 +33,6 @@ export default class ForeignTableSchema extends BaseUISchema {
|
|||
columns: [],
|
||||
ftoptions: [],
|
||||
relacl: [],
|
||||
stracl: [],
|
||||
seclabels: [],
|
||||
...initValues
|
||||
});
|
||||
|
@ -198,12 +197,11 @@ export default class ForeignTableSchema extends BaseUISchema {
|
|||
canAdd: true, canDelete: true, uniqueCol : ['option'],
|
||||
},
|
||||
{
|
||||
id: 'relacl', label: gettext('Privileges'), cell: 'text',
|
||||
type: 'text', group: gettext('Security'),
|
||||
mode: ['properties'], min_version: 90200,
|
||||
id: 'acl', label: gettext('Privileges'), type: 'text',
|
||||
group: gettext('Security'), mode: ['properties'], min_version: 90200,
|
||||
},
|
||||
{
|
||||
id: 'acl', label: gettext('Privileges'), type: 'collection',
|
||||
id: 'relacl', label: gettext('Privileges'), type: 'collection',
|
||||
schema: this.getPrivilegeRoleSchema(['a','r','w','x']),
|
||||
uniqueCol : ['grantee', 'grantor'],
|
||||
editable: false,
|
||||
|
|
|
@ -56,9 +56,9 @@ COMMENT ON COLUMN {{conn|qtIdent(data.basensp, data.name, c.attname)}}
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if data.acl %}
|
||||
{% if data.relacl %}
|
||||
|
||||
{% for priv in data.acl %}
|
||||
{% for priv in data.relacl %}
|
||||
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.basensp) }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
SELECT
|
||||
c.oid, c.relname AS name, c.relacl, pg_catalog.pg_get_userbyid(relowner) AS owner,
|
||||
c.oid, c.relname AS name, pg_catalog.pg_get_userbyid(relowner) AS owner,
|
||||
pg_catalog.array_to_string(c.relacl::text[], ', ') as acl,
|
||||
ftoptions, srvname AS ftsrvname, description, nspname AS basensp,
|
||||
(SELECT
|
||||
pg_catalog.array_agg(provider || '=' || label)
|
||||
|
|
|
@ -187,23 +187,23 @@ COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
|
|||
IS {{ data.description|qtLiteral(conn) }};
|
||||
|
||||
{% endif -%}
|
||||
{% if data.acl %}
|
||||
{% if 'deleted' in data.acl %}
|
||||
{% for priv in data.acl.deleted %}
|
||||
{% if data.relacl %}
|
||||
{% if 'deleted' in data.relacl %}
|
||||
{% for priv in data.relacl.deleted %}
|
||||
{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }}
|
||||
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'changed' in data.acl %}
|
||||
{% for priv in data.acl.changed %}
|
||||
{% if 'changed' in data.relacl %}
|
||||
{% for priv in data.relacl.changed %}
|
||||
{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }}
|
||||
|
||||
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }}
|
||||
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'added' in data.acl %}
|
||||
{% for priv in data.acl.added %}
|
||||
{% if 'added' in data.relacl %}
|
||||
{% for priv in data.relacl.added %}
|
||||
{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }}
|
||||
|
||||
{% endfor %}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"option":"table_name",
|
||||
"value":"test_table"
|
||||
}],
|
||||
"acl":[{
|
||||
"relacl":[{
|
||||
"grantee":"PUBLIC",
|
||||
"grantor":"postgres",
|
||||
"privileges":[{
|
||||
|
@ -153,7 +153,7 @@
|
|||
"sql_endpoint": "NODE-foreign_table.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table.msql_id",
|
||||
"data": {
|
||||
"acl":{
|
||||
"relacl":{
|
||||
"added": [{
|
||||
"grantee":"PUBLIC",
|
||||
"grantor":"postgres",
|
||||
|
@ -205,7 +205,7 @@
|
|||
"sql_endpoint": "NODE-foreign_table.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table.msql_id",
|
||||
"data": {
|
||||
"acl":{
|
||||
"relacl":{
|
||||
"deleted": [{
|
||||
"grantee":"PUBLIC",
|
||||
"grantor":"postgres",
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"option":"table_name",
|
||||
"value":"test_table"
|
||||
}],
|
||||
"acl":[{
|
||||
"relacl":[{
|
||||
"grantee":"PUBLIC",
|
||||
"grantor":"enterprisedb",
|
||||
"privileges":[{
|
||||
|
@ -153,7 +153,7 @@
|
|||
"sql_endpoint": "NODE-foreign_table.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table.msql_id",
|
||||
"data": {
|
||||
"acl":{
|
||||
"relacl":{
|
||||
"added": [{
|
||||
"grantee":"PUBLIC",
|
||||
"grantor":"enterprisedb",
|
||||
|
@ -205,7 +205,7 @@
|
|||
"sql_endpoint": "NODE-foreign_table.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table.msql_id",
|
||||
"data": {
|
||||
"acl":{
|
||||
"relacl":{
|
||||
"deleted": [{
|
||||
"grantee":"PUBLIC",
|
||||
"grantor":"enterprisedb",
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
{% import 'macros/functions/security.macros' as SECLABEL %}
|
||||
{% import 'macros/functions/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% set exclude_quoting = ['search_path'] %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{
|
||||
o_data.proargtypenames }})
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
{% set name = data.name %}
|
||||
{% endif %}
|
||||
{% endif -%}
|
||||
{% if data.change_func %}
|
||||
|
||||
CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %}
|
||||
{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %}
|
||||
{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
)
|
||||
RETURNS {% if 'prorettypename' in data %}{{ data.prorettypename }}{% else %}{{ o_data.prorettypename }}{% endif %}
|
||||
|
||||
{% if 'lanname' in data %}
|
||||
LANGUAGE {{ data.lanname|qtLiteral(conn) }} {% else %}
|
||||
LANGUAGE {{ o_data.lanname|qtLiteral(conn) }}
|
||||
{% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %}
|
||||
{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %}
|
||||
{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %}
|
||||
{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %}
|
||||
{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %}
|
||||
|
||||
{% if 'proparallel' in data and data.proparallel %}PARALLEL {{ data.proparallel }}{% elif 'proparallel' not in data and o_data.proparallel %}PARALLEL {{ o_data.proparallel }}{% endif %}
|
||||
|
||||
{% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0'%}
|
||||
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
|
||||
{% endif %}
|
||||
|
||||
AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %}
|
||||
{% if 'probin' in data %}{{ data.probin|qtLiteral(conn) }}{% else %}{{ o_data.probin|qtLiteral(conn) }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral(conn) }}{% else %}{{ o_data.prosrc_c|qtLiteral(conn) }}{% endif %}{% elif 'prosrc' in data %}
|
||||
$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %}
|
||||
{{ o_data.probin|qtLiteral(conn) }}, {{ o_data.prosrc_c|qtLiteral(conn) }}{% else %}
|
||||
$BODY${{ o_data.prosrc }}$BODY${% endif -%};
|
||||
{% endif -%}
|
||||
{% if data.funcowner %}
|
||||
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }})
|
||||
OWNER TO {{ conn|qtIdent(data.funcowner) }};
|
||||
{% endif -%}
|
||||
{# The SQL generated below will change priviledges #}
|
||||
{% if data.acl %}
|
||||
{% if 'deleted' in data.acl %}
|
||||
{% for priv in data.acl.deleted %}
|
||||
|
||||
{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'changed' in data.acl %}
|
||||
{% for priv in data.acl.changed %}
|
||||
|
||||
{% if priv.grantee != priv.old_grantee %}
|
||||
{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% else %}
|
||||
{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endif %}
|
||||
|
||||
{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'added' in data.acl %}
|
||||
{% for priv in data.acl.added %}
|
||||
|
||||
{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endfor %}{% endif -%}
|
||||
{% endif -%}
|
||||
{% if data.change_func == False %}
|
||||
{% if data.variables %}
|
||||
{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %}
|
||||
|
||||
{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endif -%}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
|
||||
{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
|
||||
{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
|
||||
{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
|
||||
{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if data.description is defined and data.description != o_data.description%}
|
||||
|
||||
COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }})
|
||||
IS {{ data.description|qtLiteral(conn) }};
|
||||
{% endif -%}
|
||||
|
||||
{% if data.pronamespace %}
|
||||
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }})
|
||||
SET SCHEMA {{ conn|qtIdent(data.pronamespace) }};
|
||||
{% endif -%}
|
||||
|
||||
{% endif %}
|
|
@ -3,6 +3,12 @@
|
|||
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% set exclude_quoting = ['search_path'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{
|
||||
|
@ -36,7 +42,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
|
|||
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif %}
|
||||
|
||||
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
|
||||
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
|
||||
{% endif %}
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% set exclude_quoting = ['search_path'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{
|
||||
|
@ -36,7 +42,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
|
|||
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif %}
|
||||
|
||||
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
|
||||
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
|
||||
{% endif %}
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% set exclude_quoting = ['search_path'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{
|
||||
|
@ -34,7 +40,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
|
|||
|
||||
{% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %}
|
||||
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
|
||||
{% endif %}
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% set exclude_quoting = ['search_path'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{
|
||||
|
@ -36,7 +42,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
|
|||
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif %}
|
||||
|
||||
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
|
||||
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
|
||||
{% endif %}
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% set exclude_quoting = ['search_path'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{
|
||||
|
@ -36,7 +42,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
|
|||
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif %}
|
||||
|
||||
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
|
||||
{% if data.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
|
||||
{% endif %}
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% set exclude_quoting = ['search_path'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% if data.name %}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{
|
||||
|
@ -34,7 +40,7 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d
|
|||
|
||||
{% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %}
|
||||
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %}
|
||||
ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
|
||||
{% endif %}
|
||||
|
|
|
@ -57,6 +57,8 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare):
|
|||
'scid': kwargs.get('target_scid')}
|
||||
ignore_owner = kwargs.get('ignore_owner')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace')
|
||||
ignore_grants = kwargs.get('ignore_grants')
|
||||
|
||||
group_name = kwargs.get('group_name')
|
||||
source_schema_name = kwargs.get('source_schema_name', None)
|
||||
|
@ -90,7 +92,9 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare):
|
|||
ignore_keys=self.keys_to_ignore,
|
||||
source_schema_name=source_schema_name,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
def ddl_compare(self, **kwargs):
|
||||
"""
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %}
|
||||
-- WARNING:
|
||||
-- We have found the difference in either of Type or SubType or Collation,
|
||||
-- so we need to drop the existing type first and re-create it.
|
||||
DROP TYPE {{ conn|qtIdent(o_data.schema, o_data.name) }} CASCADE;
|
||||
|
||||
{## If user selected shell type then just create type template ##}
|
||||
{% if data and data.typtype == 'p' %}
|
||||
CREATE TYPE {{ conn|qtIdent(o_data.schema, o_data.name) }};
|
||||
{% endif %}
|
||||
{### Composite Type ###}
|
||||
{% if data and data.typtype == 'c' %}
|
||||
{% if data.composite %}{% set typinput = data.typinput %}{% elif o_data.typinput %}{% set typinput = o_data.typinput %}{% endif %}
|
||||
CREATE TYPE {% if o_data.schema %}{{ conn|qtIdent(o_data.schema, o_data.name) }}{% else %}{{ conn|qtIdent(o_data.name) }}{% endif %} AS
|
||||
({{"\n\t"}}{% if data.composite.added %}{% for d in data.composite.added %}{% if loop.index != 1 %},{{"\n\t"}}{% endif %}{{ conn|qtIdent(d.member_name) }} {% if is_sql %}{{ d.fulltype }}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, d.cltype, d.tlength, d.precision, d.hasSqrBracket) }}{% endif %}{% if d.collation %} COLLATE {{d.collation}}{% endif %}{% endfor %}{% endif %}{{"\n"}});
|
||||
{% endif %}
|
||||
{### Enum Type ###}
|
||||
{% if data and data.typtype == 'e' %}
|
||||
CREATE TYPE {% if o_data.schema %}{{ conn|qtIdent(o_data.schema, o_data.name) }}{% else %}{{ conn|qtIdent(o_data.name) }}{% endif %} AS ENUM
|
||||
({% for e in data.enum.added %}{% if loop.index != 1 %}, {% endif %}{{ e.label|qtLiteral(conn) }}{% endfor %});
|
||||
{% endif %}
|
||||
{### Range Type ###}
|
||||
{% if data and (data.typtype == 'r' or (data.typtype is not defined and o_data.typtype == 'r')) %}
|
||||
{% if data.typname %}{% set typname = data.typname %}{% elif o_data.typname %}{% set typname = o_data.typname %}{% endif %}
|
||||
CREATE TYPE {% if o_data.schema %}{{ conn|qtIdent(o_data.schema, o_data.name) }}{% else %}{{ conn|qtIdent(o_data.name) }}{% endif %} AS RANGE
|
||||
(
|
||||
{% if typname %}SUBTYPE={{ conn|qtTypeIdent(typname) }}{% endif %}{% if data.collname %},
|
||||
COLLATION = {{ data.collname }}{% endif %}{% if data.opcname %},
|
||||
SUBTYPE_OPCLASS = {{ data.opcname }}{% endif %}{% if data.rngcanonical %},
|
||||
CANONICAL = {{ data.rngcanonical }}{% endif %}{% if data.rngsubdiff %},
|
||||
SUBTYPE_DIFF = {{ data.rngsubdiff }}{% endif %}
|
||||
|
||||
);
|
||||
{% endif %}
|
||||
{### External Type ###}
|
||||
{% if data and (data.typtype == 'b' or (data.typtype is not defined and o_data.typtype == 'b')) %}
|
||||
{% if data.typinput %}{% set typinput = data.typinput %}{% elif o_data.typinput %}{% set typinput = o_data.typinput %}{% endif %}
|
||||
{% if data.typoutput %}{% set typoutput = data.typoutput %}{% elif o_data.typoutput %}{% set typoutput = o_data.typoutput %}{% endif %}
|
||||
CREATE TYPE {% if o_data.schema %}{{ conn|qtIdent(o_data.schema, o_data.name) }}{% else %}{{ conn|qtIdent(o_data.name) }}{% endif %}
|
||||
|
||||
(
|
||||
{% if typinput %}INPUT = {{ typinput }}{% endif %}{% if typoutput %},
|
||||
OUTPUT = {{ typoutput }}{% endif %}{% if data.typreceive %},
|
||||
RECEIVE = {{data.typreceive}}{% endif %}{% if data.typsend %},
|
||||
SEND = {{data.typsend}}{% endif %}{% if data.typmodin %},
|
||||
TYPMOD_IN = {{data.typmodin}}{% endif %}{% if data.typmodout %},
|
||||
TYPMOD_OUT = {{data.typmodout}}{% endif %}{% if data.typanalyze %},
|
||||
ANALYZE = {{data.typanalyze}}{% endif %}{% if data.typlen %},
|
||||
INTERNALLENGTH = {{data.typlen}}{% endif %}{% if data.typbyval %},
|
||||
PASSEDBYVALUE{% endif %}{% if data.typalign %},
|
||||
ALIGNMENT = {{data.typalign}}{% endif %}{% if data.typstorage %},
|
||||
STORAGE = {{data.typstorage}}{% endif %}{% if data.typcategory %},
|
||||
CATEGORY = {{data.typcategory|qtLiteral(conn)}}{% endif %}{% if data.typispreferred %},
|
||||
PREFERRED = {{data.typispreferred}}{% endif %}{% if data.typdefault %},
|
||||
DEFAULT = {{data.typdefault|qtLiteral(conn)}}{% endif %}{% if data.element %},
|
||||
ELEMENT = {{data.element}}{% endif %}{% if data.typdelim %},
|
||||
DELIMITER = {{data.typdelim|qtLiteral(conn)}}{% endif %}{% if data.is_collatable %},
|
||||
COLLATABLE = {{data.is_collatable}}{% endif %}
|
||||
|
||||
);
|
||||
{% endif %}
|
||||
{### Type Owner ###}
|
||||
{% if data and (data.typeowner or o_data.typeowner)%}
|
||||
|
||||
ALTER TYPE {% if o_data.schema %}{{ conn|qtIdent(o_data.schema, o_data.name) }}{% else %}{{ conn|qtIdent(o_data.name) }}{% endif %}
|
||||
|
||||
OWNER TO {% if data.typeowner %}{{ conn|qtIdent(data.typeowner) }}{% elif o_data.typeowner %}{{ conn|qtIdent(o_data.typeowner) }}{% endif %};
|
||||
{% endif %}
|
||||
{### Type Comments ###}
|
||||
{% if data and data.description %}
|
||||
|
||||
COMMENT ON TYPE {% if o_data.schema %}{{ conn|qtIdent(o_data.schema, o_data.name) }}{% else %}{{ conn|qtIdent(o_data.name) }}{% endif %}
|
||||
|
||||
IS {{data.description|qtLiteral(conn)}};
|
||||
{% endif %}
|
||||
{### ACL ###}
|
||||
{% if data.typacl and data.typacl|length > 0 %}
|
||||
{% if 'deleted' in data.typacl %}
|
||||
{% for priv in data.typacl.deleted %}
|
||||
{{ PRIVILEGE.UNSETALL(conn, 'TYPE', priv.grantee, o_data.name, o_data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in data.typacl %}
|
||||
{% for priv in data.typacl.changed %}
|
||||
{{ PRIVILEGE.UNSETALL(conn, 'TYPE', priv.grantee, o_data.name, o_data.schema) }}
|
||||
{{ PRIVILEGE.SET(conn, 'TYPE', priv.grantee, o_data.name, priv.without_grant, priv.with_grant, o_data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in data.typacl %}
|
||||
{% for priv in data.typacl.added %}
|
||||
{{ PRIVILEGE.SET(conn, 'TYPE', priv.grantee, o_data.name, priv.without_grant, priv.with_grant, o_data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{### Security Lables ###}
|
||||
{% if data.seclabels %}
|
||||
|
||||
{% for r in data.seclabels %}
|
||||
{% if r.provider and r.label %}
|
||||
{{ SECLABEL.SET(conn, 'TYPE', o_data.name, r.provider, r.label, o_data.schema) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
|
@ -73,7 +73,7 @@ class SchemaDiffModule(PgAdminModule):
|
|||
|
||||
self.preference.register(
|
||||
'display', 'ignore_whitespaces',
|
||||
gettext("Ignore whitespace"), 'boolean', False,
|
||||
gettext("Ignore Whitespace"), 'boolean', False,
|
||||
category_label=PREF_LABEL_DISPLAY,
|
||||
help_str=gettext('Set ignore whitespace on or off by default in '
|
||||
'the drop-down menu near the Compare button in '
|
||||
|
@ -82,13 +82,31 @@ class SchemaDiffModule(PgAdminModule):
|
|||
|
||||
self.preference.register(
|
||||
'display', 'ignore_owner',
|
||||
gettext("Ignore owner"), 'boolean', False,
|
||||
gettext("Ignore Owner"), 'boolean', False,
|
||||
category_label=PREF_LABEL_DISPLAY,
|
||||
help_str=gettext('Set ignore owner on or off by default in the '
|
||||
'drop-down menu near the Compare button in the '
|
||||
'Schema Diff tab.')
|
||||
)
|
||||
|
||||
self.preference.register(
|
||||
'display', 'ignore_tablespace',
|
||||
gettext("Ignore Tablespace"), 'boolean', False,
|
||||
category_label=PREF_LABEL_DISPLAY,
|
||||
help_str=gettext('Set ignore tablespace on or off by default in '
|
||||
'the drop-down menu near the Compare button in '
|
||||
'the Schema Diff tab.')
|
||||
)
|
||||
|
||||
self.preference.register(
|
||||
'display', 'ignore_grants',
|
||||
gettext("Ignore Grants/Revoke"), 'boolean', False,
|
||||
category_label=PREF_LABEL_DISPLAY,
|
||||
help_str=gettext('Set ignore grants/revoke on or off by default '
|
||||
'in the drop-down menu near the Compare button '
|
||||
'in the Schema Diff tab.')
|
||||
)
|
||||
|
||||
|
||||
blueprint = SchemaDiffModule(MODULE_NAME, __name__, static_url_path='/static')
|
||||
|
||||
|
@ -462,6 +480,8 @@ def compare_database(params):
|
|||
try:
|
||||
ignore_owner = bool(params['ignore_owner'])
|
||||
ignore_whitespaces = bool(params['ignore_whitespaces'])
|
||||
ignore_tablespace = bool(params['ignore_tablespace'])
|
||||
ignore_grants = bool(params['ignore_grants'])
|
||||
|
||||
# Fetch all the schemas of source and target database
|
||||
# Compare them and get the status.
|
||||
|
@ -476,7 +496,7 @@ def compare_database(params):
|
|||
node_percent = 0
|
||||
if total_schema > 0:
|
||||
node_percent = round(100 / (total_schema * len(
|
||||
SchemaDiffRegistry.get_registered_nodes())))
|
||||
SchemaDiffRegistry.get_registered_nodes())), 2)
|
||||
total_percent = 0
|
||||
|
||||
# Compare Database objects
|
||||
|
@ -489,7 +509,9 @@ def compare_database(params):
|
|||
target_did=params['target_did'],
|
||||
diff_model_obj=diff_model_obj, total_percent=total_percent,
|
||||
node_percent=node_percent, ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
|
||||
|
@ -511,7 +533,9 @@ def compare_database(params):
|
|||
node_percent=node_percent,
|
||||
is_schema_source_only=True,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
|
@ -532,7 +556,9 @@ def compare_database(params):
|
|||
total_percent=total_percent,
|
||||
node_percent=node_percent,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
|
@ -555,7 +581,9 @@ def compare_database(params):
|
|||
total_percent=total_percent,
|
||||
node_percent=node_percent,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
|
@ -597,8 +625,10 @@ def compare_schema(params):
|
|||
try:
|
||||
ignore_owner = bool(params['ignore_owner'])
|
||||
ignore_whitespaces = bool(params['ignore_whitespaces'])
|
||||
ignore_tablespace = bool(params['ignore_tablespace'])
|
||||
ignore_grants = bool(params['ignore_grants'])
|
||||
all_registered_nodes = SchemaDiffRegistry.get_registered_nodes()
|
||||
node_percent = round(100 / len(all_registered_nodes))
|
||||
node_percent = round(100 / len(all_registered_nodes), 2)
|
||||
total_percent = 0
|
||||
|
||||
comparison_schema_result, total_percent = \
|
||||
|
@ -615,7 +645,9 @@ def compare_schema(params):
|
|||
total_percent=total_percent,
|
||||
node_percent=node_percent,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
comparison_result = \
|
||||
comparison_result + comparison_schema_result
|
||||
|
@ -749,6 +781,8 @@ def compare_database_objects(**kwargs):
|
|||
node_percent = kwargs.get('node_percent')
|
||||
ignore_owner = kwargs.get('ignore_owner')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace')
|
||||
ignore_grants = kwargs.get('ignore_grants')
|
||||
comparison_result = []
|
||||
|
||||
all_registered_nodes = SchemaDiffRegistry.get_registered_nodes(None,
|
||||
|
@ -772,7 +806,9 @@ def compare_database_objects(**kwargs):
|
|||
target_did=target_did,
|
||||
group_name=gettext('Database Objects'),
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
if res is not None:
|
||||
comparison_result = comparison_result + res
|
||||
|
@ -803,6 +839,8 @@ def compare_schema_objects(**kwargs):
|
|||
is_schema_source_only = kwargs.get('is_schema_source_only', False)
|
||||
ignore_owner = kwargs.get('ignore_owner')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace')
|
||||
ignore_grants = kwargs.get('ignore_grants')
|
||||
|
||||
source_schema_name = None
|
||||
if is_schema_source_only:
|
||||
|
@ -839,12 +877,14 @@ def compare_schema_objects(**kwargs):
|
|||
group_name=gettext(schema_name),
|
||||
source_schema_name=source_schema_name,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
if res is not None:
|
||||
comparison_result = comparison_result + res
|
||||
total_percent = total_percent + node_percent
|
||||
# if total_percent is more then 100 then set it to less then 100
|
||||
# if total_percent is more than 100 then set it to less than 100
|
||||
if total_percent >= 100:
|
||||
total_percent = 96
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@ class SchemaDiffObjectCompare:
|
|||
'did': kwargs.get('target_did')}
|
||||
ignore_owner = kwargs.get('ignore_owner', False)
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces', False)
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace', False)
|
||||
ignore_grants = kwargs.get('ignore_grants', False)
|
||||
|
||||
group_name = kwargs.get('group_name')
|
||||
source_schema_name = kwargs.get('source_schema_name', None)
|
||||
|
@ -102,7 +104,9 @@ class SchemaDiffObjectCompare:
|
|||
ignore_keys=self.keys_to_ignore,
|
||||
source_schema_name=source_schema_name,
|
||||
ignore_owner=ignore_owner,
|
||||
ignore_whitespaces=ignore_whitespaces)
|
||||
ignore_whitespaces=ignore_whitespaces,
|
||||
ignore_tablespace=ignore_tablespace,
|
||||
ignore_grants=ignore_grants)
|
||||
|
||||
def ddl_compare(self, **kwargs):
|
||||
"""
|
||||
|
|
|
@ -253,6 +253,8 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
|||
group_name = kwargs['group_name']
|
||||
target_schema = kwargs.get('target_schema')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_grants = kwargs.get('ignore_grants', False)
|
||||
|
||||
for key in intersect_keys:
|
||||
source_object_id, target_object_id = \
|
||||
get_source_target_oid(source_dict, target_dict, key)
|
||||
|
@ -299,7 +301,10 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
|||
ignore_keys=temp_ignore_keys,
|
||||
difference={}
|
||||
)
|
||||
parse_acl(dict1[key], dict2[key], diff_dict)
|
||||
|
||||
# No need to parse acl if ignore_grants is set to True.
|
||||
if not ignore_grants:
|
||||
parse_acl(dict1[key], dict2[key], diff_dict)
|
||||
|
||||
temp_src_params['tid'] = source_object_id
|
||||
temp_tgt_params['tid'] = target_object_id
|
||||
|
@ -326,7 +331,10 @@ def _get_identical_and_different_list(intersect_keys, source_dict, target_dict,
|
|||
dict1[key], dict2[key],
|
||||
ignore_keys=view_object.keys_to_ignore, difference={}
|
||||
)
|
||||
parse_acl(dict1[key], dict2[key], diff_dict)
|
||||
|
||||
# No need to parse acl if ignore_grants is set to True.
|
||||
if not ignore_grants:
|
||||
parse_acl(dict1[key], dict2[key], diff_dict)
|
||||
|
||||
temp_src_params['oid'] = source_object_id
|
||||
temp_tgt_params['oid'] = target_object_id
|
||||
|
@ -387,6 +395,8 @@ def compare_dictionaries(**kwargs):
|
|||
source_schema_name = kwargs.get('source_schema_name')
|
||||
ignore_owner = kwargs.get('ignore_owner')
|
||||
ignore_whitespaces = kwargs.get('ignore_whitespaces')
|
||||
ignore_tablespace = kwargs.get('ignore_tablespace')
|
||||
ignore_grants = kwargs.get('ignore_grants')
|
||||
|
||||
dict1 = copy.deepcopy(source_dict)
|
||||
dict2 = copy.deepcopy(target_dict)
|
||||
|
@ -421,10 +431,22 @@ def compare_dictionaries(**kwargs):
|
|||
# ignore keys.
|
||||
if ignore_owner:
|
||||
owner_keys = ['owner', 'eventowner', 'funcowner', 'fdwowner',
|
||||
'fsrvowner', 'lanowner', 'relowner', 'relacl', 'acl',
|
||||
'seqowner', 'typeowner']
|
||||
'fsrvowner', 'lanowner', 'relowner', 'seqowner',
|
||||
'typeowner']
|
||||
ignore_keys = ignore_keys + owner_keys
|
||||
|
||||
# if ignore_tablespace is True then add all the possible tablespace keys
|
||||
# to the ignore keys.
|
||||
if ignore_tablespace:
|
||||
tablespace_keys = ['spcname', 'spcoid']
|
||||
ignore_keys = ignore_keys + tablespace_keys
|
||||
|
||||
# if ignore_grants is True then add all the possible grants keys
|
||||
# to the ignore keys.
|
||||
if ignore_grants:
|
||||
grant_keys = ['relacl', 'acl', 'datacl', 'fdwacl', 'lanacl', 'fsrvacl']
|
||||
ignore_keys = ignore_keys + grant_keys
|
||||
|
||||
# Compare the values of duplicates keys.
|
||||
other_param = {
|
||||
"dict1": dict1,
|
||||
|
@ -434,7 +456,8 @@ def compare_dictionaries(**kwargs):
|
|||
"target_params": target_params,
|
||||
"group_name": group_name,
|
||||
"target_schema": target_schema,
|
||||
"ignore_whitespaces": ignore_whitespaces
|
||||
"ignore_whitespaces": ignore_whitespaces,
|
||||
"ignore_grants": ignore_grants
|
||||
}
|
||||
|
||||
identical, different = _get_identical_and_different_list(
|
||||
|
@ -486,11 +509,12 @@ def are_dictionaries_identical(source_dict, target_dict, ignore_keys,
|
|||
"""
|
||||
src_keys = set(source_dict.keys())
|
||||
tar_keys = set(target_dict.keys())
|
||||
igr_keys = set(ignore_keys)
|
||||
|
||||
# Keys that are available in source and missing in target.
|
||||
src_only = src_keys - tar_keys
|
||||
src_only = (src_keys - igr_keys) - tar_keys
|
||||
# Keys that are available in target and missing in source.
|
||||
tar_only = tar_keys - src_keys
|
||||
tar_only = (tar_keys - igr_keys) - src_keys
|
||||
|
||||
# If number of keys are different in source and target then
|
||||
# return False
|
||||
|
@ -590,11 +614,12 @@ def directory_diff(source_dict, target_dict, ignore_keys=[], difference=None):
|
|||
difference = {} if difference is None else difference
|
||||
src_keys = set(source_dict.keys())
|
||||
tar_keys = set(target_dict.keys())
|
||||
igr_keys = set(ignore_keys)
|
||||
|
||||
# Keys that are available in source and missing in target.
|
||||
src_only = src_keys - tar_keys
|
||||
src_only = (src_keys - igr_keys) - tar_keys
|
||||
# Keys that are available in target and missing in source.
|
||||
tar_only = tar_keys - src_keys
|
||||
tar_only = (tar_keys - igr_keys) - src_keys
|
||||
|
||||
for key in source_dict.keys():
|
||||
added = []
|
||||
|
|
|
@ -34,7 +34,9 @@ export const STYLE_CONSTANT = {
|
|||
|
||||
export const MENUS_COMPARE_CONSTANT = {
|
||||
COMPARE_IGNORE_OWNER: 1,
|
||||
COMPARE_IGNORE_WHITESPACE: 2
|
||||
COMPARE_IGNORE_WHITESPACE: 2,
|
||||
COMPARE_IGNORE_TABLESPACE: 3,
|
||||
COMPARE_IGNORE_GRANTS: 4
|
||||
};
|
||||
|
||||
export const MENUS_FILTER_CONSTANT = {
|
||||
|
@ -63,3 +65,10 @@ export const FILTER_NAME = {
|
|||
SOURCE_ONLY: gettext('Source Only'),
|
||||
TARGET_ONLY: gettext('Target Only')
|
||||
};
|
||||
|
||||
export const IGNORE_OPTION = {
|
||||
OWNER : gettext('Ignore Owner'),
|
||||
WHITESPACE : gettext('Ignore Whitespace'),
|
||||
TABLESPACE: gettext('Ignore Tablespace'),
|
||||
GRANTS: gettext('Ignore Grant/Revoke')
|
||||
};
|
||||
|
|
|
@ -371,13 +371,17 @@ function prepareRows(rows, gridData, filterParams) {
|
|||
|
||||
let adedIds = [];
|
||||
gridData.map((record) => {
|
||||
let childrens = getChildrenRows(record);
|
||||
let children = getChildrenRows(record);
|
||||
// Sort the children using label
|
||||
children.sort((a, b) => (a.label > b.label) ? 1 : -1);
|
||||
|
||||
if (childrens.length > 0) {
|
||||
childrens.map((child) => {
|
||||
let subChildrens = getChildrenRows(child);
|
||||
if (children.length > 0) {
|
||||
children.map((child) => {
|
||||
let subChildren = getChildrenRows(child);
|
||||
// Sort the sub children using label
|
||||
subChildren.sort((a, b) => (a.label > b.label) ? 1 : -1);
|
||||
let tempChildList = [];
|
||||
subChildrens.map((subChild) => {
|
||||
subChildren.map((subChild) => {
|
||||
if (filterParams.includes(subChild.status)) {
|
||||
tempChildList.push(subChild);
|
||||
adedIds.push(subChild.id);
|
||||
|
|
|
@ -17,13 +17,12 @@ import { Box } from '@material-ui/core';
|
|||
import CompareArrowsRoundedIcon from '@material-ui/icons/CompareArrowsRounded';
|
||||
import FeaturedPlayListRoundedIcon from '@material-ui/icons/FeaturedPlayListRounded';
|
||||
import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';
|
||||
import CheckRoundedIcon from '@material-ui/icons/CheckRounded';
|
||||
import { makeStyles } from '@material-ui/styles';
|
||||
|
||||
import { DefaultButton, PgButtonGroup, PgIconButton, PrimaryButton } from '../../../../../static/js/components/Buttons';
|
||||
import { FilterIcon } from '../../../../../static/js/components/ExternalIcon';
|
||||
import { PgMenu, PgMenuItem, usePgMenuGroup } from '../../../../../static/js/components/Menu';
|
||||
import { FILTER_NAME, MENUS, MENUS_COMPARE_CONSTANT, SCHEMA_DIFF_EVENT } from '../SchemaDiffConstants';
|
||||
import { FILTER_NAME, MENUS, MENUS_COMPARE_CONSTANT, SCHEMA_DIFF_EVENT, IGNORE_OPTION } from '../SchemaDiffConstants';
|
||||
import { SchemaDiffContext, SchemaDiffEventsContext } from './SchemaDiffComponent';
|
||||
|
||||
|
||||
|
@ -85,7 +84,11 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
|||
useEffect(() => {
|
||||
let isDisableComp = true;
|
||||
if (sourceData.sid != null && sourceData.did != null && targetData.sid != null && targetData.did != null) {
|
||||
isDisableComp = false;
|
||||
if ((sourceData.scid != null && targetData.scid == null) || (sourceData.scid == null && targetData.scid != null)) {
|
||||
isDisableComp = true;
|
||||
} else {
|
||||
isDisableComp = false;
|
||||
}
|
||||
}
|
||||
setIsDisableCompare(isDisableComp);
|
||||
}, [sourceData, targetData]);
|
||||
|
@ -96,10 +99,14 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
|||
if (!_.isUndefined(compareParams)) {
|
||||
compareParams.ignoreOwner && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER);
|
||||
compareParams.ignoreWhitespaces && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE);
|
||||
compareParams.ignoreTablespace && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE);
|
||||
compareParams.ignoreGrants && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS);
|
||||
setSelectedCompare(prefCompareOptions);
|
||||
} else {
|
||||
schemaDiffCtx?.preferences_schema_diff?.ignore_owner && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER);
|
||||
schemaDiffCtx?.preferences_schema_diff?.ignore_whitespaces && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE);
|
||||
schemaDiffCtx?.preferences_schema_diff?.ignore_tablespace && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE);
|
||||
schemaDiffCtx?.preferences_schema_diff?.ignore_grants && prefCompareOptions.push(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS);
|
||||
setSelectedCompare(prefCompareOptions);
|
||||
}
|
||||
}, [schemaDiffCtx.preferences_schema_diff]);
|
||||
|
@ -140,6 +147,8 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
|||
let compareParam = {
|
||||
'ignoreOwner': selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER) ? 1 : 0,
|
||||
'ignoreWhitespaces': selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE) ? 1 : 0,
|
||||
'ignoreTablespace': selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE) ? 1 : 0,
|
||||
'ignoreGrants': selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS) ? 1 : 0,
|
||||
};
|
||||
let filterParam = selectedFilters;
|
||||
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_COMPARE_DIFF, { sourceData, targetData, compareParams: compareParam, filterParams: filterParam });
|
||||
|
@ -182,32 +191,32 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
|||
open={openMenuName == MENUS.COMPARE}
|
||||
onClose={onMenuClose}
|
||||
label={gettext('Compare')}
|
||||
align="end"
|
||||
>
|
||||
<PgMenuItem onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER); }}>
|
||||
{selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>}{gettext('Ignore owner')}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE); }}>
|
||||
{selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>}{gettext('Ignore whitespace')}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER)}
|
||||
onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_OWNER); }}>{IGNORE_OPTION.OWNER}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE)}
|
||||
onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_WHITESPACE); }}>{IGNORE_OPTION.WHITESPACE}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE)}
|
||||
onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_TABLESPACE); }}>{IGNORE_OPTION.TABLESPACE}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedCompare.includes(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS)}
|
||||
onClick={() => { selectCompareOption(MENUS_COMPARE_CONSTANT.COMPARE_IGNORE_GRANTS); }}>{IGNORE_OPTION.GRANTS}</PgMenuItem>
|
||||
</PgMenu>
|
||||
<PgMenu
|
||||
anchorRef={filterRef}
|
||||
open={openMenuName == MENUS.FILTER}
|
||||
onClose={onMenuClose}
|
||||
label={gettext('Filter')}
|
||||
align="end"
|
||||
>
|
||||
<PgMenuItem onClick={() => { selectFilterOption(FILTER_NAME.IDENTICAL); }}>
|
||||
{selectedFilters.includes(FILTER_NAME.IDENTICAL) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>} {gettext(FILTER_NAME.IDENTICAL)}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem onClick={() => { selectFilterOption(FILTER_NAME.DIFFERENT); }}>
|
||||
{selectedFilters.includes(FILTER_NAME.DIFFERENT) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>} {gettext(FILTER_NAME.DIFFERENT)}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem onClick={() => { selectFilterOption(FILTER_NAME.SOURCE_ONLY); }}>
|
||||
{selectedFilters.includes(FILTER_NAME.SOURCE_ONLY) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>} {gettext(FILTER_NAME.SOURCE_ONLY)}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem onClick={() => { selectFilterOption(FILTER_NAME.TARGET_ONLY); }}>
|
||||
{selectedFilters.includes(FILTER_NAME.TARGET_ONLY) ? <CheckRoundedIcon /> : <span className={classes.emptyIcon}></span>} {gettext(FILTER_NAME.TARGET_ONLY)}
|
||||
</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedFilters.includes(FILTER_NAME.IDENTICAL)}
|
||||
onClick={() => { selectFilterOption(FILTER_NAME.IDENTICAL); }}>{FILTER_NAME.IDENTICAL}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedFilters.includes(FILTER_NAME.DIFFERENT)}
|
||||
onClick={() => { selectFilterOption(FILTER_NAME.DIFFERENT); }}>{FILTER_NAME.DIFFERENT}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedFilters.includes(FILTER_NAME.SOURCE_ONLY)}
|
||||
onClick={() => { selectFilterOption(FILTER_NAME.SOURCE_ONLY); }}>{FILTER_NAME.SOURCE_ONLY}</PgMenuItem>
|
||||
<PgMenuItem hasCheck checked={selectedFilters.includes(FILTER_NAME.TARGET_ONLY)}
|
||||
onClick={() => { selectFilterOption(FILTER_NAME.TARGET_ONLY); }}>{FILTER_NAME.TARGET_ONLY}</PgMenuItem>
|
||||
</PgMenu>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -256,8 +256,6 @@ export function SchemaDiffCompare({ params }) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
const triggerSelectSchema = ({ selectedSC, diff_type }) => {
|
||||
|
@ -272,7 +270,17 @@ export function SchemaDiffCompare({ params }) {
|
|||
const triggerCompareDiff = async ({ sourceData, targetData, compareParams, filterParams }) => {
|
||||
setGridData([]);
|
||||
setIsInit(false);
|
||||
if (JSON.stringify(sourceData) === JSON.stringify(targetData)) {
|
||||
|
||||
let raiseSelectionError = false;
|
||||
if (!_.isEmpty(sourceData.scid) && !_.isEmpty(targetData.scid)) {
|
||||
if (sourceData.sid === targetData.sid && sourceData.did === targetData.did && sourceData.scid === targetData.scid) {
|
||||
raiseSelectionError = true;
|
||||
}
|
||||
} else if (sourceData.sid === targetData.sid && sourceData.did === targetData.did) {
|
||||
raiseSelectionError = true;
|
||||
}
|
||||
|
||||
if (raiseSelectionError) {
|
||||
Notifier.alert(gettext('Selection Error'),
|
||||
gettext('Please select the different source and target.'));
|
||||
} else {
|
||||
|
@ -285,6 +293,8 @@ export function SchemaDiffCompare({ params }) {
|
|||
'target_did': targetData['did'],
|
||||
'ignore_owner': compareParams['ignoreOwner'],
|
||||
'ignore_whitespaces': compareParams['ignoreWhitespaces'],
|
||||
'ignore_tablespace': compareParams['ignoreTablespace'],
|
||||
'ignore_grants': compareParams['ignoreGrants'],
|
||||
};
|
||||
let socketEndpoint = 'compare_database';
|
||||
if (sourceData['scid'] != null && targetData['scid'] != null) {
|
||||
|
@ -299,7 +309,7 @@ export function SchemaDiffCompare({ params }) {
|
|||
socket = await openSocket('/schema_diff');
|
||||
socket.on('compare_status', res=>{
|
||||
let msg = res.compare_msg;
|
||||
msg = msg + gettext(` (this may take a few minutes)... ${res.diff_percentage} %`);
|
||||
msg = msg + gettext(` (this may take a few minutes)... ${Math.round(res.diff_percentage)} %`);
|
||||
setLoaderText(msg);
|
||||
});
|
||||
resData = await socketApiGet(socket, socketEndpoint, url_params);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -413,7 +413,7 @@ CREATE VIEW test_schema_diff."test view" AS
|
|||
pg_class.relacl,
|
||||
pg_class.reloptions,
|
||||
pg_class.relpartbound
|
||||
FROM pg_class
|
||||
FROM pg_catalog.pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
|
@ -1117,7 +1117,7 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping;
|
|||
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping
|
||||
OPTIONS (password 'admin123');
|
||||
|
||||
-- Publication Script
|
||||
-- Publication scripts
|
||||
|
||||
CREATE TABLE test_schema_diff.table_for_publication (
|
||||
col1 integer NOT NULL,
|
||||
|
@ -1158,4 +1158,3 @@ ALTER SUBSCRIPTION subscription_test1
|
|||
RENAME TO subscription_test;
|
||||
|
||||
DROP SUBSCRIPTION subscription_test;
|
||||
|
||||
|
|
|
@ -363,7 +363,6 @@ CREATE RULE rule3 AS
|
|||
|
||||
REFRESH MATERIALIZED VIEW test_schema_diff."MView";
|
||||
|
||||
|
||||
--
|
||||
-- TOC entry 12284 (class 1259 OID 347823)
|
||||
-- Name: test view; Type: VIEW; Schema: test_schema_diff; Owner: postgres
|
||||
|
@ -402,7 +401,7 @@ CREATE VIEW test_schema_diff."test view" AS
|
|||
pg_class.relacl,
|
||||
pg_class.reloptions,
|
||||
pg_class.relpartbound
|
||||
FROM pg_class
|
||||
FROM pg_catalog.pg_class
|
||||
LIMIT 10;
|
||||
|
||||
|
||||
|
@ -1108,4 +1107,3 @@ ALTER SUBSCRIPTION subscription_test1_in_target
|
|||
RENAME TO subscription_test_in_target;
|
||||
|
||||
DROP SUBSCRIPTION subscription_test_in_target;
|
||||
|
||||
|
|
|
@ -1051,6 +1051,8 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping
|
|||
|
||||
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping;
|
||||
|
||||
-- Publication scripts
|
||||
|
||||
CREATE TABLE test_schema_diff.table_for_publication (
|
||||
col1 integer NOT NULL,
|
||||
col2 text
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,7 @@ SET default_tablespace = '';
|
|||
|
||||
|
||||
CREATE EXTENSION btree_gist
|
||||
SCHEMA test_schema_diff;
|
||||
SCHEMA test_schema_diff;
|
||||
|
||||
--
|
||||
-- TOC entry 12272 (class 1259 OID 149205)
|
||||
|
@ -937,6 +937,7 @@ TABLESPACE pg_default;
|
|||
ALTER TABLE public.test_table_for_foreign_table
|
||||
OWNER to enterprisedb;
|
||||
|
||||
-- Foreign Table scripts
|
||||
CREATE FOREIGN TABLE test_schema_diff.ft_src(
|
||||
fid bigint NULL,
|
||||
fname text NULL COLLATE pg_catalog."default"
|
||||
|
|
|
@ -1213,7 +1213,7 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping
|
|||
|
||||
CREATE USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping;
|
||||
|
||||
-- Publication script
|
||||
-- Publication scripts
|
||||
|
||||
CREATE TABLE test_schema_diff.table_for_publication (
|
||||
col1 integer NOT NULL,
|
||||
|
|
|
@ -117,7 +117,9 @@ class SchemaDiffTestCase(BaseSocketTestGenerator):
|
|||
'target_sid': self.server_id,
|
||||
'target_did': self.tar_db_id,
|
||||
'ignore_owner': 0,
|
||||
'ignore_whitespaces': 0
|
||||
'ignore_whitespaces': 0,
|
||||
'ignore_tablespace': 0,
|
||||
'ignore_grants': 0
|
||||
}
|
||||
self.socket_client.emit('compare_database', data,
|
||||
namespace=self.SOCKET_NAMESPACE)
|
||||
|
|
Loading…
Reference in New Issue
Block a user