Skip to content
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
Closed

Aggregate functions on boolean #292

Ghalleb opened this issue Nov 22, 2012 · 8 comments
Milestone

Comments

@Ghalleb
Copy link

@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
Copy link
Member

@timowest 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
Copy link
Author

@Ghalleb 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
Copy link
Member

@timowest timowest commented Nov 22, 2012

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

@Ghalleb
Copy link
Author

@Ghalleb Ghalleb commented Nov 22, 2012

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

@timowest
Copy link
Member

@timowest 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
Copy link
Member

@timowest 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
Copy link
Author

@Ghalleb Ghalleb commented Nov 29, 2012

Thanks a lot

@timowest
Copy link
Member

@timowest 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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants