Skip to content

Fix LIKE escape mapping with value converters - #3889

Merged
roji merged 1 commit into
mainfrom
roji-fix-ilike-escape-conversion
Jul 23, 2026
Merged

Fix LIKE escape mapping with value converters#3889
roji merged 1 commit into
mainfrom
roji-fix-ilike-escape-conversion

Conversation

@roji

@roji roji commented Jul 23, 2026

Copy link
Copy Markdown
Member

A value converter on a LIKE/ILIKE match property could also be applied to the escape expression, converting the provider-generated empty escape into ESCAPE NULL and causing matching predicates to evaluate as unknown.

This change keeps escape-character type mapping independent from match/pattern inference for both LIKE and ILIKE. It also adds regression coverage that verifies converted properties still match and generate ESCAPE '' for parameterized patterns.

Tests:

  • AdHocMiscellaneousQueryNpgsqlTest.Like_with_implicit_escape_does_not_apply_value_converter
  • NorthwindDbFunctionsQueryNpgsqlTest (41 tests)

Fixes: #3888

Keep LIKE and ILIKE escape expressions independent from match and pattern type mapping so property converters cannot rewrite provider-generated escape values.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e5b861c2-ea5b-411c-8efe-3d925d29c52e
Copilot AI review requested due to automatic review settings July 23, 2026 00:21
@roji
roji enabled auto-merge (squash) July 23, 2026 00:22
@roji
roji merged commit 88629d3 into main Jul 23, 2026
16 checks passed
@roji
roji deleted the roji-fix-ilike-escape-conversion branch July 23, 2026 00:34

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.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Fixes an issue where value converters on LIKE/ILIKE match properties were inadvertently applied to the provider-generated escape expression, resulting in ESCAPE NULL and unknown predicate evaluation.

Changes:

  • Applies type mapping to LikeExpression via provider logic to keep escape-character mapping independent of match/pattern inference.
  • Updates PgILikeExpression type mapping to avoid inheriting value converters for the escape expression.
  • Adds a regression test covering value-converted properties with parameterized patterns and implicit escape.
Show a summary per file
File Description
test/EFCore.PG.FunctionalTests/Query/AdHocMiscellaneousQueryNpgsqlTest.cs Adds a regression test validating LIKE/ILIKE SQL uses ESCAPE '' even with a value converter on the match property.
src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs Adjusts LIKE/ILIKE type mapping so the escape expression does not inherit converters from match/pattern.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs
Comment thread src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs
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.

ILike implicit empty escape applies property ValueConverter, producing ESCAPE NULL

2 participants