Skip to content

[Gel] Use unaccent extension for sorting ignoring accents #3487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions dbschema/common.gel
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
using extension pg_unaccent;

module default {
global currentActorId: uuid;
global currentActor := (select Actor filter .id = global currentActorId);
global currentUser := (select User filter .id = global currentActorId);
global currentRoles := (global currentActor).roles;

scalar type ReportPeriod extending enum<Monthly, Quarterly>;

# Helper function to workaround native support for sort ignoring accents
# https://stackoverflow.com/a/11007216
# https://github.com/geldata/gel/issues/386
function str_sortable(value: str) -> str
using (

# Helper function to sort strings in a more natural way
function str_sortable(value: str) -> str using (
str_lower(
re_replace('Ñ', 'N',
ext::pg_unaccent::unaccent(
str_trim(re_replace('[ [\\]|,\\-$]+', ' ', value, flags := 'g')),
flags := 'g'
)
)
)
);

Expand Down
8 changes: 8 additions & 0 deletions dbschema/migrations/00022-m1p34dr.edgeql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.