Skip to content

Fix combined Singleline and Multiline regex options - #4164

Merged
roji merged 1 commit into
mainfrom
roji-triage-regex-newline-options
Nov 25, 2026
Merged

roji merged 1 commit into
mainfrom
roji-triage-regex-newline-options

Conversation

@roji

@roji roji commented Nov 25, 2026

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: a4198fc14f404fefaff12a5c4649caffb3e37c0b

Dimension Assessment Rationale
Change confidence 9.5/10 ↑ Four regression tests fail before the fix and pass afterward; all 80 regex tests pass on PostgreSQL 18.4.
↑ Two-line mapping change preserves other option paths.
↓ Broader suite and other PostgreSQL versions not run.
Diagnosis confidence 10/10 ↑ Both mappings select n whenever Multiline is set.
↑ Direct PostgreSQL queries confirm w preserves newline matching and per-line anchors.
Evidence fit 10/10 ↑ Standalone reproduction matches the reported options, newline input, incorrect result and SQL on 10.0.4, 11.0.0 and original main.
↓ PostgreSQL and .NET 10 runtime patch versions differ from the reported environment.

Combining RegexOptions.Singleline and RegexOptions.Multiline currently emits PostgreSQL's n flag, incorrectly preventing . from matching newlines. Use w for this combination in both IsMatch SQL generation and the shared Replace/Count option translation.

Regression tests cover newline matching with per-line anchors, constant and parameter patterns, and IgnoreCase.

Fixes #4155

Fixes #4155

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 20:57
@roji
roji enabled auto-merge (squash) November 25, 2026 20:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the change aligning combined regex options with PostgreSQL semantics.

No open issues 🎉

What changed in this PR

Fixes #4155 by aligning combined RegexOptions.Singleline | RegexOptions.Multiline translation with PostgreSQL semantics: . matches newlines while anchors match per line.

Changes:

  • Emit PostgreSQL’s w flag for the combined options in IsMatch, Replace, and Count.
  • Add four regression tests covering newline matching, per-line anchors, constant and parameter patterns, and IgnoreCase.
File Description
test/​EFCore.PG.FunctionalTests/​Query/​Translations/​StringTranslationsNpgsqlTest.cs Adds regression tests with result and SQL assertions.
src/​EFCore.PG/​Query/​Internal/​NpgsqlQuerySqlGenerator.cs Corrects combined-option SQL generation for IsMatch.
src/​EFCore.PG/​Query/​ExpressionTranslators/​Internal/​NpgsqlRegexTranslator.cs Corrects shared option translation for Replace and Count.

Review effort: Balanced

@roji
roji disabled auto-merge November 25, 2026 21:08
@roji
roji merged commit 287351d into main Nov 25, 2026
13 checks passed
@roji
roji deleted the roji-triage-regex-newline-options branch November 25, 2026 21:08
roji added a commit that referenced this pull request Nov 25, 2026
Fixes #4155

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 287351d)
roji added a commit that referenced this pull request Nov 25, 2026
Fixes #4155

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 287351d)
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.

Regex: RegexOptions.Singleline | RegexOptions.Multiline renders the n flag, so . doesn't match a newline

2 participants