vapor / fluent

Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
https://docs.vapor.codes/4.0/fluent/overview/
MIT License
1.3k stars 171 forks source link

COLLATION support in Fluent #725

Open kavink opened 3 years ago

kavink commented 3 years ago

Are there any plans to support COLLATION in Fluent or Postgres-kit/MySQL-kit https://www.postgresql.org/docs/current/collation.html

I am trying to create a COLLATION during schema creation in the Migration script . Is there a way for me to do it ? I read about .custom but unable to make it work.

DB Fiddle: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=e7945853a6501b4eb1ceea94da3e0b46 Schema:

create table versions (v1 varchar(20));

CREATE COLLATION en_natural (
   LOCALE = 'en-US-u-kn-true',
   PROVIDER = 'icu'
);

insert into versions values
('1.2'),
('1.23.231+b'),
('1.23.231+a'),
('1.23'),
('1.23.231-test.beta'),
('1.23.231-test.alpha'),
('1.23.45-rc.2+B001');

Query:

SELECT *
FROM versions ORDER BY v1 COLLATE en_natural desc;

Any examples would be helpful or some workaround to get it working.

0xTim commented 2 years ago

It's been discussed a few times, with the main issue that Fluent needs to generally support all the databases. A future version may potentially support it.

A raw migration is probably the best workaround