mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-23 09:16:29 -06:00
Use ROLE consistently when generating RE-SQL for roles, not USER. Fixes #4446
This commit is contained in:
parent
1dcf46cc5f
commit
1831c9e70a
@ -39,5 +39,6 @@ Bug fixes
|
||||
| `Issue #4429 <https://redmine.postgresql.org/issues/4429>`_ - Ensure drag/drop from the treeview works as expected on Firefox.
|
||||
| `Issue #4437 <https://redmine.postgresql.org/issues/4437>`_ - Fix table icon issue when updating any existing field.
|
||||
| `Issue #4442 <https://redmine.postgresql.org/issues/4442>`_ - Ensure browser should not be started by Selenium when feature tests are excluded from a test run.
|
||||
| `Issue #4446 <https://redmine.postgresql.org/issues/4446>`_ - Use ROLE consistently when generating RE-SQL for roles, not USER.
|
||||
| `Issue #4450 <https://redmine.postgresql.org/issues/4450>`_ - Fix reverse engineered sql for Foreign Data Wrapper created on EPAS server in redwood mode.
|
||||
| `Issue #4462 <https://redmine.postgresql.org/issues/4462>`_ - Fix some minor UI issues on IE11.
|
@ -1,6 +1,6 @@
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
CREATE {% if data.rolcanlogin %}USER{% else %}ROLE{% endif %} {{ conn|qtIdent(data.rolname) }} WITH{% if data.rolcanlogin and data.rolcanlogin is sameas True %}
|
||||
CREATE ROLE {{ conn|qtIdent(data.rolname) }} WITH{% if data.rolcanlogin and data.rolcanlogin is sameas True %}
|
||||
|
||||
LOGIN{% else %}
|
||||
|
||||
|
@ -2,11 +2,10 @@ SELECT
|
||||
array_to_string(array_agg(sql), E'\n\n')
|
||||
FROM
|
||||
(SELECT
|
||||
CASE WHEN rolcanlogin THEN '-- User: ' ELSE '-- Role: ' END ||
|
||||
'-- Role: ' ||
|
||||
pg_catalog.quote_ident(rolname) ||
|
||||
E'\n-- DROP ' || CASE WHEN rolcanlogin THEN 'USER ' ELSE 'ROLE ' END ||
|
||||
pg_catalog.quote_ident(rolname) || E';\n\nCREATE ' ||
|
||||
CASE WHEN rolcanlogin THEN 'USER ' ELSE 'ROLE ' END ||
|
||||
E'\n-- DROP ROLE ' ||
|
||||
pg_catalog.quote_ident(rolname) || E';\n\nCREATE ROLE ' ||
|
||||
pg_catalog.quote_ident(rolname) || E' WITH\n ' ||
|
||||
CASE WHEN rolcanlogin THEN 'LOGIN' ELSE 'NOLOGIN' END || E'\n ' ||
|
||||
CASE WHEN rolcanlogin AND rolpassword LIKE 'md5%%' THEN 'ENCRYPTED PASSWORD ' || quote_literal(rolpassword) || E'\n ' ELSE '' END ||
|
||||
@ -48,7 +47,7 @@ UNION ALL
|
||||
array_to_string(array_agg(sql), E'\n') AS sql
|
||||
FROM
|
||||
(SELECT
|
||||
'ALTER ' || CASE WHEN rolcanlogin THEN 'USER ' ELSE 'ROLE ' END || pg_catalog.quote_ident(rolname) || ' SET ' || param || ' TO ' || CASE WHEN param IN ('search_path', 'temp_tablespaces') THEN value ELSE quote_literal(value) END || ';' AS sql
|
||||
'ALTER ROLE ' || pg_catalog.quote_ident(rolname) || ' SET ' || param || ' TO ' || CASE WHEN param IN ('search_path', 'temp_tablespaces') THEN value ELSE quote_literal(value) END || ';' AS sql
|
||||
FROM
|
||||
(SELECT
|
||||
rolcanlogin, rolname, split_part(rolconfig, '=', 1) AS param, replace(rolconfig, split_part(rolconfig, '=', 1) || '=', '') AS value
|
||||
|
@ -2,14 +2,14 @@
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{% if 'rolname' in data %}
|
||||
{% set rolname=data.rolname %}
|
||||
ALTER{% if rolCanLogin %} USER {% else %} ROLE {% endif %}{{ conn|qtIdent(role) }}
|
||||
ALTER ROLE {{ conn|qtIdent(role) }}
|
||||
RENAME TO {{ conn|qtIdent(rolname) }};
|
||||
|
||||
{% else %}
|
||||
{% set rolname=role %}
|
||||
{% endif %}
|
||||
{% if data|hasAny(alterKeys) %}
|
||||
ALTER {% if rolCanLogin %}USER{% else %}ROLE{% endif %} {{ conn|qtIdent(rolname) }}{% if 'rolcanlogin' in data %}
|
||||
ALTER ROLE {{ conn|qtIdent(rolname) }}{% if 'rolcanlogin' in data %}
|
||||
|
||||
{% if data.rolcanlogin %}
|
||||
LOGIN{% else %}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
CREATE {% if data.rolcanlogin %}USER{% else %}ROLE{% endif %} {{ conn|qtIdent(data.rolname) }} WITH{% if data.rolcanlogin and data.rolcanlogin is sameas True %}
|
||||
CREATE ROLE {{ conn|qtIdent(data.rolname) }} WITH{% if data.rolcanlogin and data.rolcanlogin is sameas True %}
|
||||
|
||||
LOGIN{% else %}
|
||||
|
||||
|
@ -2,11 +2,10 @@ SELECT
|
||||
array_to_string(array_agg(sql), E'\n\n') AS sql
|
||||
FROM
|
||||
(SELECT
|
||||
CASE WHEN rolcanlogin THEN '-- User: ' ELSE '-- Role: ' END ||
|
||||
'-- Role: ' ||
|
||||
pg_catalog.quote_ident(rolname) ||
|
||||
E'\n-- DROP ' || CASE WHEN rolcanlogin THEN 'USER ' ELSE 'ROLE ' END ||
|
||||
pg_catalog.quote_ident(rolname) || E';\n\nCREATE ' ||
|
||||
CASE WHEN rolcanlogin THEN 'USER ' ELSE 'ROLE ' END ||
|
||||
E'\n-- DROP ROLE ' ||
|
||||
pg_catalog.quote_ident(rolname) || E';\n\nCREATE ROLE ' ||
|
||||
pg_catalog.quote_ident(rolname) || E' WITH\n ' ||
|
||||
CASE WHEN rolcanlogin THEN 'LOGIN' ELSE 'NOLOGIN' END || E'\n ' ||
|
||||
CASE WHEN rolcanlogin AND rolpassword LIKE 'md5%%' THEN 'ENCRYPTED PASSWORD ' || quote_literal(rolpassword) || E'\n ' ELSE '' END ||
|
||||
@ -46,7 +45,7 @@ UNION ALL
|
||||
array_to_string(array_agg(sql), E'\n') AS sql
|
||||
FROM
|
||||
(SELECT
|
||||
'ALTER ' || CASE WHEN rolcanlogin THEN 'USER ' ELSE 'ROLE ' END || pg_catalog.quote_ident(rolname) || ' SET ' || param || ' TO ' || CASE WHEN param IN ('search_path', 'temp_tablespaces') THEN value ELSE quote_literal(value) END || ';' AS sql
|
||||
'ALTER ROLE ' || pg_catalog.quote_ident(rolname) || ' SET ' || param || ' TO ' || CASE WHEN param IN ('search_path', 'temp_tablespaces') THEN value ELSE quote_literal(value) END || ';' AS sql
|
||||
FROM
|
||||
(SELECT
|
||||
rolcanlogin, rolname, split_part(rolconfig, '=', 1) AS param, replace(rolconfig, split_part(rolconfig, '=', 1) || '=', '') AS value
|
||||
|
@ -2,14 +2,14 @@
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{% if 'rolname' in data %}
|
||||
{% set rolname=data.rolname %}
|
||||
ALTER{% if rolCanLogin %} USER {% else %} ROLE {% endif %}{{ conn|qtIdent(role) }}
|
||||
ALTER ROLE {{ conn|qtIdent(role) }}
|
||||
RENAME TO {{ conn|qtIdent(rolname) }};
|
||||
|
||||
{% else %}
|
||||
{% set rolname=role %}
|
||||
{% endif %}
|
||||
{% if data|hasAny(alterKeys) %}
|
||||
ALTER {% if rolCanLogin %}USER{% else %}ROLE{% endif %} {{ conn|qtIdent(rolname) }}{% if 'rolcanlogin' in data %}
|
||||
ALTER ROLE {{ conn|qtIdent(rolname) }}{% if 'rolcanlogin' in data %}
|
||||
|
||||
{% if data.rolcanlogin %}
|
||||
LOGIN{% else %}
|
||||
|
@ -1,7 +1,7 @@
|
||||
-- User: "Role1_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP USER "Role1_$%{}[]()&*^!@""'`\/#";
|
||||
-- Role: "Role1_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE USER "Role1_$%{}[]()&*^!@""'`\/#" WITH
|
||||
CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
SUPERUSER
|
||||
INHERIT
|
@ -1,7 +1,7 @@
|
||||
-- User: "Role2_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP USER "Role2_$%{}[]()&*^!@""'`\/#";
|
||||
-- Role: "Role2_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE USER "Role2_$%{}[]()&*^!@""'`\/#" WITH
|
||||
CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
SUPERUSER
|
||||
INHERIT
|
@ -1,7 +1,7 @@
|
||||
-- User: "Role2_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP USER "Role2_$%{}[]()&*^!@""'`\/#";
|
||||
-- Role: "Role2_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE USER "Role2_$%{}[]()&*^!@""'`\/#" WITH
|
||||
CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
NOSUPERUSER
|
||||
INHERIT
|
@ -1,7 +1,7 @@
|
||||
-- User: "Role1_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP USER "Role1_$%{}[]()&*^!@""'`\/#";
|
||||
-- Role: "Role1_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE USER "Role1_$%{}[]()&*^!@""'`\/#" WITH
|
||||
CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
SUPERUSER
|
||||
INHERIT
|
@ -62,7 +62,7 @@
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create User",
|
||||
"name": "Create Login Role",
|
||||
"endpoint": "NODE-role.obj",
|
||||
"sql_endpoint": "NODE-role.sql_id",
|
||||
"data": {
|
||||
@ -81,42 +81,42 @@
|
||||
"seclabels": [],
|
||||
"variables": []
|
||||
},
|
||||
"expected_sql_file": "create_user.sql"
|
||||
"expected_sql_file": "create_login_role.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter User description",
|
||||
"name": "Alter Login Role description",
|
||||
"endpoint": "NODE-role.obj_id",
|
||||
"sql_endpoint": "NODE-role.sql_id",
|
||||
"data": {
|
||||
"description": "This is detailed description"
|
||||
},
|
||||
"expected_sql_file": "alter_user_description.sql"
|
||||
"expected_sql_file": "alter_login_role_description.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter User name",
|
||||
"name": "Alter Login Role name",
|
||||
"endpoint": "NODE-role.obj_id",
|
||||
"sql_endpoint": "NODE-role.sql_id",
|
||||
"data": {
|
||||
"rolname": "Role2_$%{}[]()&*^!@\"'`\\/#"
|
||||
},
|
||||
"expected_sql_file": "alter_user_name.sql"
|
||||
"expected_sql_file": "alter_login_role_name.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter User superuser, createdb etc options",
|
||||
"name": "Alter Login Role superuser, createdb etc options",
|
||||
"endpoint": "NODE-role.obj_id",
|
||||
"sql_endpoint": "NODE-role.sql_id",
|
||||
"data": {
|
||||
"rolsuper": false,
|
||||
"rolcreatedb": false
|
||||
},
|
||||
"expected_sql_file": "alter_user_options.sql"
|
||||
"expected_sql_file": "alter_login_role_options.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop User",
|
||||
"name": "Drop Login Role",
|
||||
"endpoint": "NODE-role.obj_id",
|
||||
"data": {}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
-- User: "Role1_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP USER "Role1_$%{}[]()&*^!@""'`\/#";
|
||||
-- Role: "Role1_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE USER "Role1_$%{}[]()&*^!@""'`\/#" WITH
|
||||
CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
SUPERUSER
|
||||
INHERIT
|
@ -1,7 +1,7 @@
|
||||
-- User: "Role2_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP USER "Role2_$%{}[]()&*^!@""'`\/#";
|
||||
-- Role: "Role2_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE USER "Role2_$%{}[]()&*^!@""'`\/#" WITH
|
||||
CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
SUPERUSER
|
||||
INHERIT
|
@ -1,7 +1,7 @@
|
||||
-- User: "Role2_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP USER "Role2_$%{}[]()&*^!@""'`\/#";
|
||||
-- Role: "Role2_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP ROLE "Role2_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE USER "Role2_$%{}[]()&*^!@""'`\/#" WITH
|
||||
CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
NOSUPERUSER
|
||||
INHERIT
|
@ -0,0 +1,10 @@
|
||||
-- Role: "Role1_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP ROLE "Role1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
SUPERUSER
|
||||
INHERIT
|
||||
CREATEDB
|
||||
CREATEROLE
|
||||
REPLICATION;
|
@ -1,10 +0,0 @@
|
||||
-- User: "Role1_$%{}[]()&*^!@""'`\/#"
|
||||
-- DROP USER "Role1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE USER "Role1_$%{}[]()&*^!@""'`\/#" WITH
|
||||
LOGIN
|
||||
SUPERUSER
|
||||
INHERIT
|
||||
CREATEDB
|
||||
CREATEROLE
|
||||
REPLICATION;
|
@ -62,7 +62,7 @@
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create User",
|
||||
"name": "Create Login Role",
|
||||
"endpoint": "NODE-role.obj",
|
||||
"sql_endpoint": "NODE-role.sql_id",
|
||||
"data": {
|
||||
@ -81,42 +81,42 @@
|
||||
"seclabels": [],
|
||||
"variables": []
|
||||
},
|
||||
"expected_sql_file": "create_user.sql"
|
||||
"expected_sql_file": "create_login_role.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter User description",
|
||||
"name": "Alter Login Role description",
|
||||
"endpoint": "NODE-role.obj_id",
|
||||
"sql_endpoint": "NODE-role.sql_id",
|
||||
"data": {
|
||||
"description": "This is detailed description"
|
||||
},
|
||||
"expected_sql_file": "alter_user_description.sql"
|
||||
"expected_sql_file": "alter_login_role_description.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter User name",
|
||||
"name": "Alter Login Role name",
|
||||
"endpoint": "NODE-role.obj_id",
|
||||
"sql_endpoint": "NODE-role.sql_id",
|
||||
"data": {
|
||||
"rolname": "Role2_$%{}[]()&*^!@\"'`\\/#"
|
||||
},
|
||||
"expected_sql_file": "alter_user_name.sql"
|
||||
"expected_sql_file": "alter_login_role_name.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter User superuser, createdb etc options",
|
||||
"name": "Alter Login Role superuser, createdb etc options",
|
||||
"endpoint": "NODE-role.obj_id",
|
||||
"sql_endpoint": "NODE-role.sql_id",
|
||||
"data": {
|
||||
"rolsuper": false,
|
||||
"rolcreatedb": false
|
||||
},
|
||||
"expected_sql_file": "alter_user_options.sql"
|
||||
"expected_sql_file": "alter_login_role_options.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop User",
|
||||
"name": "Drop Login Role",
|
||||
"endpoint": "NODE-role.obj_id",
|
||||
"data": {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user