From d3ef1137d9c330b979e92b6d2d8ba1e8ac5d566d Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Mon, 15 Jul 2019 14:56:22 +0100 Subject: [PATCH] Add Reverse Engineered SQL tests for Sequences. Fixes #4469 --- docs/en_US/release_notes_4_11.rst | 2 +- .../tests/pg/10_plus/alter_seq_comment.sql | 16 ++++++ .../tests/pg/10_plus/alter_seq_props.sql | 17 +++++++ .../tests/pg/10_plus/create_sequence.sql | 13 +++++ .../sequences/tests/pg/10_plus/test.json | 49 +++++++++++++++++++ .../tests/pg/default/alter_seq_comment.sql | 16 ++++++ .../tests/pg/default/alter_seq_props.sql | 17 +++++++ .../tests/pg/default/create_sequence.sql | 13 +++++ .../sequences/tests/pg/default/test.json | 49 +++++++++++++++++++ 9 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/alter_seq_comment.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/alter_seq_props.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/create_sequence.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/test.json create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_comment.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_props.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/create_sequence.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test.json diff --git a/docs/en_US/release_notes_4_11.rst b/docs/en_US/release_notes_4_11.rst index 46cde893a..0c2bf744a 100644 --- a/docs/en_US/release_notes_4_11.rst +++ b/docs/en_US/release_notes_4_11.rst @@ -27,7 +27,7 @@ Housekeeping | `Issue #4464 `_ - Add Reverse Engineered SQL tests for Collations. | `Issue #4468 `_ - Add Reverse Engineered SQL tests for Types. | `Issue #4471 `_ - Add Reverse Engineered SQL tests for FTS Parsers. - +| `Issue #4469 `_ - Add Reverse Engineered SQL tests for Sequences. Bug fixes ********* diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/alter_seq_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/alter_seq_comment.sql new file mode 100644 index 000000000..abb620824 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/alter_seq_comment.sql @@ -0,0 +1,16 @@ +-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#" + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + INCREMENT 5 + START 5 + MINVALUE 5 + MAXVALUE 999 + CACHE 1; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/alter_seq_props.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/alter_seq_props.sql new file mode 100644 index 000000000..9b29c67d9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/alter_seq_props.sql @@ -0,0 +1,17 @@ +-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#" + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + CYCLE + INCREMENT 12 + START 7 + MINVALUE 2 + MAXVALUE 9992 + CACHE 2; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/create_sequence.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/create_sequence.sql new file mode 100644 index 000000000..6d79f516b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/create_sequence.sql @@ -0,0 +1,13 @@ +-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#" + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + INCREMENT 5 + START 5 + MINVALUE 5 + MAXVALUE 999 + CACHE 1; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/test.json new file mode 100644 index 000000000..6a56038ae --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/10_plus/test.json @@ -0,0 +1,49 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Sequence", + "endpoint": "NODE-sequence.obj", + "sql_endpoint": "NODE-sequence.sql_id", + "data": { + "name": "Seq1_$%{}[]()&*^!@\"'`\\/#", + "seqowner": "postgres", + "schema": "public", + "increment": "5", + "start": "5", + "maximum": "999", + "minimum": "5", + "cache": "1", + "cycled": false, + "relacl": [], + "securities": [] + }, + "expected_sql_file": "create_sequence.sql" + },{ + "type": "alter", + "name": "Alter Sequence comment", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "data": { + "comment": "Some comment" + }, + "expected_sql_file": "alter_seq_comment.sql" + },{ + "type": "alter", + "name": "Alter Sequence properties", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "data": { + "current_value": "7", "increment": "12", "minimum": "2", "maximum": "9992", "cache": "2", "cycled": true + }, + "expected_sql_file": "alter_seq_props.sql" + },{ + "type": "delete", + "name": "Drop sequence", + "endpoint": "NODE-sequence.delete_id", + "data": { + "name": "Seq1_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_comment.sql new file mode 100644 index 000000000..abb620824 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_comment.sql @@ -0,0 +1,16 @@ +-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#" + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + INCREMENT 5 + START 5 + MINVALUE 5 + MAXVALUE 999 + CACHE 1; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_props.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_props.sql new file mode 100644 index 000000000..9b29c67d9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_props.sql @@ -0,0 +1,17 @@ +-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#" + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + CYCLE + INCREMENT 12 + START 7 + MINVALUE 2 + MAXVALUE 9992 + CACHE 2; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/create_sequence.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/create_sequence.sql new file mode 100644 index 000000000..6d79f516b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/create_sequence.sql @@ -0,0 +1,13 @@ +-- SEQUENCE: public."Seq1_$%{}[]()&*^!@""'`\/#" + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + INCREMENT 5 + START 5 + MINVALUE 5 + MAXVALUE 999 + CACHE 1; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test.json new file mode 100644 index 000000000..6a56038ae --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test.json @@ -0,0 +1,49 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Sequence", + "endpoint": "NODE-sequence.obj", + "sql_endpoint": "NODE-sequence.sql_id", + "data": { + "name": "Seq1_$%{}[]()&*^!@\"'`\\/#", + "seqowner": "postgres", + "schema": "public", + "increment": "5", + "start": "5", + "maximum": "999", + "minimum": "5", + "cache": "1", + "cycled": false, + "relacl": [], + "securities": [] + }, + "expected_sql_file": "create_sequence.sql" + },{ + "type": "alter", + "name": "Alter Sequence comment", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "data": { + "comment": "Some comment" + }, + "expected_sql_file": "alter_seq_comment.sql" + },{ + "type": "alter", + "name": "Alter Sequence properties", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "data": { + "current_value": "7", "increment": "12", "minimum": "2", "maximum": "9992", "cache": "2", "cycled": true + }, + "expected_sql_file": "alter_seq_props.sql" + },{ + "type": "delete", + "name": "Drop sequence", + "endpoint": "NODE-sequence.delete_id", + "data": { + "name": "Seq1_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +}