Conversation
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
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address the nullable API contract and PostgreSQL version gating issues.
Review effort: Lite
Findings: 1
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
EF.Functions.FuzzyStringMatchDaitchMokotoff(text), translated to PostgreSQL'sdaitch_mokotoff(text)from fuzzystrmatch (PostgreSQL 16+). Thestring[]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:
git diff --checkclean.TZ=UTCagainst 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_DateTimefailures (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:Both
publish-ciandreleasewere 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 upstream930bd291, without this PR. All actual GitHub CI jobs, including PostgreSQL 18 Debug, passed.