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..195636b25 --- /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."default"; + +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_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_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/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..d9717ac83 --- /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."default"; + +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/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json new file mode 100644 index 000000000..889553e48 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json @@ -0,0 +1,166 @@ +{ + "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", + "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_2_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} 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..06e8e8064 --- /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."default"; + +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_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_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_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/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..02144bc03 --- /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."default"; + +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_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/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json new file mode 100644 index 000000000..fc976de81 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json @@ -0,0 +1,210 @@ +{ + "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", + "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_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} 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..4671c72c4 --- /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."default"; + +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/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..88a70f924 --- /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."default"; + +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/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json new file mode 100644 index 000000000..ae351a5e1 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json @@ -0,0 +1,107 @@ +{ + "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", + "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_$%{}[]()&*^!@\"'`\\/#" + } + } + + ] +} 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