Skip to content

Translate Any() over byte array#38168

Open
roji wants to merge 1 commit intomainfrom
roji/port-byte-array-any-test
Open

Translate Any() over byte array#38168
roji wants to merge 1 commit intomainfrom
roji/port-byte-array-any-test

Conversation

@roji
Copy link
Copy Markdown
Member

@roji roji commented Apr 26, 2026

Adds translation of Enumerable.Any() on byte[] to DATALENGTH(col) > 0 (SQL Server) and length(col) > 0 (SQLite). Cosmos keeps AssertTranslationFailed since it doesn't support byte array operations.

The base test is added to ByteArrayTranslationsTestBase with provider-specific SQL assertions.

Ported from npgsql/efcore.pg#3817.

Fixes #38167

Adds translation of Enumerable.Any() on byte[] to DATALENGTH(col) > 0
(SQL Server) and length(col) > 0 (SQLite). The base test is added to
ByteArrayTranslationsTestBase with provider-specific SQL assertions.

Fixes #38167

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roji roji requested a review from a team as a code owner April 26, 2026 13:20
Copilot AI review requested due to automatic review settings April 26, 2026 13:20
@roji roji enabled auto-merge (squash) April 26, 2026 13:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds provider-specific translation for Enumerable.Any() over byte[] in EF Core relational providers, enabling queries like e.ByteArray.Any() to translate to a length check rather than failing translation (Cosmos continues to fail as intended).

Changes:

  • Added a new base specification test for byte[] Any() translation.
  • Implemented translation in SQLite (length(col) > 0) and SQL Server (DATALENGTH(col) > 0) byte-array method translators.
  • Added provider-specific SQL assertions and updated Cosmos to assert translation failure for the new test.

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
test/EFCore.Specification.Tests/Query/Translations/ByteArrayTranslationsTestBase.cs Adds the new shared Any() test over byte[].
test/EFCore.Sqlite.FunctionalTests/Query/Translations/ByteArrayTranslationsSqliteTest.cs Overrides Any() to assert SQLite SQL (length(...) > 0).
test/EFCore.SqlServer.FunctionalTests/Query/Translations/ByteArrayTranslationsSqlServerTest.cs Overrides Any() to assert SQL Server SQL (DATALENGTH(...) > 0).
test/EFCore.Cosmos.FunctionalTests/Query/Translations/ByteArrayTranslationsCosmosTest.cs Overrides Any() to continue asserting translation failure on Cosmos.
src/EFCore.Sqlite.Core/Query/Internal/Translators/SqliteByteArrayMethodTranslator.cs Adds SQLite translation for Enumerable.Any() over byte[].
src/EFCore.SqlServer/Query/Internal/Translators/SqlServerByteArrayMethodTranslator.cs Adds SQL Server translation for Enumerable.Any() over byte[].

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.

Translate Any() over byte array

3 participants