[jira] [Updated] (TORQUE-365) CountHelper doesn't work, when Criteria has "setDisctint()"

"Max Philipp Wriedt (Jira)" <[email protected]>
Newsgroups gmane.comp.jakarta.turbine.torque.devel
Message-ID <[email protected]>
     [ https://issues.apache.org/jira/browse/TORQUE-365?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Max Philipp Wriedt updated TORQUE-365:
--------------------------------------
    Description: 
When passing a Criteria which has been modified with "setDistinct()" the CountHelper creates a wrong SQL-Statement containing "SELECT COUNT(DISTINCT *)". This is not valid SQL.

A common workaround is to set a column to count while creating the CountHelper.

If I am not wrong we could also solve this problem inside the count()-function of the CountHelper itself, as there is already a handler for DISTINCT cases.
{code:java}
boolean distinct = isAndSetDistinct(criteriaSelectModifiers) && !Objects.equals(columnName, "*"); // org.apache.torque.utils.CountHelper:202{code}
This could probably set "DISTINCT" directly behind the SELECT, but not inside the "COUNT()" clause, generating at least valid SQL.

  was:
When passing a Criteria which has been modified with "setDistinct()" the CountHelper creates a wrong SQL-Statement containing "SELECT COUNT(DISTINCT *)". This is not valid SQL.

A common workaround is to set a column to count while creating the CountHelper.

If I am not wrong we could also solve this problem inside the count()-function of the CountHelper itself, as there is already a handler for DISTINCT cases.
{code:java}
boolean distinct = isAndSetDistinct(criteriaSelectModifiers) && !Objects.equals(columnName, "*");{code}
This could probably set "DISTINCT" directly behind the SELECT, but not inside the "COUNT()" clause, generating at least valid SQL.


> CountHelper doesn't work, when Criteria has "setDisctint()"
> -----------------------------------------------------------
>
>                 Key: TORQUE-365
>                 URL: https://issues.apache.org/jira/browse/TORQUE-365
>             Project: Torque
>          Issue Type: Bug
>          Components: Runtime
>    Affects Versions: 5.1
>            Reporter: Max Philipp Wriedt
>            Priority: Minor
>              Labels: CountHelper, distinct
>
> When passing a Criteria which has been modified with "setDistinct()" the CountHelper creates a wrong SQL-Statement containing "SELECT COUNT(DISTINCT *)". This is not valid SQL.
> A common workaround is to set a column to count while creating the CountHelper.
> If I am not wrong we could also solve this problem inside the count()-function of the CountHelper itself, as there is already a handler for DISTINCT cases.
> {code:java}
> boolean distinct = isAndSetDistinct(criteriaSelectModifiers) && !Objects.equals(columnName, "*"); // org.apache.torque.utils.CountHelper:202{code}
> This could probably set "DISTINCT" directly behind the SELECT, but not inside the "COUNT()" clause, generating at least valid SQL.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.