Skip to content

Always add parentheses around regex pattern in generated SQL - #3924

Open
fritz3n wants to merge 4 commits into
npgsql:mainfrom
fritz3n:main
Open

fritz3n wants to merge 4 commits into
npgsql:mainfrom
fritz3n:main

Conversation

@fritz3n

@fritz3n fritz3n commented Sep 28, 2026

Copy link
Copy Markdown

Fixes #3923

Copilot AI lite review requested due to automatic review settings September 28, 2026 14:26

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

The Singleline non-constant branch still omits parentheses, and JSON-derived pattern regression coverage is missing.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Updates PostgreSQL regex SQL generation to parenthesize dynamic patterns and refresh affected SQL baselines.

Changes:

  • Groups non-constant regex patterns in generated SQL.
  • Updates column- and parameter-pattern baselines.
File Summary
test/​EFCore.PG.FunctionalTests/​Query/​Translations/​StringTranslationsNpgsqlTest.cs Updates regex SQL baseline; lacks JSON-derived pattern coverage.
test/​EFCore.PG.FunctionalTests/​Query/​NorthwindFunctionsQueryNpgsqlTest.cs Updates parameter-pattern baseline.
src/​EFCore.PG/​Query/​Internal/​NpgsqlQuerySqlGenerator.cs Adds grouping for dynamic regex patterns; a non-constant Singleline branch remains ungrouped.

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

Comment thread src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs
Copilot AI review requested due to automatic review settings September 28, 2026 14:46

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

Update the affected SQL baselines and add coverage for JSON-derived regex patterns.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs
Copilot AI review requested due to automatic review settings September 29, 2026 07:09

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

🔵 Needs a closer look

Add regression coverage for expression-based patterns, including the non-constant single-line path.

Review effort: Lite
Findings: 1 High severity

Open (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Add regression coverage for JSON traversal regex patterns

test/​EFCore.PG.FunctionalTests/​Query/​NorthwindFunctionsQueryNpgsqlTest.cs:104

The updated assertions only exercise a plain column and a parameter, so they do not cover the precedence-sensitive case this PR fixes: a pattern expression such as a JSON traversal (json_column ->> 'a'). Please add a regression test that would fail with the old ('(?p)' || pattern) SQL; the new RegexOptions.Singleline non-constant path is also currently only tested with a literal pattern.

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.

Missing Parantheses around JSON patterns in generated SQL

2 participants