-
SummaryI'm using Vercel Postgres to store tables containing swedish names. For some queries, I want to SELECT
name
FROM
(
VALUES
('Örjan'),
('Åsa'),
('Britt'),
('Niklas'),
('Ängla')
) AS names (name)
ORDER BY
name; In sweden, "Å", "Ä" and "Ö" are letters in their own right and should be ordered "ÅÄÖ" with placement at the end of the english alphabet. However, the above query yields the following, incorrect, result:
(specifically - the order should be "Åsa", "Ängla", "Örjan" rather than "Ängla", "Åsa", "Örjan"). While I could probably fix this by setting the collation per-column, there are a lot of columns and it's easy to forget to set the collation when adding/altering tables. It would be much easier if I could change the global locale to swedish. Is this supported by Vercel Postgres? Example 1 - How I do it locally: For the Example 2 - How to do it using CREATE DATABASE "example_db"
WITH OWNER "postgres"
ENCODING 'UTF8'
LC_COLLATE = 'sv-SE'
LC_CTYPE = 'sv-SE'; (modified from original at https://stackoverflow.com/a/52067734/1137077)
https://www.postgresql.org/docs/current/locale.html ExampleNo response Steps to ReproduceSELECT
name
FROM
(
VALUES
('Örjan'),
('Åsa'),
('Britt'),
('Niklas'),
('Ängla')
) AS names (name)
ORDER BY
name; |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Given that Vercel Postgres is powered by Neon in the background, I took a look at Neon's support site:
A good first step is that it seems that we should be able to run However, using
So while it is technically possible to create a new database with a specified collation, no collations beyond the default are really supported. In my case, I would need some variation of the |
Beta Was this translation helpful? Give feedback.
-
Ok, I actually managed to solve it! What you need to do is: CREATE DATABASE
mydb
WITH
ENCODING 'UTF8'
LOCALE_PROVIDER icu
ICU_LOCALE "sv-SE"
TEMPLATE template0; Note: Vercel by default uses Vercel: I would really like a feature to change the target database in the auto-added connection string secrets. |
Beta Was this translation helpful? Give feedback.
-
I'm looking for a solution for
|
Beta Was this translation helpful? Give feedback.
Ok, I actually managed to solve it!
What you need to do is:
Note: Vercel by default uses
verceldb
rather thanmydb
in its connection strings. I have not yet found a way to change this so you'll need to go through your secrets and point things right.Vercel: I would really like a feature to change the target database in the auto-added connection string secrets.