mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-08-19 01:15:04 -05:00
Added support for builtin locale provider while creating Collation. #8931
This commit is contained in:
+2
-1
@@ -79,7 +79,8 @@ define('pgadmin.node.collation', [
|
||||
{
|
||||
owner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name,
|
||||
schema: ('schema' in treeNodeInfo)? treeNodeInfo.schema.label : ''
|
||||
}
|
||||
},
|
||||
treeNodeInfo
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
+19
-10
@@ -12,7 +12,7 @@ import gettext from 'sources/gettext';
|
||||
import { isEmptyString } from 'sources/validators';
|
||||
|
||||
export default class CollationSchema extends BaseUISchema {
|
||||
constructor(fieldOptions = {},initValues={}) {
|
||||
constructor(fieldOptions = {}, initValues={}, nodeInfo={}) {
|
||||
super({
|
||||
name: undefined,
|
||||
oid: undefined,
|
||||
@@ -30,6 +30,7 @@ export default class CollationSchema extends BaseUISchema {
|
||||
this.schemaList = fieldOptions.schemaList;
|
||||
this.ownerList = fieldOptions.rolesList;
|
||||
this.collationsList = fieldOptions.collationsList;
|
||||
this.nodeInfo = nodeInfo;
|
||||
}
|
||||
|
||||
get idAttribute() {
|
||||
@@ -86,16 +87,24 @@ export default class CollationSchema extends BaseUISchema {
|
||||
deps: ['locale', 'lc_collate', 'lc_type'],
|
||||
},
|
||||
{
|
||||
id: 'provider', label: gettext('Locale Provider'),
|
||||
id: 'provider', label: gettext('Provider'),
|
||||
editable: false, type: 'select',mode: ['create'], group: gettext('Definition'),
|
||||
readonly: function (state) { return !obj.isNew(state); },
|
||||
options: [{
|
||||
label: gettext('icu'),
|
||||
value: 'icu',
|
||||
}, {
|
||||
label: gettext('libc'),
|
||||
value: 'libc',
|
||||
}],
|
||||
options: function() {
|
||||
let options = [{
|
||||
label: gettext('icu'),
|
||||
value: 'icu',
|
||||
}, {
|
||||
label: gettext('libc'),
|
||||
value: 'libc',
|
||||
}];
|
||||
if(obj.getServerVersion() >= 170000) {
|
||||
options.push({
|
||||
label: gettext('builtin'), value: 'builtin',
|
||||
});
|
||||
}
|
||||
return Promise.resolve(options);
|
||||
},
|
||||
min_version: 110000,
|
||||
deps: ['copy_collation'],
|
||||
depChange: (state)=>{
|
||||
@@ -110,7 +119,7 @@ export default class CollationSchema extends BaseUISchema {
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'provider', label: gettext('Locale Provider'),
|
||||
id: 'provider', label: gettext('Provider'),
|
||||
type: 'text',mode: ['properties', 'edit'], group: gettext('Definition'),
|
||||
readonly: true,
|
||||
min_version: 110000,
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
SELECT c.oid, c.collname AS name, c.collcollate AS lc_collate, c.collctype AS lc_type,
|
||||
pg_catalog.pg_get_userbyid(c.collowner) AS owner, c.collisdeterministic AS is_deterministic, c.collversion AS version,
|
||||
c.collprovider AS provider, des.description, n.nspname AS schema
|
||||
|
||||
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider,
|
||||
des.description, n.nspname AS schema
|
||||
FROM pg_catalog.pg_collation c
|
||||
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_collation'::regclass)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colliculocale) AS lc_collate,
|
||||
COALESCE(c.collctype, c.colliculocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
|
||||
c.collprovider AS provider,
|
||||
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider,
|
||||
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
|
||||
FROM pg_catalog.pg_collation c
|
||||
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colliculocale) AS lc_collate,
|
||||
COALESCE(c.collctype, c.colliculocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
|
||||
c.collprovider AS provider, c.collicurules AS rules,
|
||||
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider, c.collicurules AS rules,
|
||||
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
|
||||
FROM pg_catalog.pg_collation c
|
||||
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
SELECT c.oid, c.collname AS name, COALESCE(c.collcollate, c.colllocale) AS lc_collate,
|
||||
COALESCE(c.collctype, c.colllocale) AS lc_type, c.collisdeterministic AS is_deterministic, c.collversion AS version,
|
||||
c.collprovider AS provider, c.collicurules AS rules,
|
||||
CASE WHEN c.collprovider = 'i' THEN 'icu' WHEN c.collprovider = 'b' THEN 'builtin'
|
||||
ELSE 'libc' END provider, c.collicurules AS rules,
|
||||
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
|
||||
FROM pg_catalog.pg_collation c
|
||||
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'c', DETERMINISTIC = true);
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
|
||||
OWNER TO <OWNER>;
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#"
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'c', DETERMINISTIC = true);
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO <OWNER>;
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
(LC_COLLATE = 'locale', LC_CTYPE = 'locale', PROVIDER = 'i', DETERMINISTIC = true, VERSION = '1');
|
||||
(LC_COLLATE = 'locale', LC_CTYPE = 'locale', PROVIDER = 'icu', DETERMINISTIC = true, VERSION = '1');
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
OWNER TO <OWNER>;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#b;
|
||||
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true, VERSION = '1');
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
OWNER TO <OWNER>;
|
||||
|
||||
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
IS 'libc';
|
||||
+36
-2
@@ -33,12 +33,12 @@
|
||||
"name": "Drop Collation",
|
||||
"endpoint": "NODE-collation.delete_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#a"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Collation with extra parameters",
|
||||
"name": "Create Collation with icu provider",
|
||||
"endpoint": "NODE-collation.obj",
|
||||
"sql_endpoint": "NODE-collation.sql_id",
|
||||
"data": {
|
||||
@@ -53,6 +53,40 @@
|
||||
},
|
||||
"store_object_id": true,
|
||||
"expected_sql_file": "create_collation_with_extra_params.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Collation",
|
||||
"endpoint": "NODE-collation.delete_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Collation with libc provider",
|
||||
"endpoint": "NODE-collation.obj",
|
||||
"sql_endpoint": "NODE-collation.sql_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b",
|
||||
"schema": "testschema",
|
||||
"owner": "postgres",
|
||||
"description": "libc",
|
||||
"locale": "C",
|
||||
"provider": "libc",
|
||||
"is_deterministic": true,
|
||||
"version": "1"
|
||||
},
|
||||
"store_object_id": true,
|
||||
"expected_sql_file": "create_collation_with_libc.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Collation",
|
||||
"endpoint": "NODE-collation.delete_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#a;
|
||||
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
|
||||
OWNER TO <OWNER>;
|
||||
|
||||
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#a"
|
||||
IS 'Description for alter';
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#;
|
||||
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#"
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
|
||||
OWNER TO <OWNER>;
|
||||
|
||||
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
|
||||
IS 'Description';
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#b;
|
||||
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'builtin', DETERMINISTIC = true, VERSION = '1');
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
OWNER TO <OWNER>;
|
||||
|
||||
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
IS 'builtin';
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#b;
|
||||
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
(LC_COLLATE = 'locale', LC_CTYPE = 'locale', PROVIDER = 'icu', DETERMINISTIC = true, VERSION = '1');
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
OWNER TO <OWNER>;
|
||||
|
||||
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
IS 'Description for extra params';
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
-- Collation: Cl1_$%{}[]()&*^!@"'`\/#b;
|
||||
|
||||
-- DROP COLLATION IF EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b";
|
||||
|
||||
CREATE COLLATION IF NOT EXISTS testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
(LC_COLLATE = 'C', LC_CTYPE = 'C', PROVIDER = 'libc', DETERMINISTIC = true);
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
OWNER TO <OWNER>;
|
||||
|
||||
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#b"
|
||||
IS 'libc';
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
COMMENT ON COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
|
||||
IS 'Description for alter';
|
||||
|
||||
ALTER COLLATION testschema."Cl1_$%{}[]()&*^!@""'`\/#"
|
||||
RENAME TO "Cl1_$%{}[]()&*^!@""'`\/#a";
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"scenarios": [
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Collation",
|
||||
"endpoint": "NODE-collation.obj",
|
||||
"sql_endpoint": "NODE-collation.sql_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"schema": "testschema",
|
||||
"copy_collation": "pg_catalog.\"C\"",
|
||||
"description": "Description"
|
||||
},
|
||||
"store_object_id": true,
|
||||
"expected_sql_file": "create_collation.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Collation",
|
||||
"endpoint": "NODE-collation.obj_id",
|
||||
"sql_endpoint": "NODE-collation.sql_id",
|
||||
"msql_endpoint": "NODE-collation.msql_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#a",
|
||||
"schema": "testschema",
|
||||
"description": "Description for alter"
|
||||
},
|
||||
"expected_sql_file": "alter_collation.sql",
|
||||
"expected_msql_file": "msql_collation.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Collation",
|
||||
"endpoint": "NODE-collation.delete_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#a"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Collation with icu provider",
|
||||
"endpoint": "NODE-collation.obj",
|
||||
"sql_endpoint": "NODE-collation.sql_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b",
|
||||
"schema": "testschema",
|
||||
"owner": "postgres",
|
||||
"description": "Description for extra params",
|
||||
"locale": "locale",
|
||||
"provider": "icu",
|
||||
"is_deterministic": true,
|
||||
"version": "1"
|
||||
},
|
||||
"store_object_id": true,
|
||||
"expected_sql_file": "create_collation_with_extra_params.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Collation",
|
||||
"endpoint": "NODE-collation.delete_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Collation with libc provider",
|
||||
"endpoint": "NODE-collation.obj",
|
||||
"sql_endpoint": "NODE-collation.sql_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b",
|
||||
"schema": "testschema",
|
||||
"owner": "postgres",
|
||||
"description": "libc",
|
||||
"locale": "C",
|
||||
"provider": "libc",
|
||||
"is_deterministic": true
|
||||
},
|
||||
"store_object_id": true,
|
||||
"expected_sql_file": "create_collation_with_libc.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Collation",
|
||||
"endpoint": "NODE-collation.delete_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Collation with builtin provider",
|
||||
"endpoint": "NODE-collation.obj",
|
||||
"sql_endpoint": "NODE-collation.sql_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b",
|
||||
"schema": "testschema",
|
||||
"owner": "postgres",
|
||||
"description": "builtin",
|
||||
"locale": "C",
|
||||
"provider": "builtin",
|
||||
"is_deterministic": true,
|
||||
"version": "1"
|
||||
},
|
||||
"store_object_id": true,
|
||||
"expected_sql_file": "create_collation_with_builtin.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop Collation",
|
||||
"endpoint": "NODE-collation.delete_id",
|
||||
"data": {
|
||||
"name": "Cl1_$%{}[]()&*^!@\"'`\\/#b"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user