Uploaded image for project: 'In-Portal CMS'
  1. In-Portal CMS
  2. INP-753

Generation of COUNT SQL Fails with DISTINCT in sub-query

    XMLWordPrintable

    Details

    • Type: Bug Report
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.1.1
    • Fix Version/s: 5.1.2-B1
    • Component/s: Database
    • Labels:
      None

      Description

      There is a bug in kDBList::getCountSQL method, which generates SQL for counting list totals.

      It checks if there's DISTINCT in SQL and, if it's there, tries to replace it for COUNT(DISTINCT...) construction instead of simple COUNT.

      Problem is that it checks for distinct in ANY place of query, but replaces it in beginning, so, if there's DISTINCT in subquery, it won't replace anything. So, count SQL will be equal to list SQL, and you will get first record's first field's value (according to kDBConnection::GetOne logic) as record count.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex Alex
                Reporter:
                BaSSiST Sergejs Gribs
                Developer:
                Sergejs Gribs
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: