Skip to content

Support LINQ GroupBy subquery #2210

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

Merged
merged 1 commit into from
Sep 27, 2019
Merged

Conversation

bahusoid
Copy link
Member

@bahusoid bahusoid commented Sep 12, 2019

Fixes #1124

Yet another workaround to make LINQ GroupBy subquery works. IMHO it's less intrusive than last @oskarb attempt in https://github.com/oskarb/nhibernate-core/tree/NH-3155-alt2. And doesn't look very hackish to me - allows type mismatch and doesn't fail in specific places.

switch (resultOperator)
{
case ContainsResultOperator _:
case AnyResultOperator _:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnyResultOperator actually currently doesn't throw on type mismatch. But it looks like omission in ReLinq as I see no reasons why it should behave any differently. So added it just in case if it's changed in ReLinq.

//at Remotion.Linq.Clauses.ResultOperators.ContainsResultOperator.GetOutputDataInfo(StreamedSequenceInfo inputInfo)
//But in this place we don't really care about types involving inside expression, all we need to know is operation result which is bool for Contains
//So let's skip possible type exception mismatch if it allows to generate proper SQL
switch (resultOperator)
Copy link
Member

@hazzik hazzik Sep 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing it here, can we fix the condition at its source?

Copy link
Member Author

@bahusoid bahusoid Sep 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the real source of the issue. You should know this parts much better than me. And as this issue hangs since 2012 I think it's worth to implement such simple workaround.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is removing MaxResultOperator and replacing it with NhMaxExpression.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about Min and others aggregate functions? It's Group By specific not Max specific.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly the reason not to do it. To keep workaround in one place and it doesn't affect perf
(instead of type integrity check inside we do this resultOperator check)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are suggesting that changing NhMaxExpression and etc. will fix issue at its core and it won't be workaround than please make those changes yourself and I will close this PR. As I still don't understand what fix exactly do you have in mind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably fine with the proposed change.

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.

NH-3155 - Linq subquery with group is not supported
3 participants