Skip to content

NH-3474 - Fix support of GroupBy with constant keys #434

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
Jul 9, 2015

Conversation

PleasantD
Copy link
Contributor

  • Remove the GROUP BY clause entirely if all keys are constant
  • Re-write the GROUP BY clause using only non-constant keys

@PleasantD
Copy link
Contributor Author

@hazzik It would be very beneficial if this fix could be included in v4.1.0
Please let me know if there are any issues.

FlattenSubQuery(queryModel, subQueryExpression.QueryModel, groupBy);
RemoveCostantGroupByKeys(queryModel, groupBy).ForEach(groupByKeys.Add);
Copy link
Member

Choose a reason for hiding this comment

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

Can you please rewrite this to regular foreach?

@hazzik hazzik added this to the 4.1.0 milestone Jun 25, 2015
@@ -549,6 +549,46 @@ public void GroupByComputedValueInObjectArray()
Assert.AreEqual(830, orderGroups.Sum(g => g.Count));
}

[Test(Description = "NH-3474")]
public void GroupByConstant()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generates
select
cast(count(*) as INT) as col_0_0_,
cast(sum(order0_.Freight) as DECIMAL(19,
5)) as col_1_0_
from
Orders order0_

@PleasantD
Copy link
Contributor Author

Fixed the overcaching issue and fixed other comments.

@PleasantD PleasantD mentioned this pull request Jul 7, 2015
@hazzik
Copy link
Member

hazzik commented Jul 8, 2015

@PleasantD can you please squash the PR and rebase on master?

* Remove the GROUP BY clause entirely if all keys are constant
* Re-write the GROUP BY clause using only non-constant keys
* Adjust the ExpressionKeyVisitor so that constants in GroupBy are not replaced with parameter
* Fix ExpressionKeyVisitor handling of constant arrays to show initialization values
@hazzik hazzik merged commit fbe1ddc into nhibernate:master Jul 9, 2015
@hazzik
Copy link
Member

hazzik commented Jul 9, 2015

I've added some more tests and merged. Thanks

@PleasantD PleasantD deleted the NH-3474 branch March 6, 2017 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants