mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix an error that could be seen when editing column privileges. Fixes #4389
This commit is contained in:
parent
20a5899c7d
commit
ed01274f7b
@ -29,6 +29,7 @@ Bug fixes
|
||||
|
||||
| `Issue #3919 <https://redmine.postgresql.org/issues/3919>`_ - Allow keyboard navigation of all controls on subnode grids.
|
||||
| `Issue #4224 <https://redmine.postgresql.org/issues/4224>`_ - Prevent flickering of large tooltips on the Graphical EXPLAIN canvas.
|
||||
| `Issue #4389 <https://redmine.postgresql.org/issues/4389>`_ - Fix an error that could be seen when editing column privileges.
|
||||
| `Issue #4393 <https://redmine.postgresql.org/issues/4393>`_ - Ensure parameter values are quoted when needed when editing roles.
|
||||
| `Issue #4395 <https://redmine.postgresql.org/issues/4395>`_ - EXPLAIN options should be Query Tool instance-specific.
|
||||
| `Issue #4429 <https://redmine.postgresql.org/issues/4429>`_ - Ensure drag/drop from the treeview works as expected on Firefox.
|
||||
|
@ -905,10 +905,18 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings):
|
||||
|
||||
for c in final_columns:
|
||||
if 'attacl' in c:
|
||||
c['attacl'] = parse_priv_to_db(
|
||||
c['attacl'], self.column_acl
|
||||
if 'added' in c['attacl']:
|
||||
c['attacl']['added'] = parse_priv_to_db(
|
||||
c['attacl']['added'], self.column_acl
|
||||
)
|
||||
elif 'changed' in c['attacl']:
|
||||
c['attacl']['changed'] = parse_priv_to_db(
|
||||
c['attacl']['changed'], self.column_acl
|
||||
)
|
||||
elif 'deleted' in c['attacl']:
|
||||
c['attacl']['deleted'] = parse_priv_to_db(
|
||||
c['attacl']['deleted'], self.column_acl
|
||||
)
|
||||
|
||||
if 'cltype' in c:
|
||||
# check type for '[]' in it
|
||||
c['cltype'], c['hasSqrBracket'] = \
|
||||
|
@ -131,29 +131,29 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
||||
{% if 'deleted' in data.attacl %}
|
||||
{% for priv in data.attacl.deleted %}
|
||||
{% if data.name %}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
|
||||
{% else %}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in data.attacl %}
|
||||
{% for priv in data.attacl.changed %}
|
||||
{% if data.name %}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% else %}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in data.attacl %}
|
||||
{% for priv in data.attacl.added %}
|
||||
{% if data.name %}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% else %}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -89,29 +89,29 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
||||
{% if 'deleted' in data.attacl %}
|
||||
{% for priv in data.attacl.deleted %}
|
||||
{% if data.name %}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
|
||||
{% else %}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in data.attacl %}
|
||||
{% for priv in data.attacl.changed %}
|
||||
{% if data.name %}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% else %}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in data.attacl %}
|
||||
{% for priv in data.attacl.added %}
|
||||
{% if data.name %}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% else %}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -145,7 +145,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{% if c.attacl and c.attacl|length > 0 %}
|
||||
|
||||
{% for priv in c.attacl %}
|
||||
{{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{### Security Lables ###}
|
||||
|
@ -157,7 +157,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{% if c.attacl and c.attacl|length > 0 %}
|
||||
|
||||
{% for priv in c.attacl %}
|
||||
{{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{### Security Lables ###}
|
||||
|
@ -0,0 +1,96 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from pgadmin.browser.server_groups.servers.databases.schemas.tests import \
|
||||
utils as schema_utils
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import utils as \
|
||||
database_utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression import parent_node_dict
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
from . import utils as tables_utils
|
||||
|
||||
|
||||
class TableUpdateColumnTestCase(BaseTestGenerator):
|
||||
"""This class will update the column node from table"""
|
||||
scenarios = [
|
||||
# Fetching default URL for table node.
|
||||
('Add privileges for existing column',
|
||||
dict(url='/browser/table/obj/')
|
||||
)
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
self.db_name = parent_node_dict["database"][-1]["db_name"]
|
||||
schema_info = parent_node_dict["schema"][-1]
|
||||
self.server_id = schema_info["server_id"]
|
||||
self.db_id = schema_info["db_id"]
|
||||
db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
|
||||
self.server_id, self.db_id)
|
||||
if not db_con['data']["connected"]:
|
||||
raise Exception("Could not connect to database to add a table.")
|
||||
self.schema_id = schema_info["schema_id"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
schema_response = schema_utils.verify_schemas(self.server,
|
||||
self.db_name,
|
||||
self.schema_name)
|
||||
if not schema_response:
|
||||
raise Exception("Could not find the schema to add a table.")
|
||||
self.table_name = "test_table_column_put_%s" % (str(uuid.uuid4())[1:8])
|
||||
|
||||
self.table_id = tables_utils.create_table(
|
||||
self.server, self.db_name,
|
||||
self.schema_name,
|
||||
self.table_name)
|
||||
|
||||
def runTest(self):
|
||||
"""This function will fetch added table under schema node."""
|
||||
table_response = tables_utils.verify_table(self.server, self.db_name,
|
||||
self.table_id)
|
||||
if not table_response:
|
||||
raise Exception("Could not find the table to update.")
|
||||
|
||||
data = {
|
||||
"columns": {
|
||||
"changed": [{
|
||||
"attnum": 1,
|
||||
"attacl": {
|
||||
"added": [{
|
||||
"grantee": self.server["username"],
|
||||
"grantor": self.server["username"],
|
||||
"privileges": [
|
||||
{"privilege_type": "a", "privilege": True,
|
||||
"with_grant": True},
|
||||
{"privilege_type": "r", "privilege": True,
|
||||
"with_grant": True},
|
||||
{"privilege_type": "w", "privilege": True,
|
||||
"with_grant": True},
|
||||
{"privilege_type": "x", "privilege": True,
|
||||
"with_grant": True
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
response = self.tester.put(
|
||||
self.url + str(utils.SERVER_GROUP) + '/' +
|
||||
str(self.server_id) + '/' + str(self.db_id) + '/' +
|
||||
str(self.schema_id) + '/' + str(self.table_id),
|
||||
data=json.dumps(data), follow_redirects=True)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
|
||||
def tearDown(self):
|
||||
# Disconnect the database
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
@ -1750,9 +1750,6 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
|
||||
for c in columns['changed']:
|
||||
c['schema'] = data['schema']
|
||||
c['table'] = data['name']
|
||||
if 'attacl' in c:
|
||||
c['attacl'] = parse_priv_to_db(c['attacl'],
|
||||
self.column_acl)
|
||||
|
||||
properties_sql = render_template(
|
||||
"/".join([self.column_template_path,
|
||||
@ -1856,10 +1853,6 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
|
||||
for c in columns['added']:
|
||||
c['schema'] = data['schema']
|
||||
c['table'] = data['name']
|
||||
# Sql for create column
|
||||
if 'attacl' in c:
|
||||
c['attacl'] = parse_priv_to_db(c['attacl'],
|
||||
self.column_acl)
|
||||
|
||||
c = BaseTableView.convert_length_precision_to_string(c)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user