diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_table_columns/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_table_columns/sql/default/update.sql index 36f6c6915a7..f93b4325082 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_table_columns/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_table_columns/sql/default/update.sql @@ -35,8 +35,8 @@ ALTER FOREIGN TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} -- the current datatype cannot be cast to the target cltype so this conversion cannot be made automatically. {% endif %} {% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %}ALTER FOREIGN TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname is not none %}{%if data.collspcname != o_data.collspcname %} - COLLATE {{data.collspcname}}{% elif data.collspcname is not none and o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %}{% endif %}; +{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname and and data.cltype != '"char"' %} + COLLATE {{data.collspcname}}{% elif o_data.collspcname and data.cltype != '"char"' %} COLLATE {{o_data.collspcname}}{% endif %}; {% endif %} {### Alter column default value ###} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql index 180d25d8638..b34f0e9fb10 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql @@ -2,7 +2,7 @@ ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character; + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character COLLATE pg_catalog."C"; ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql index 9a249aed340..6ac8f813c47 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql @@ -3,7 +3,7 @@ -- ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#"; ALTER TABLE IF EXISTS testschema."table_3_$%{}[]()&*^!@""'`\/#" - ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."default"; + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/14_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/14_plus/update.sql index b3bb12abc76..97009be7361 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/14_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/14_plus/update.sql @@ -17,8 +17,8 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %}ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname is not none %}{% if data.collspcname != o_data.collspcname %} - COLLATE {{data.collspcname}}{% elif data.collspcname is not none and o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %}{% endif %}; +{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname and data.cltype != '"char"' %} + COLLATE {{data.collspcname}}{% elif o_data.collspcname and data.cltype != '"char"' %} COLLATE {{o_data.collspcname}}{% endif %}; {% endif %} {### Alter column default value ###} {% if is_view_only and data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/update.sql index 34a8598b77d..3d00b9062d7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/16_plus/update.sql @@ -17,8 +17,8 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %}ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname is not none %}{% if data.collspcname != o_data.collspcname %} - COLLATE {{data.collspcname}}{% elif o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %}{% endif %}; +{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname and data.cltype != '"char"' %} + COLLATE {{data.collspcname}}{% elif o_data.collspcname and data.cltype != '"char"' %} COLLATE {{o_data.collspcname}}{% endif %}; {% endif %} {### Alter column default value ###} {% if is_view_only and data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql index a52f4ca061c..34445e3c2ac 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql @@ -17,8 +17,8 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %}ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname is not none %}{%if data.collspcname != o_data.collspcname %} - COLLATE {{data.collspcname}}{% elif data.collspcname is not none and o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %}{% endif %}; +{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{%if data.collspcname and data.collspcname != o_data.collspcname and data.cltype != '"char"' %} + COLLATE {{data.collspcname}}{% elif o_data.collspcname and data.cltype != '"char"' %} COLLATE {{o_data.collspcname}}{% endif %}; {% endif %} {### Alter column default value ###} {% if is_view_only and data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/alter_table_change_col_data_type_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/alter_table_change_col_data_type_msql.sql index 309ac306a80..290f242443f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/alter_table_change_col_data_type_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/alter_table_change_col_data_type_msql.sql @@ -2,7 +2,7 @@ ALTER TABLE public."simple_table_$%{}[]()&*^!@""'`\/#" ALTER COLUMN col1 TYPE bigint; ALTER TABLE public."simple_table_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN col2 TYPE character varying; + ALTER COLUMN col2 TYPE character varying COLLATE pg_catalog."default"; ALTER TABLE public."simple_table_$%{}[]()&*^!@""'`\/#" ALTER COLUMN col6 TYPE time(5) without time zone ; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/12_plus/alter_table_change_col_data_type_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/12_plus/alter_table_change_col_data_type_msql.sql index 309ac306a80..290f242443f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/12_plus/alter_table_change_col_data_type_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/12_plus/alter_table_change_col_data_type_msql.sql @@ -2,7 +2,7 @@ ALTER TABLE public."simple_table_$%{}[]()&*^!@""'`\/#" ALTER COLUMN col1 TYPE bigint; ALTER TABLE public."simple_table_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN col2 TYPE character varying; + ALTER COLUMN col2 TYPE character varying COLLATE pg_catalog."default"; ALTER TABLE public."simple_table_$%{}[]()&*^!@""'`\/#" ALTER COLUMN col6 TYPE time(5) without time zone ;