Open
Conversation
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>
There was a problem hiding this comment.
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[]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds translation of
Enumerable.Any()onbyte[]toDATALENGTH(col) > 0(SQL Server) andlength(col) > 0(SQLite). Cosmos keepsAssertTranslationFailedsince it doesn't support byte array operations.The base test is added to
ByteArrayTranslationsTestBasewith provider-specific SQL assertions.Ported from npgsql/efcore.pg#3817.
Fixes #38167