From 3f541200d98ed754cb6fd3d2a1b3f07dc547762a Mon Sep 17 00:00:00 2001 From: Murtuza Zabuawala Date: Fri, 16 Aug 2019 17:36:13 +0530 Subject: [PATCH] Add Reverse Engineered SQL tests for Columns. Fixes #4546 --- docs/en_US/release_notes_4_12.rst | 1 + .../tests/10_plus/alter_column_char.sql | 11 + .../10_plus/alter_column_drop_identity.sql | 11 + .../alter_column_drop_identity_by_default.sql | 9 + .../tests/10_plus/alter_column_identity.sql | 11 + .../alter_column_identity_by_default.sql | 9 + .../tests/10_plus/alter_column_int.sql | 11 + .../tests/10_plus/alter_column_numeric.sql | 15 + .../tests/10_plus/create_column_char.sql | 9 + .../tests/10_plus/create_column_int.sql | 9 + .../10_plus/create_column_int_identity.sql | 9 + .../create_column_int_identity_by_default.sql | 9 + .../tests/10_plus/create_column_numeric.sql | 13 + .../tables/columns/tests/10_plus/test.json | 279 ++++++++++++ .../tests/12_plus/alter_column_char.sql | 11 + .../12_plus/alter_column_drop_identity.sql | 11 + .../alter_column_drop_identity_by_default.sql | 9 + .../tests/12_plus/alter_column_generated.sql | 11 + ...column_generated_with_existing_columns.sql | 11 + .../tests/12_plus/alter_column_identity.sql | 11 + .../alter_column_identity_by_default.sql | 9 + .../tests/12_plus/alter_column_int.sql | 11 + .../tests/12_plus/alter_column_numeric.sql | 15 + .../tests/12_plus/create_column_char.sql | 9 + .../tests/12_plus/create_column_int.sql | 9 + .../12_plus/create_column_int_generated.sql | 9 + ...mn_int_generated_with_existing_columns.sql | 9 + .../12_plus/create_column_int_identity.sql | 9 + .../create_column_int_identity_by_default.sql | 9 + .../tests/12_plus/create_column_numeric.sql | 13 + .../tables/columns/tests/12_plus/test.json | 407 ++++++++++++++++++ .../tests/default/alter_column_char.sql | 11 + .../tests/default/alter_column_int.sql | 11 + .../tests/default/alter_column_numeric.sql | 15 + .../tests/default/create_column_char.sql | 9 + .../tests/default/create_column_int.sql | 9 + .../tests/default/create_column_numeric.sql | 13 + .../tables/columns/tests/default/test.json | 154 +++++++ .../templates/columns/sql/9.1_plus/acl.sql | 1 + 39 files changed, 1202 insertions(+) create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql create mode 100644 web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json diff --git a/docs/en_US/release_notes_4_12.rst b/docs/en_US/release_notes_4_12.rst index 4f7ed78be..e33c8b0ba 100644 --- a/docs/en_US/release_notes_4_12.rst +++ b/docs/en_US/release_notes_4_12.rst @@ -22,6 +22,7 @@ New features Housekeeping ************ +| `Issue #4546 `_ - Add Reverse Engineered SQL tests for Columns. | `Issue #4554 `_ - Add Reverse Engineered SQL tests for Trigger Functions. | `Issue #4555 `_ - Add Reverse Engineered SQL tests for Exclusion Constraint. | `Issue #4560 `_ - Add a --modules option to the RE-SQL test suite to allow testing of specific object types. diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql new file mode 100644 index 000000000..c5b9b23c8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql new file mode 100644 index 000000000..6749d14e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql new file mode 100644 index 000000000..e4828088b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql new file mode 100644 index 000000000..7d78c948d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql new file mode 100644 index 000000000..560d2b978 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 200 CACHE 2 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql new file mode 100644 index 000000000..515f2cdc0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql new file mode 100644 index 000000000..eeceb9e61 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" numeric(15,0) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql new file mode 100644 index 000000000..0f7e099f9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql new file mode 100644 index 000000000..61e7b4452 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql new file mode 100644 index 000000000..063b3c675 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql new file mode 100644 index 000000000..1aa62031e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql new file mode 100644 index 000000000..487567ade --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json new file mode 100644 index 000000000..5596ec178 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json @@ -0,0 +1,279 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (v.10+)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_2_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_table_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "0", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"a", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 3, + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_identity.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) drop identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 3, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity.sql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "attnum": 4, + "attlen":"15", + "attprecision":"0", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column with identity (Generated by default)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"d", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity_by_default.sql" + }, + { + "type": "alter", + "name": "Alter Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 5, + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "seqincrement":"2", + "seqmax":"200", + "seqcache":"2", + "seqcycle":true, + "seqmin":"1" + }, + "expected_sql_file": "alter_column_identity_by_default.sql" + }, + { + "type": "alter", + "name": "Alter Column with drop identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 5, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity_by_default.sql" + }, + { + "type": "delete", + "name": "Drop Column Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql new file mode 100644 index 000000000..1fe2b7a88 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql new file mode 100644 index 000000000..ccd89d803 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql new file mode 100644 index 000000000..c23442003 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql new file mode 100644 index 000000000..e49bebfaf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS (((1 + 2) + 3)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_4_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_4_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql new file mode 100644 index 000000000..4f96cd527 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_8_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_8_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS ((dummy1 + dummy2)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_8_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_8_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_8_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql new file mode 100644 index 000000000..e0fbb91c9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql new file mode 100644 index 000000000..a16cc8721 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 200 CACHE 2 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql new file mode 100644 index 000000000..e7e818ef1 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql new file mode 100644 index 000000000..5fff0f3c9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" numeric(15,0) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql new file mode 100644 index 000000000..5b4cd4a4d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql new file mode 100644 index 000000000..39e8868da --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql new file mode 100644 index 000000000..e06070efb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS (((1 + 2) + 3)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql new file mode 100644 index 000000000..ae40c07c4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_8_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_8_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS ((dummy1 + dummy2)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql new file mode 100644 index 000000000..da3867660 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql new file mode 100644 index 000000000..bdc3795da --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql new file mode 100644 index 000000000..73f49eebf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json new file mode 100644 index 000000000..9a52b7e8a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json @@ -0,0 +1,407 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (v.12+)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_3_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_table_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "0", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"a", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 3, + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_identity.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) drop identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 3, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity.sql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with Generated feature", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":null, + "attprecision":null, + "attidentity":"a", + "colconstype":"g", + "genexpr":"1 + 2 + 3", + "attoptions":[], + "seclabels":[] + }, + "expected_sql_file": "create_column_int_generated.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with Generated feature", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 4, + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_generated.sql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#", + "attnum": 5, + "attlen":"15", + "attprecision":"0", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Dummy Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "dummy1", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + } + }, + { + "type": "create", + "name": "Create Dummy Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "dummy2", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_8_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":null, + "attprecision":null, + "attidentity":"a", + "colconstype":"g", + "genexpr":"dummy1 + dummy2", + "attoptions":[], + "seclabels":[] + }, + "expected_sql_file": "create_column_int_generated_with_existing_columns.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 8, + "name": "new_col_8_$%{}[]()&*^!@\"'`\\/#", + "genexpr":"dummy1 - dummy2", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_generated_with_existing_columns.sql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_8_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column with identity (Generated by default)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_9_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"d", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity_by_default.sql" + }, + { + "type": "alter", + "name": "Alter Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 9, + "name": "new_col_9_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "seqincrement":"2", + "seqmax":"200", + "seqcache":"2", + "seqcycle":true, + "seqmin":"1" + }, + "expected_sql_file": "alter_column_identity_by_default.sql" + }, + { + "type": "alter", + "name": "Alter Column with drop identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 9, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity_by_default.sql" + }, + { + "type": "delete", + "name": "Drop Column Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_9_$%{}[]()&*^!@\"'`\\/#" + } + } + + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql new file mode 100644 index 000000000..5cd145bb3 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql new file mode 100644 index 000000000..d96d1a1d0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql new file mode 100644 index 000000000..5e5eb3e18 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" numeric(15,0) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql new file mode 100644 index 000000000..c5c3e10bf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql new file mode 100644 index 000000000..b7c693539 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql new file mode 100644 index 000000000..68c7fb52a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json new file mode 100644 index 000000000..59555d2bd --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json @@ -0,0 +1,154 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (Ver.default)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_1_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_table_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "0", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "attnum": 3, + "attlen":"15", + "attprecision":"0", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/acl.sql index 713b518b2..152a784e2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/acl.sql @@ -32,3 +32,4 @@ FROM LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) GROUP BY g.rolname, gt.rolname +ORDER BY grantee