-
Notifications
You must be signed in to change notification settings - Fork 936
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
Count(Distinct ...) does not work #3215
Comments
Need details. Does it throw exception (than provide exception with full stacktrace) or what? |
Made a quick test (NHibernate.Test/Hql/Ast/HqlFixture.cs): [Test(Description = "GH-3215" )]
public void CountDistinctWithAlias()
{
using var sqlLog = new SqlLogSpy();
var hql = "select l.serialNumber, Count(Distinct l.father.id) as MemCount from Mammal l group by l.serialNumber";
using(var s = OpenSession())
s.CreateQuery(hql).List();
} And everything seems to work OK. |
exception : A recognition error occurred. near line 1, column 327
at NHibernate.Hql.Ast.ANTLR.HqlParser.aggregateDistinctAll()
stacktrace:
at NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException()
at NHibernate.Hql.Ast.ANTLR.HqlParseEngine.Parse()
at NHibernate.Hql.StringQueryExpression.Translate(ISessionFactoryImplementor factory, Boolean filter)
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)
at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)
at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString)
at Behandish.Common.CPersistable.GetList[T](ISession s, Type type, String fetch, Object param, Boolean cache) hql: |
So it looks like some regression from #2502 but I can't reproduce it - test case succeeds. |
I use this test template and I can reproduce it. below test works with NH 5.3.14 but does not work with NH 5.4 : Entitys : Mapping by code:
OnSetUp:
|
Yes it's regression from #2502 |
Fixed by #3217 |
below HQL does not work with NH 5.4 but works with NH 5.3.14 :
select l.Name, Count(Distinct l.Member.ID) as MemCount from Loan l group by l.Name
The text was updated successfully, but these errors were encountered: