Uploaded image for project: 'Torque'
  1. Torque
  2. TORQUE-365

CountHelper doesn't work, when Criteria has "setDisctint()"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.1
    • 6.0
    • Runtime

    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.

      boolean distinct = isAndSetDistinct(criteriaSelectModifiers) && !Objects.equals(columnName, "*"); // org.apache.torque.utils.CountHelper:202

      This could probably set "DISTINCT" directly behind the SELECT, but not inside the "COUNT()" clause, generating at least valid SQL.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mwriedt Max Philipp Wriedt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: