Skip to content

NH-3789 - generating sql comand "Having" with two conditions #1336

Open
@nhibernate-bot

Description

@nhibernate-bot

Glautter created an issue — 7th May 2015, 18:07:30:

When trying to generate a search with the "Having" clause, there is a small poblem while riding queryover with two conditions.

Examples:

If I put just the condition of zero, it generates "HAVING".

Where(Restrictions.Eq(Projections.Sum<MyClass>((x) => x.Valor), 0))
having (sum(classAlias.value) = 0)

but if use: not generate the sql "HAVING"

.Where(Restrictions.Eq(Projections.SqlFunction("coalesce", NHibernateUtil.Object,Projections.Sum<MinhaClasse>(x => x.Valor), Projections.Constant(0)), 0));

in other words

AND nvl(sum(classAlias.value), 0) = 0 

Or

using:

.Where(Restrictions.Eq(Projections.Sum<MinhaClasse>((x) => x.Valor), 0) || 
Restrictions.IsNull(Projections.Sum<MinhaClasse>((x) => x.Receita)))

in other words

AND (sum(classAlias.value) = 0 or sum(classAlias.value) is null)

Just because I include a further condition is failing to generate "Having clause"

Thank you in Advance


Alexander Zaytsev added a comment — 7th May 2015, 21:46:21:

Related discussion: https://groups.google.com/d/topic/nhusers/hDKnzeEbk50/discussion


Alexander Zaytsev added a comment — 8th July 2015, 5:12:06:

<~Glautter> can you please provide a complete failing test case?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions