Skip to content

test: an empty VALUES without range or set columns keeps EF Core's behaviour - #264

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
test/empty-values-guard
Oct 19, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
test/empty-values-guard

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #252

Problem

EmptyCollectionRewriter rewrites an empty VALUES only when a column read from it is a registered range or value set type (HoldsAPluginType). The XML doc promises that a collection of other values, sent the same way by a context configured for MultipleParameters, keeps EF Core's own behaviour. No test held it: removing the guard passed all seven test projects.

Change

A new test, EmptyCollectionGuardTests, with no production change. It builds two contexts over an int-only entity, both under ParameterizedCollectionMode = MultipleParameters, one with UseValueRanges() and one without. It runs four queries over an empty List<int> and requires the same outcome, SQL text or exception, from both:

  • Any(id => id > c.Id), which reads the collection from VALUES;
  • Any(id => id == c.Id), which EF Core turns into IN and so never reaches VALUES;
  • Count(id => id > c.Id) == 0;
  • All(id => id != c.Id).

Tests

  • Proved by reverting. With the guard line removed, the test fails on the Any case. Plain EF Core throws InvalidOperationException: Empty collections are not supported as inline query roots., while the plugin wrote (VALUES (NULL::int)) … WHERE FALSE. The Count case shows the same split.
  • The EF Core translation suite passes.

🤖 Generated with Claude Code

…haviour

EmptyCollectionRewriter rewrites an empty VALUES only when a column read from it is a registered
range or value set type (HoldsAPluginType), so a context configured for MultipleParameters keeps EF
Core's own behaviour for a collection of plain values. Nothing held it: removing the guard passed
every suite.

EmptyCollectionGuardTests runs Any (with a predicate EF Core cannot turn into IN, and with one it
can), Count and All over an empty List<int> under MultipleParameters with and without the plugin,
and requires the same SQL or the same exception. Without the guard, Any and Count are rewritten
where plain EF Core throws "Empty collections are not supported as inline query roots".

Closes #252

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.0.0 milestone Oct 19, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (oracles, harnesses); no library code package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL labels Oct 19, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit c924d3a into main Oct 19, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the test/empty-values-guard branch October 19, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL tests Adds or changes tests only (oracles, harnesses); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No test holds that EmptyCollectionRewriter leaves a VALUES without range or set columns alone

1 participant