Skip to content

Add Daitch-Mokotoff fuzzy string matching support - #3922

Open
adomorn wants to merge 2 commits into
npgsql:mainfrom
adomorn:feat/daitch-mokotoff
Open

adomorn wants to merge 2 commits into
npgsql:mainfrom
adomorn:feat/daitch-mokotoff

Conversation

@adomorn

@adomorn adomorn commented Sep 26, 2026 •

Copy link
Copy Markdown

Adds EF.Functions.FuzzyStringMatchDaitchMokotoff(text), translated to PostgreSQL's daitch_mokotoff(text) from fuzzystrmatch (PostgreSQL 16+). The string[] result mapping is resolved through the provider's type mapping source.

Keeps parameter-only calls on the server and preserves function null checks: Daitch-Mokotoff can return NULL for a non-null input, including the empty string. Tests cover column and parameter translations, single/multiple codes, empty/null inputs, null comparisons, the array mapping, and rejection of client execution. Translation is enabled only when the configured PostgreSQL version is 16 or later, following the existing version-aware translator pattern. Unit tests cover PostgreSQL 15 rejection and PostgreSQL 16/18 support. New database tests are gated on PostgreSQL 16. The new API annotates its potentially null result as string[]?.

Fixes #3524. LINQ Any/Intersect composition on function results remains outside this change (dotnet/efcore#35980).

Validation:

  • Release build: no warnings or errors; changed-file whitespace and git diff --check clean.
  • Docker PostgreSQL 16.15: 19 fuzzy translation/unit tests passed, including the null-comparison regression (failed before the fix).
  • Docker PostgreSQL 15: 13 fuzzy/unit tests passed; PostgreSQL 16-only tests were excluded by the CI trait filter.
  • Full Release suite on the final commit with TZ=UTC against Docker PostgreSQL 16.15: 28,622 passed, 226 skipped, 0 failed (dotnet test -c Release --no-build --filter-not-trait category=failing). PostGIS is not installed in this container; its tests are excluded by the repository's conditional filter.

The initial full run exposed two unrelated timezone-sensitive DateTimeFunction_subtract_DateTime failures (host in Istanbul, PostgreSQL in UTC). Aligning the test process to UTC resolved both; the complete suite was then rerun successfully.

Additional CI verification on the exact PR head b0c73a6da258234e57c93f63906fc347035939a4: the unchanged Build workflow passed in the fork, with all 8 build/test jobs successful:

  • Ubuntu 26.04: PostgreSQL 13, 14, 15, 16, 17, and 18 in Release, with PostGIS required.
  • Ubuntu 26.04: PostgreSQL 18 in Debug, with PostGIS required.
  • Windows Server 2022: PostgreSQL 17 in Release.

Both publish-ci and release were skipped by their existing repository/event conditions. The upstream run still needs maintainer approval.

An additional local macOS ARM64 Debug run against Docker PostgreSQL 18.6/PostGIS 3.6.4 had 29,014 passing tests, 227 skips, and one unrelated SQL baseline failure in TPCInheritanceQueryNpgsqlTest.Can_insert_update_delete (generated ID 3 versus expected 4). The identical failure reproduces on clean upstream 930bd291, without this PR. All actual GitHub CI jobs, including PostgreSQL 18 Debug, passed.

Translate EF.Functions.FuzzyStringMatchDaitchMokotoff using provider array mapping and preserve null checks for empty inputs. Add PostgreSQL 16 integration and translator tests.

Fixes npgsql#3524
Copilot AI lite review requested due to automatic review settings September 26, 2026 23:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Address the nullable API contract and PostgreSQL version gating issues.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds EF Core/Npgsql support for PostgreSQL 16’s daitch_mokotoff fuzzy string-matching function.

Changes:

  • Adds the public DbFunctions API and SQL translation.
  • Configures array mapping and server-side evaluation.
  • Adds unit and PostgreSQL 16 functional tests.

Moderate findings remain regarding public API nullability annotations and PostgreSQL version-aware translation.

File Description
test/​EFCore.PG.Tests/​Query/​NpgsqlFuzzyStringMatchMethodTranslatorTest.cs Tests translation, mapping, nullability, and client rejection.
test/​EFCore.PG.FunctionalTests/​Query/​FuzzyStringMatchQueryNpgsqlTest.cs Adds PostgreSQL 16 functional coverage.
src/​EFCore.PG/​Query/​Internal/​NpgsqlEvaluatableExpressionFilter.cs Prevents client-side evaluation.
src/​EFCore.PG/​Query/​ExpressionTranslators/​Internal/​NpgsqlMethodCallTranslatorProvider.cs Supplies type mapping support.
src/​EFCore.PG/​Query/​ExpressionTranslators/​Internal/​NpgsqlFuzzyStringMatchMethodTranslator.cs Translates the function and applies array mapping.
src/​EFCore.PG/​Extensions/​DbFunctionsExtensions/​NpgsqlFuzzyStringMatchDbFunctionsExtensions.cs Defines the public database-function API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Follow the provider's version-aware translator pattern, test PostgreSQL 15 rejection and PostgreSQL 16/18 support, and annotate the nullable result.
Copilot AI review requested due to automatic review settings September 26, 2026 23:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

This branch has not been deployed

No deployments
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.

Fuzzy text search: support for Daitch-Mokotoff function

2 participants