mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Add Reverse Engineered SQL tests for Views. Fixes #4576
2) Ensure View should be created with special characters. Fixes #4486
This commit is contained in:
parent
06ad6b8ba8
commit
ac298b03c0
@ -16,6 +16,7 @@ New features
|
||||
Housekeeping
|
||||
************
|
||||
|
||||
| `Issue #4576 <https://redmine.postgresql.org/issues/4576>`_ - Add Reverse Engineered SQL tests for Views.
|
||||
| `Issue #4600 <https://redmine.postgresql.org/issues/4600>`_ - Add Reverse Engineered SQL tests for Rules.
|
||||
|
||||
Bug fixes
|
||||
@ -25,6 +26,7 @@ Bug fixes
|
||||
| `Issue #2828 <https://redmine.postgresql.org/issues/2828>`_ - Added Gather Merge, Named Tuple Store Scan and Table Function Scan icon for explain module.
|
||||
| `Issue #3778 <https://redmine.postgresql.org/issues/3778>`_ - Ensure Boolean columns should be editable using keyboard keys.
|
||||
| `Issue #4419 <https://redmine.postgresql.org/issues/4419>`_ - Fix a debugger error when using Python 2.7.
|
||||
| `Issue #4486 <https://redmine.postgresql.org/issues/4486>`_ - Ensure View should be created with special characters.
|
||||
| `Issue #4487 <https://redmine.postgresql.org/issues/4487>`_ - Ensure Boolean columns should be editable in View/Edit data and Query Tool.
|
||||
| `Issue #4577 <https://redmine.postgresql.org/issues/4577>`_ - Fix an error that could be seen when click on any system column of a table.
|
||||
| `Issue #4584 <https://redmine.postgresql.org/issues/4584>`_ - Unescape HTML entities in database names in the Query Tool title bar.
|
||||
|
@ -2,5 +2,5 @@
|
||||
{% if data %}
|
||||
SELECT c.oid, c.relname FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
WHERE c.relname = '{{ data.name }}' and nsp.nspname = '{{ data.schema }}';
|
||||
WHERE c.relname = {{ data.name |qtLiteral }} and nsp.nspname = '{{ data.schema }}';
|
||||
{% endif %}
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
{% endif %}
|
||||
{% if data.name and data.schema and data.definition %}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %}{{'\r'}}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %}
|
||||
WITH (
|
||||
{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}{{'\r'}}
|
||||
{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}
|
||||
){% endif %} AS
|
||||
{{ data.definition.rstrip(';') }};
|
||||
{% if data.owner %}
|
||||
|
@ -2,5 +2,5 @@
|
||||
{% if data %}
|
||||
SELECT c.oid, c.relname FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
WHERE c.relname = '{{ data.name }}' and nsp.nspname = '{{ data.schema }}';
|
||||
WHERE c.relname = {{ data.name |qtLiteral }} and nsp.nspname = '{{ data.schema }}';
|
||||
{% endif %}
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
{% endif %}
|
||||
{% if data.name and data.schema and data.definition %}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %}{{'\r'}}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %}
|
||||
WITH (
|
||||
{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}{{'\r'}}
|
||||
{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}
|
||||
){% endif %} AS
|
||||
{{ data.definition.rstrip(';') }};
|
||||
{% if data.owner %}
|
||||
|
@ -2,5 +2,5 @@
|
||||
{% if data %}
|
||||
SELECT c.oid, c.relname FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
WHERE c.relname = '{{ data.name }}' and nsp.nspname = '{{ data.schema }}';
|
||||
WHERE c.relname = {{ data.name |qtLiteral }} and nsp.nspname = '{{ data.schema }}';
|
||||
{% endif %}
|
||||
|
@ -6,8 +6,14 @@
|
||||
|
||||
{% endif %}
|
||||
{% if data.name and data.schema and data.definition %}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier) %}{{ '\n' }}WITH (
|
||||
{% if data.check_option and data.check_option.lower() != 'no' %} check_option={{ data.check_option }}{% endif %}{{ ',\r' if data.check_option and data.check_option.lower() != 'no' and data.security_barrier }}{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}{{'\r'}}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}
|
||||
{% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier) %}
|
||||
WITH ({% if data.check_option and data.check_option.lower() != 'no' %}
|
||||
|
||||
check_option={{ data.check_option }}{% endif %}{{ ',' if data.check_option and data.check_option.lower() != 'no' and data.security_barrier }}
|
||||
{% if data.security_barrier %}
|
||||
security_barrier={{ data.security_barrier|lower }}
|
||||
{% endif %}
|
||||
){% endif %} AS
|
||||
{{ data.definition.rstrip(';') }};
|
||||
{% if data.owner and data.m_view is undefined %}
|
||||
|
@ -2,5 +2,5 @@
|
||||
{% if data %}
|
||||
SELECT c.oid, c.relname FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
WHERE c.relname = '{{ data.name }}' and nsp.nspname = '{{ data.schema }}';
|
||||
WHERE c.relname = {{ data.name |qtLiteral }} and nsp.nspname = '{{ data.schema }}';
|
||||
{% endif %}
|
||||
|
@ -2,5 +2,5 @@
|
||||
{% if data %}
|
||||
SELECT c.oid, c.relname FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
WHERE c.relname = '{{ data.name }}' and nsp.nspname = '{{ data.schema }}';
|
||||
WHERE c.relname = {{ data.name|qtLiteral }} and nsp.nspname = '{{ data.schema }}';
|
||||
{% endif %}
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
{% endif %}
|
||||
{% if data.name and data.schema and data.definition %}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %}{{'\r'}}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %}
|
||||
WITH (
|
||||
{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}{{'\r'}}
|
||||
{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}
|
||||
){% endif %} AS
|
||||
{{ data.definition.rstrip(';') }};
|
||||
{% if data.owner %}
|
||||
|
@ -2,5 +2,5 @@
|
||||
{% if data %}
|
||||
SELECT c.oid, c.relname FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
WHERE c.relname = '{{ data.name }}' and nsp.nspname = '{{ data.schema }}';
|
||||
WHERE c.relname = {{ data.name|qtLiteral }} and nsp.nspname = '{{ data.schema }}';
|
||||
{% endif %}
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
{% endif %}
|
||||
{% if data.name and data.schema and data.definition %}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %}{{'\r'}}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %}
|
||||
WITH (
|
||||
{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}{{'\r'}}
|
||||
{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}
|
||||
){% endif %} AS
|
||||
{{ data.definition.rstrip(';') }};
|
||||
{% if data.owner %}
|
||||
|
@ -2,5 +2,5 @@
|
||||
{% if data %}
|
||||
SELECT c.oid, c.relname FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
WHERE c.relname = '{{ data.name }}' and nsp.nspname = '{{ data.schema }}';
|
||||
WHERE c.relname = {{ data.name|qtLiteral }} and nsp.nspname = '{{ data.schema }}';
|
||||
{% endif %}
|
||||
|
@ -6,8 +6,14 @@
|
||||
|
||||
{% endif %}
|
||||
{% if data.name and data.schema and data.definition %}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier) %}{{ '\n' }}WITH (
|
||||
{% if data.check_option and data.check_option.lower() != 'no' %} check_option={{ data.check_option }}{% endif %}{{ ',\r' if data.check_option and data.check_option.lower() != 'no' and data.security_barrier }}{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %}{{'\r'}}
|
||||
CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}
|
||||
{% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier) %}
|
||||
WITH ({% if data.check_option and data.check_option.lower() != 'no' %}
|
||||
|
||||
check_option={{ data.check_option }}{% endif %}{{ ',' if data.check_option and data.check_option.lower() != 'no' and data.security_barrier }}
|
||||
{% if data.security_barrier %}
|
||||
security_barrier={{ data.security_barrier|lower }}
|
||||
{% endif %}
|
||||
){% endif %} AS
|
||||
{{ data.definition.rstrip(';') }};
|
||||
{% if data.owner and data.m_view is undefined %}
|
||||
|
@ -2,5 +2,5 @@
|
||||
{% if data %}
|
||||
SELECT c.oid, c.relname FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
WHERE c.relname = '{{ data.name }}' and nsp.nspname = '{{ data.schema }}';
|
||||
WHERE c.relname = {{ data.name|qtLiteral }} and nsp.nspname = '{{ data.schema}}';
|
||||
{% endif %}
|
||||
|
@ -0,0 +1,20 @@
|
||||
-- View: public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
|
||||
-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
WITH (
|
||||
check_option=cascaded,
|
||||
security_barrier=true
|
||||
) AS
|
||||
SELECT test_view_table.col1
|
||||
FROM test_view_table;
|
||||
|
||||
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO postgres;
|
||||
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
IS 'Testcomment-updated';
|
||||
|
||||
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres;
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
-- View: public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
|
||||
-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
WITH (
|
||||
check_option=local
|
||||
) AS
|
||||
SELECT test_view_table.col1
|
||||
FROM test_view_table;
|
||||
|
||||
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO postgres;
|
||||
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
IS 'Testcomment';
|
||||
|
||||
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres;
|
@ -0,0 +1,78 @@
|
||||
{
|
||||
"scenarios": [
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Table for Views",
|
||||
"endpoint": "NODE-table.obj",
|
||||
"sql_endpoint": "NODE-table.sql_id",
|
||||
"data": {
|
||||
"name": "test_view_table",
|
||||
"check_constraint": [],
|
||||
"coll_inherits": "[]",
|
||||
"columns": [
|
||||
{
|
||||
"name": "col1",
|
||||
"cltype": "integer"
|
||||
}
|
||||
],
|
||||
"schema": "public"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create View",
|
||||
"endpoint": "NODE-view.obj",
|
||||
"sql_endpoint": "NODE-view.sql_id",
|
||||
"data": {
|
||||
"definition": "select col1 from test_view_table;",
|
||||
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
|
||||
"owner": "postgres",
|
||||
"schema": "public",
|
||||
"check_option": "local",
|
||||
"security_barrier": false,
|
||||
"comment":"Testcomment",
|
||||
"datacl":[{"grantee":"postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true,
|
||||
"with_grant":false}]}]
|
||||
},
|
||||
"expected_sql_file": "create_view.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter View",
|
||||
"endpoint": "NODE-view.obj_id",
|
||||
"sql_endpoint": "NODE-view.sql_id",
|
||||
"data": {
|
||||
"definition": "select col1 from test_view_table;",
|
||||
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
|
||||
"owner": "postgres",
|
||||
"schema": "public",
|
||||
"check_option": "cascaded",
|
||||
"security_barrier": true,
|
||||
"comment":"Testcomment-updated",
|
||||
"datacl":[{"grantee":"postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true,
|
||||
"with_grant":false}]}]
|
||||
},
|
||||
"expected_sql_file": "alter_view.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop View",
|
||||
"endpoint": "NODE-view.obj_id",
|
||||
"data": {
|
||||
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
|
||||
"owner": "postgres",
|
||||
"schema": "public"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Table for view",
|
||||
"endpoint": "NODE-table.obj_id",
|
||||
"data": {
|
||||
"name": "test_view_table",
|
||||
"owner": "postgres",
|
||||
"schema": "public"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
-- View: public."testview1_$%{}[]()&*^!@""'`\/#"
|
||||
|
||||
-- DROP VIEW public."testview1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE OR REPLACE VIEW public."testview1_$%{}[]()&*^!@""'`\/#"
|
||||
WITH (
|
||||
check_option=cascaded,
|
||||
security_barrier=true
|
||||
) AS
|
||||
SELECT test_view_table.col1
|
||||
FROM test_view_table;
|
||||
|
||||
ALTER TABLE public."testview1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO enterprisedb;
|
||||
COMMENT ON VIEW public."testview1_$%{}[]()&*^!@""'`\/#"
|
||||
IS 'Testcomment-updated';
|
||||
|
||||
GRANT ALL ON TABLE public."testview1_$%{}[]()&*^!@""'`\/#" TO enterprisedb;
|
@ -0,0 +1,21 @@
|
||||
-- View: public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
|
||||
-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
WITH (
|
||||
check_option=local
|
||||
) AS
|
||||
SELECT test_view_table.col1
|
||||
FROM test_view_table;
|
||||
|
||||
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO enterprisedb;
|
||||
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
|
||||
IS 'Testcomment';
|
||||
|
||||
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb;
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
{
|
||||
"scenarios": [{
|
||||
"type": "create",
|
||||
"name": "Create Table for Views",
|
||||
"endpoint": "NODE-table.obj",
|
||||
"sql_endpoint": "NODE-table.sql_id",
|
||||
"data":{
|
||||
"name":"test_view_table",
|
||||
"check_constraint": [],
|
||||
"coll_inherits": "[]",
|
||||
"columns": [
|
||||
{
|
||||
"name": "col1",
|
||||
"cltype": "integer"
|
||||
}
|
||||
],
|
||||
"schema": "public"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create View",
|
||||
"endpoint": "NODE-view.obj",
|
||||
"sql_endpoint": "NODE-view.sql_id",
|
||||
"data": {
|
||||
"datacl":[{"grantee":"enterprisedb", "grantor":"enterprisedb", "privileges":[{"privilege_type": "a", "privilege": true, "with_grant":
|
||||
false}]}],
|
||||
"definition": "select col1 from test_view_table;",
|
||||
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
|
||||
"owner": "enterprisedb",
|
||||
"schema": "public",
|
||||
"check_option": "local",
|
||||
"security_barrier": false,
|
||||
"comment":"Testcomment"
|
||||
},
|
||||
"expected_sql_file": "create_view.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter View",
|
||||
"endpoint": "NODE-view.obj_id",
|
||||
"sql_endpoint": "NODE-view.sql_id",
|
||||
"data": {
|
||||
"definition": "select col1 from test_view_table;",
|
||||
"name": "testview1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"owner": "enterprisedb",
|
||||
"schema": "public",
|
||||
"check_option": "cascaded",
|
||||
"security_barrier": true,
|
||||
"comment":"Testcomment-updated",
|
||||
"datacl":[{"grantee":"enterprisedb", "grantor":"enterprisedb", "privileges":[{"privilege_type": "a", "privilege": false,
|
||||
"with_grant":false}]}]
|
||||
},
|
||||
"expected_sql_file": "alter_view.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop View",
|
||||
"endpoint": "NODE-view.obj_id",
|
||||
"data": {
|
||||
"name": "testview1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"owner": "enterprisedb",
|
||||
"schema": "public"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Table for Views",
|
||||
"endpoint": "NODE-table.obj_id",
|
||||
"data": {
|
||||
"name": "test_view_table",
|
||||
"owner": "enterprisedb",
|
||||
"schema": "public"
|
||||
}
|
||||
}]
|
||||
}
|
Loading…
Reference in New Issue
Block a user