Skip to content

Validate date-time query-constant operands - #62

Merged
alex-clickhouse merged 1 commit into
mainfrom
fix/datetime-query-constant-operands
Aug 14, 2026
Merged

Validate date-time query-constant operands#62
alex-clickhouse merged 1 commit into
mainfrom
fix/datetime-query-constant-operands

Conversation

@alex-clickhouse

Copy link
Copy Markdown
Collaborator

Summary

  • reject row-dependent ToStartOfWeek modes and ToStartOfInterval sizes during query translation
  • continue translating SQL literals and typed query parameters
  • document the ClickHouse query-constant constraint and cover both accepted and rejected operands

Why

ClickHouse requires the optional toStartOfWeek mode and the interval size passed through toInterval* to be constant for the query. The translator previously forwarded arbitrary row expressions, producing SQL such as toStartOfWeek(ts, mode_column), which ClickHouse rejects with ILLEGAL_COLUMN.

Recognized invalid calls now fail during query compilation with an actionable message. This also prevents EF Core's top-level client-projection fallback from fetching rows before invoking the throwing client stub.

This is a follow-up to #57.

Validation

  • dotnet build
  • dotnet test test/EFCore.ClickHouse.Tests/EFCore.ClickHouse.Tests.csproj --no-build — 661 passed
  • dotnet test test/EFCore.ClickHouse.FunctionalTests/EFCore.ClickHouse.FunctionalTests.csproj --no-build — 323 passed, 4 skipped
  • targeted date-time translation tests — 28 passed
  • independent code review — approved with no findings

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ors/Internal/ClickHouseDateTimeMethodTranslator.cs 90.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@alex-clickhouse
alex-clickhouse requested a balanced review from Copilot August 14, 2026 09:59
@alex-clickhouse
alex-clickhouse marked this pull request as ready for review August 14, 2026 09:59

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

Adds query-translation validation for ClickHouse date-time operands that must remain constant throughout a query.

Changes:

  • Rejects row-dependent week modes and interval sizes with actionable errors.
  • Preserves support for literals and captured parameters.
  • Adds integration/negative tests and updates public documentation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ClickHouseDateTimeMethodTranslator.cs Validates query-constant operands.
ClickHouseDateTimeDbFunctionsExtensions.cs Documents operand constraints.
DateTimeFunctionsTranslationTests.cs Covers accepted and rejected operands.
README.md Documents usage restrictions.
CHANGELOG.md Records the bug fix.
RELEASENOTES.md Adds release-facing fix details.

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

@alex-clickhouse
alex-clickhouse merged commit a1afe01 into main Aug 14, 2026
4 checks passed
@alex-clickhouse
alex-clickhouse deleted the fix/datetime-query-constant-operands branch August 14, 2026 10:04
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.

2 participants