Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer inline collection element type mappings from each other (and onto the projection) #33438

Closed
roji opened this issue Mar 30, 2024 · 2 comments · Fixed by #33439
Closed

Infer inline collection element type mappings from each other (and onto the projection) #33438

roji opened this issue Mar 30, 2024 · 2 comments · Fixed by #33439
Assignees
Labels
area-primitive-collections area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@roji
Copy link
Member

roji commented Mar 30, 2024

Our logic for handling inline collections (VALUES) in relational currently does the same thing as for parameter collections - the type mapping is left null, and is inferred based on usage in the query (e.g. if the query's projection column is compared to an actual column, that latter column's type mapping gets inferred to the VALUES expression).

However, unlike a parameter collection, an inline collection can actually contain a column with a type mapping. For example, in the following:

await context.Blogs.Where(b => new[] { b.Name }...).ToListAsync();

The type mapping of the SQL ValuesExpression projection should just bubble up from the type mapping of b.Name. Similarly, if there are some constants/parameters in the inline collection, we should infer their type mapping from the column in the same type mapping:

await context.Blogs.Where(b => new[] { b.Name, "foo" }...).ToListAsync();

This is what we already do for InExpression over an inline collection, which is conceptually very similar.

Triggered by analysis by @maumar in #33410 (comment)

@roji roji self-assigned this Mar 30, 2024
roji added a commit to roji/efcore that referenced this issue Mar 30, 2024
roji added a commit to roji/efcore that referenced this issue Mar 30, 2024
roji added a commit to roji/efcore that referenced this issue Mar 30, 2024
@roji roji closed this as completed in c89731a Mar 31, 2024
@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 31, 2024
@roji roji added this to the 9.0.0 milestone Mar 31, 2024
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview4 Apr 2, 2024
@maumar
Copy link
Contributor

maumar commented Apr 6, 2024

@roji, should we patch this, given that #33410 is a regression and the fix is not too complicated?

@maumar maumar reopened this Apr 6, 2024
@roji
Copy link
Member Author

roji commented Apr 6, 2024

We could... though note that this (and #33439) don't actually fix #33410 specifically, since that uses Union and not Concat... Also I agree that these fixes are simple enough and patchable, though this isn't exactly a one-liner either.

Should we wait for more user complaints about this first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-primitive-collections area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants