Skip to content

Commit

Permalink
1) Added 'Ignore Grants' option in the schema diff tool. #5759
Browse files Browse the repository at this point in the history
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

Update preferneces documentation and screenshot

Fixed review comments.
  • Loading branch information
akshay-joshi committed Aug 11, 2023
1 parent e80d55e commit be89a71
Show file tree
Hide file tree
Showing 38 changed files with 391 additions and 5,089 deletions.
Binary file modified docs/en_US/images/preferences_schema_diff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/schema_diff_compare_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions docs/en_US/preferences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
9 changes: 9 additions & 0 deletions docs/en_US/release_notes_7_6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
************
Expand All @@ -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.
10 changes: 7 additions & 3 deletions docs/en_US/schema_diff.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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*.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ class ForeignTableView(PGChildNodeView)
'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):
"""
Expand Down Expand Up @@ -889,9 +888,9 @@ def sql(self, gid, sid, did, scid, foid=None, **kwargs):
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]),
Expand Down Expand Up @@ -932,9 +931,22 @@ def msql(self, gid, sid, did, scid, foid=None):
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
Expand All @@ -956,15 +968,15 @@ def _parse_privileges(data):
: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):
Expand Down Expand Up @@ -1095,9 +1107,9 @@ def get_sql(self, **kwargs):
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,
Expand Down Expand Up @@ -1320,7 +1332,7 @@ def _format_proacl_from_db(self, proacl):
priv = parse_priv_from_db(row)
privileges.append(priv)

return {"acl": privileges}
return {"relacl": privileges}

def _parse_variables_from_db(self, db_variables):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default class ForeignTableSchema extends BaseUISchema {
columns: [],
ftoptions: [],
relacl: [],
stracl: [],
seclabels: [],
...initValues
});
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"option":"table_name",
"value":"test_table"
}],
"acl":[{
"relacl":[{
"grantee":"PUBLIC",
"grantor":"postgres",
"privileges":[{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"option":"table_name",
"value":"test_table"
}],
"acl":[{
"relacl":[{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit be89a71

Please sign in to comment.