Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Nov 29, 2023

Fixes #32375, backports #32414.

Description

As part of the primitive collection work for EF 8, we now translate inline query roots to SQL VALUES, which doesn't support empty sets (there must be at least one element); so we had an early check to detect this and throw an informative exception.

However, in the Contains case, we pattern-match the ValuesExpression and optimize it away to an InExpression, so no actual VALUES gets sent to the database. This PR removes the check - allowing ValuesExpression to get get converted to InExpression - and moves the check for empty ValuesExpression to the SQL generation phase.

Customer impact

Queries involving an empty array and Contains no longer translate. This particularly affects dynamic query scenarios where arrays are integrated into the query as constants (inline), and may happen to be empty.

How found

Customers reported on 8.0

Regression

Yes

Testing

Added.

Risk

Very low; quirk added.

@AndriySvyryd
Copy link
Member

Note that the branch is currently closed.

@AndriySvyryd AndriySvyryd added this to the 8.0.2 milestone Dec 1, 2023
@wtgodbe wtgodbe merged commit df6a87d into dotnet:release/8.0 Jan 3, 2024
@roji roji deleted the EmptyInlineCollection8 branch January 3, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants