我可以在2022年的postges中创建icu排序的数据库吗?



我想在PostgreSQL与rails应用程序中使用icu排序。我在数据库中指定了icu排序。像这样的Yml

adapter: postgresql
ctype: ja-x-icu
collation: ja-x-icu

但是我得到了以下错误:

Caused by:
PG::WrongObjectType: ERROR:  invalid locale name: "ja-x-icu"

我发现一些问题,说我们不能使用icu排序在"CREATE DATABASE">
在Postgres 10和win server 2008中使用-x-icu作为排序符和字符类型

现在的情况和这个问题还是一样吗?
如果是这样,我如何创建数据库与icu排序?

提前谢谢你。(我正在使用Rails 7和Postgres 11,但如果有必要,我可以移动到进一步的版本。)

仅支持PostgreSQL v15或更高版本

如果您使用的是v15或更好的版本,我猜您的错误在于您只是使用了

initdb --encoding=UTF8 --locale=ja-x-icu datadir
The files belonging to this database system will be owned by user "laurenz".
This user must also own the server process.
initdb: error: invalid locale name "ja-x-icu"

你必须做不同的:

initdb --encoding=UTF8 
--locale-provider=icu --locale=ja_JP.utf8 --icu-locale=ja-x-icu datadir

使用--locale作为C库语言环境。即使使用ICU排序(--icu-locale=ja-x-icu --locale-provider=icu),也必须指定C库语言环境。

最新更新