Skip to content

Commit 58f6b64

Browse files
authored
[Gel] Use unaccent extension for sorting ignoring accents (#3487)
1 parent 58084b9 commit 58f6b64

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

dbschema/common.gel

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1+
using extension pg_unaccent;
2+
13
module default {
24
global currentActorId: uuid;
35
global currentActor := (select Actor filter .id = global currentActorId);
46
global currentUser := (select User filter .id = global currentActorId);
57
global currentRoles := (global currentActor).roles;
68

79
scalar type ReportPeriod extending enum<Monthly, Quarterly>;
8-
9-
# Helper function to workaround native support for sort ignoring accents
10-
# https://stackoverflow.com/a/11007216
11-
# https://github.com/geldata/gel/issues/386
12-
function str_sortable(value: str) -> str
13-
using (
10+
11+
# Helper function to sort strings in a more natural way
12+
function str_sortable(value: str) -> str using (
1413
str_lower(
15-
re_replace('Ñ', 'N',
14+
ext::pg_unaccent::unaccent(
1615
str_trim(re_replace('[ [\\]|,\\-$]+', ' ', value, flags := 'g')),
17-
flags := 'g'
18-
)
16+
)
1917
)
2018
);
2119

dbschema/migrations/00022-m1p34dr.edgeql

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)