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 broken for PostgreSQL #587

Closed
timowest opened this Issue Dec 9, 2013 · 1 comment

Comments

Projects
None yet
1 participant
@timowest
Member

timowest commented Dec 9, 2013

For Postgres, SQLTemplates should be changed to:

private String distinctCountStart = "count(distinct(";
private String distinctCountEnd = "))";

As it is not possible today, reflection is used to set these two attributes.

The query produced without the correction is:
select count(distinct "menu"."id", "menu"."name", "menu"."screen", "menu"."parent_menu") from "utils"."menu" "menu"

And error is:

Exception in thread "main" com.mysema.query.QueryException: ERROR: function count(bigint, character varying, bigint, bigint) does not exist
  Dica: No function matches the given name and argument types. You might need to add explicit type casts.
  Posição: 8
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
at com.mysema.query.sql.AbstractSQLQuery.unsafeCount(AbstractSQLQuery.java:772)
... 5 more

The correct sql is:
select count(distinct("menu"."id", "menu"."name", "menu"."screen", "menu"."parent_menu")) from "utils"."menu" "menu"

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Dec 12, 2013

Member

Released in 3.3.0.BETA2

Member

timowest commented Dec 12, 2013

Released in 3.3.0.BETA2

@timowest timowest closed this Dec 12, 2013

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