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

Improve type mapping inference for primitive collections #31109

Open
Tracked by #30731
roji opened this issue Jun 20, 2023 · 0 comments
Open
Tracked by #30731

Improve type mapping inference for primitive collections #31109

roji opened this issue Jun 20, 2023 · 0 comments

Comments

@roji
Copy link
Member

roji commented Jun 20, 2023

Example scenario which doesn't currently work - with a non-default type mapping

Where(m => dateTimes.Any(d => d == t.SomeColumnWithNonDefaultMapping && d != "foo")

The issue is that parameter/constant primitive collections aren't initially typed (i.e. they need to be inferred based on e.g. comparison to a column). If an untyped primitive collection ColumnExpression is compared to a typed ColumnExpression, we apply the inferred type mapping back on the collection. However, if the same untyped ColumnExpression is also compared to something untyped (e.g. "foo"), our current behavior is to apply the default type mapping in SqlExpressionFactory; this means that when inferring the type of the primitive collection, we have two conflicting type mappings - the default one (inferred from d != null above), and the non-default one (inferred from the comparison to SomeColumnWithNonDefaultMapping).

The proper solution here would be to stop inferring the default type mapping in SqlExpressionFactory, and to leave the ColumnExpression null; that would allow us to apply the inferred type mapping on it later (based on SomeColumnWithNonDefaultMapping above). We would then need to also re-apply type mappings as the visit goes back up the tree, applying the inferred type mapping from d to "foo" in the above example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants