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

Conversation

CarsonF
Copy link
Member

@CarsonF CarsonF commented Jun 10, 2025

No description provided.

Copy link

coderabbitai bot commented Jun 10, 2025

📝 Walkthrough

Walkthrough

The changes integrate the PostgreSQL pg_unaccent extension for accent-insensitive string normalization and sorting. The str_sortable function is updated to use pg_unaccent's unaccent method, replacing a previous manual workaround for accent removal. A migration script is added to enable the extension and update the function implementation accordingly.

Changes

Files/Paths Change Summary
dbschema/common.gel Added pg_unaccent extension usage; updated str_sortable to use unaccent for accent removal.
dbschema/migrations/00022-m1p34dr.edgeql Migration to enable pg_unaccent extension and update str_sortable function implementation.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between faedd82 and e460c2c.

📒 Files selected for processing (2)
  • dbschema/common.gel (1 hunks)
  • dbschema/migrations/00022-m1p34dr.edgeql (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: E2E Tests (neo4j 1/6)
  • GitHub Check: E2E Tests (neo4j 4/6)
  • GitHub Check: Clean
  • GitHub Check: Generate (head)
  • GitHub Check: E2E Tests (neo4j 6/6)
  • GitHub Check: E2E Tests (neo4j 3/6)
  • GitHub Check: E2E Tests (neo4j 5/6)
  • GitHub Check: Generate (base)
  • GitHub Check: E2E Tests (neo4j 2/6)
  • GitHub Check: Unit
  • GitHub Check: lint
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (actions)
🔇 Additional comments (3)
dbschema/common.gel (2)

1-1: LGTM: Extension declaration is correct.

The using extension pg_unaccent; declaration properly imports the PostgreSQL extension for use in EdgeDB.


12-18:

❌ Incorrect review comment

Critical inconsistency: Regex pattern differs from migration.

The regex pattern in this file '[ [\\]|,\\-$]+' doesn't match the pattern in the migration file r'[ [\]|,\-$]+'. This inconsistency could lead to different behavior between the migrated function and the schema definition.

The patterns have different escaping:

  • Schema: '[ [\\]|,\\-$]+' (double backslashes)
  • Migration: r'[ [\]|,\-$]+' (raw string with single backslashes)

Please ensure both files use the same regex pattern. The intended pattern should likely be:

-    str_trim(re_replace('[ [\\]|,\\-$]+', ' ', value, flags := 'g')),
+    str_trim(re_replace('[ \\[\\]|,\\-$]+', ' ', value, flags := 'g')),

Run this script to verify consistency between schema and migration:


🏁 Script executed:

#!/bin/bash
# Check for regex pattern consistency between schema and migration files
echo "=== Schema file pattern ==="
grep -n "re_replace" dbschema/common.gel

echo "=== Migration file pattern ==="
grep -n "re_replace" dbschema/migrations/00022-m1p34dr.edgeql

echo "=== Pattern comparison ==="
echo "If patterns differ, this needs to be resolved for consistency"

Length of output: 635


Patterns are equivalent – no change needed

The schema’s normal‐string literal ('[ [\\]|,\\-$]+') and the migration’s raw‐string literal (r'[ [\]|,\-$]+') both compile to the same character class (matching space, [, ], |, ,, -, and $). The differences are purely in how backslashes are escaped in the two string formats. No updates are required.

Likely an incorrect or invalid review comment.

dbschema/migrations/00022-m1p34dr.edgeql (1)

4-4:

✅ Verification successful

Verify PostgreSQL extension version availability.

The migration creates pg_unaccent at version '1.1'. Please ensure this version is available in your target PostgreSQL environments.


🌐 Web query:

What versions of the PostgreSQL pg_unaccent extension are available and what is the latest stable version?

💡 Result:

The PostgreSQL extension is called "unaccent" (not "pg_unaccent"), and it's used for removing accents or diacritic signs from text to make searching and text comparisons more flexible across different languages.

Available Versions

Based on the search results, the unaccent extension is consistently available as version 1.1 across multiple PostgreSQL versions:

  • PostgreSQL 17: version 1.1[1][4]
  • PostgreSQL 16: version 1.1[4]
  • PostgreSQL 15: version 1.1[4]
  • PostgreSQL 14 and earlier: version 1.1[3][4]

This consistency in versioning suggests that unaccent has been stable at version 1.1 for quite some time. The extension is supported across various PostgreSQL database services including:

  • Amazon RDS for PostgreSQL[1]
  • Amazon Aurora PostgreSQL[3]
  • Microsoft Azure PostgreSQL[4]
  • Google Cloud SQL for PostgreSQL[10]
  • Neon's PostgreSQL service[8]

Functionality

The unaccent extension provides a text search dictionary that removes accents from lexemes. It's particularly useful for:

  • Making text searches accent-insensitive
  • Ensuring that queries find relevant results regardless of accent variations
  • Handling multilingual applications where users might not consistently use accents[8]

For example, using the unaccent function:

SELECT unaccent('Hôtel');

Would return "Hotel" with the accent removed[2][5].

The latest stable version across all modern PostgreSQL implementations appears to be 1.1, with no indication of a newer version being available or in development as of June 2025.

Citations:


Extension version 1.1 is fully supported

The PostgreSQL “unaccent” extension (referenced here as pg_unaccent) remains at version 1.1 across PostgreSQL 14–17 and is supported by RDS, Aurora, Azure, GCP, Neon, etc. You can safely keep

CREATE EXTENSION pg_unaccent VERSION '1.1';

as-is—the version is available and up-to-date.

@CarsonF CarsonF merged commit 58f6b64 into develop Jun 10, 2025
18 checks passed
@CarsonF CarsonF deleted the gel/unaccent branch June 10, 2025 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant