Project

General

Profile

Actions

Feature #81451

closed

Support mysql mode "ONLY_FULL_GROUP_BY"

Added by Cihan Yesilöz about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2017-06-03
Due date:
% Done:

0%

Estimated time:
PHP Version:
7.0
Tags:
ONLY_FULL_GROUP_BY
Complexity:
Sprint Focus:

Description

TYPO3 does not support the "ONLY_FULL_GROUP_BY" strict mode of MySQL. Therefore TYPO3 shows the exception "#1472074485: 'company.tx_faq_domain_model_question.pid' isn't in GROUP BY" in case ONLY_FULL_GROUP_BY is disrespected.

Example:

class QuestionRepository extends Repository
{
    /**
     * @return array|QueryResultInterface
     */
    public function findBySettings()
    {
        $query = $this->createQuery();
        $categoryUids = [1,2];
        $or = [];
        foreach ($categoryUids as $categoryUid) {
            $or[] = $query->equals('categories.uid', (int)$categoryUid);
        }

        $query->matching($query->logicalOr($or));
        return $query->execute();
    }
}

Leads to this SQL-query:

SELECT `tx_company1_domain_model_question`.* 
FROM `tx_company1_domain_model_question` `tx_company1_domain_model_question` 
  LEFT JOIN `tx_company1_question_category_mm` `tx_company1_question_category_mm` 
    ON `tx_company1_domain_model_question`.`uid` = tx_company1_question_category_mmuid_local 
  LEFT JOIN `tx_company1_domain_model_category` `tx_company1_domain_model_category` 
    ON `tx_company1_question_category_mm`.`uid_foreign` = tx_company1_domain_model_category.uid 
WHERE ...
GROUP BY `tx_company1_domain_model_question`.`uid` 

According to the MySQL-documentation "ONLY_FULL_GROUP_BY" requires each column, used in the SELECT-clause to be also listed in the "GROUP BY" clause.

Responsible places in the TYPO3-core which are causing the issue:

To add support for "ONLY_FULL_GROUP_BY" the only possible solution which pops into my mind is:
1) First only fetch the uid's instead of "*".
2) Build a new query, which returns all records for the uid's found in 1)

Actions #1

Updated by Cihan Yesilöz about 7 years ago

  • Description updated (diff)
Actions #2

Updated by Morton Jonuschat about 7 years ago

  • Status changed from New to Needs Feedback

Can you provide more details to your environment (MySQL version etc). Most MySQL versions support feature T301 of the SQL99 standard which allows accessing non-aggregated columns as long as they are functionally dependent on the columns in the GROUP BY statement. Given that UID should be the primary key all columns are functionally dependent on that column and the query normally works as intended.

Actions #3

Updated by Riccardo De Contardi almost 7 years ago

  • Status changed from Needs Feedback to Closed

No feedback for 90 days => closing it.

If you think that this is the wrong decision or experience the issue again or have more information about how to reproduce it, please reopen it or open a new issue with a reference to this one. Thank you.

Actions

Also available in: Atom PDF