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

Aggregate functions on boolean #292

Closed
Ghalleb opened this Issue Nov 22, 2012 · 8 comments

Comments

Projects
None yet
2 participants
@Ghalleb

Ghalleb commented Nov 22, 2012

There is no typical aggregate function on boolean sur as bool_and and bool_or on postgresql (correspond to every and any on SQL)

Here you could find the aggregate functions on postgresl:
http://docs.postgresql.fr/8.4/functions-aggregate.html

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 22, 2012

Member

Just to be sure, you suggest this as an improvement to Querydsl SQL? Could you also post example queries that fail?

Member

timowest commented Nov 22, 2012

Just to be sure, you suggest this as an improvement to Querydsl SQL? Could you also post example queries that fail?

@Ghalleb

This comment has been minimized.

Show comment
Hide comment
@Ghalleb

Ghalleb Nov 22, 2012

Yes, this is for an improvement.

Nothing fails as the function doen't exist yet...

I would use something like

(BooleanExpression) myBooleanPath).any()

That would generate (with postgresql):

select bool_or(myBoolean) from ... group by ...

My workaround is tu use

(BooleanExpression) myBooleanPath).castToNum(Integer.class).sum()

and verify if it's greater than 0

Ghalleb commented Nov 22, 2012

Yes, this is for an improvement.

Nothing fails as the function doen't exist yet...

I would use something like

(BooleanExpression) myBooleanPath).any()

That would generate (with postgresql):

select bool_or(myBoolean) from ... group by ...

My workaround is tu use

(BooleanExpression) myBooleanPath).castToNum(Integer.class).sum()

and verify if it's greater than 0

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 22, 2012

Member

So BooleanExpression.any() and BooleanExpression.all() aggregate expressions?

Member

timowest commented Nov 22, 2012

So BooleanExpression.any() and BooleanExpression.all() aggregate expressions?

@Ghalleb

This comment has been minimized.

Show comment
Hide comment
@Ghalleb

Ghalleb Nov 22, 2012

I would call theme every() et any()... like in SQL

Ghalleb commented Nov 22, 2012

I would call theme every() et any()... like in SQL

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 22, 2012

Member

Querydsl uses any/all already in some other places, e.g. eqAll and eqAny, and any/all is also used in JPQL http://zawoad.blogspot.fi/2008/08/introduction-to-java-persistence-query.html

But I will think about it.

Member

timowest commented Nov 22, 2012

Querydsl uses any/all already in some other places, e.g. eqAll and eqAny, and any/all is also used in JPQL http://zawoad.blogspot.fi/2008/08/introduction-to-java-persistence-query.html

But I will think about it.

timowest added a commit that referenced this issue Nov 28, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 28, 2012

Member

They are now available via SQLExpressions.any(BooleanExpression) and SQLExpressions.all(BooleanExpression).

I didn't put them into the core DSL, since they are not (yet?) very well supported.

Member

timowest commented Nov 28, 2012

They are now available via SQLExpressions.any(BooleanExpression) and SQLExpressions.all(BooleanExpression).

I didn't put them into the core DSL, since they are not (yet?) very well supported.

@Ghalleb

This comment has been minimized.

Show comment
Hide comment
@Ghalleb

Ghalleb Nov 29, 2012

Thanks a lot

Ghalleb commented Nov 29, 2012

Thanks a lot

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jan 13, 2013

Member

Released in 3.0.0.BETA1

Member

timowest commented Jan 13, 2013

Released in 3.0.0.BETA1

@timowest timowest closed this Jan 13, 2013

@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014

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