Revert "[BUGFIX] Typo3DbQueryParser: Use IN with array-operand2" 48/35648/3
authorHelmut Hummel <helmut.hummel@typo3.org>
Fri, 26 Dec 2014 12:33:02 +0000 (13:33 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Fri, 26 Dec 2014 13:16:18 +0000 (14:16 +0100)
Reverts: #63275
Resolves: #64044
Related: #7848

This reverts commit e235c9ad8b32267ece98d843a43daeab430db235.

Change-Id: I71a134469b9b44f892ad13be52d828ca653c03f1
Reviewed-on: http://review.typo3.org/35648
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php

index 5a541ac..2f93657 100644 (file)
@@ -379,15 +379,7 @@ class Typo3DbQueryParser implements \TYPO3\CMS\Core\SingletonInterface {
                                        } else {
                                                $additionalWhereForMatchFields = '';
                                        }
-                                       $operand2IsMultiValueType = \TYPO3\CMS\Extbase\Utility\TypeHandlingUtility::isValidTypeForMultiValueComparison($operand2);
-                                       $sql['where'][] = $tableName . '.uid IN (SELECT ' . $columnMap->getParentKeyFieldName()
-                                               . ' FROM ' . $relationTableName
-                                               . ' WHERE ' . $columnMap->getChildKeyFieldName()
-                                                       . ($operand2IsMultiValueType
-                                                               ? ' IN (' . $parameterIdentifier . ')'
-                                                               : '=' . $parameterIdentifier
-                                                       )
-                                               . $additionalWhereForMatchFields . ')';
+                                       $sql['where'][] = $tableName . '.uid IN (SELECT ' . $columnMap->getParentKeyFieldName() . ' FROM ' . $relationTableName . ' WHERE ' . $columnMap->getChildKeyFieldName() . '=' . $parameterIdentifier . $additionalWhereForMatchFields . ')';
                                } elseif ($typeOfRelation === ColumnMap::RELATION_HAS_MANY) {
                                        $parentKeyFieldName = $columnMap->getParentKeyFieldName();
                                        if (isset($parentKeyFieldName)) {
index ed103c4..d4d6d4b 100644 (file)
@@ -228,55 +228,6 @@ class Typo3DbQueryParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertSame($expectedSql, $sql);
        }
 
-       /**
-        * @test
-        */
-       public function comparisonStatementGenerationWorksWithArrayAsOperand2() {
-               $dummyClassname = 'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Persistence\\Generic\\Storage\\DummyClass';
-               $dummyTablename = 'tx_extbase_tests_dummytable';
-               $mockSource = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\Selector::class, array('getNodeTypeName'), array(), '', FALSE);
-               $mockSource->expects($this->any())->method('getNodeTypeName')->will($this->returnValue($dummyClassname));
-
-               $columnMap = new \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap('', '');
-               $columnMap->setTypeOfRelation(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY);
-               $columnMap->setRelationTableName('sys_category_record_mm');
-               $columnMap->setRelationTableMatchFields(array(
-                       'tablenames' => $dummyTablename,
-                       'fieldname' => 'categories'
-               ));
-               $columnMap->setParentKeyFieldName('uid_foreign');
-               $columnMap->setChildKeyFieldName('uid_local');
-
-               $mockDataMap = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMap::class, array('getColumnMap'), array(), '', FALSE);
-               $mockDataMap->expects($this->any())->method('getColumnMap')->will($this->returnValue($columnMap));
-
-               $mockDataMapper = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class, array('convertPropertyNameToColumnName', 'convertClassNameToTableName', 'getDataMap'), array(), '', FALSE);
-               $mockDataMapper->expects($this->any())->method('convertClassNameToTableName')->with($dummyClassname)->will($this->returnValue($dummyTablename));
-               $mockDataMapper->expects($this->any())->method('convertPropertyNameToColumnName')->will($this->returnValue('converted_fieldname'));
-               $mockDataMapper->expects($this->any())->method('getDataMap')->will($this->returnValue($mockDataMap));
-
-               $mockDatabaseHandle = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array('fullQuoteStr'), array(), '', FALSE);
-               $mockDatabaseHandle->expects($this->at(0))->method('fullQuoteStr')->with($dummyTablename, 'sys_category_record_mm')->will($this->returnValue('\'' . $dummyTablename . '\''));
-               $mockDatabaseHandle->expects($this->at(1))->method('fullQuoteStr')->with('categories', 'sys_category_record_mm')->will($this->returnValue("'categories'"));
-
-               $sql = array();
-               $comparison = new \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Comparison(
-                       /* operand1 */
-                       new \TYPO3\CMS\Extbase\Persistence\Generic\Qom\PropertyValue($dummyTablename,'categories'),
-                       /* operator */
-                       \TYPO3\CMS\Extbase\Persistence\QueryInterface::OPERATOR_CONTAINS,
-                       /* operand2 */
-                       array(1, 3)
-               );
-               $comparison->setParameterIdentifier('categories');
-               $mockTypo3DbQueryParser = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class, array('dummy'), array(), '', FALSE);
-               $mockTypo3DbQueryParser->_set('dataMapper', $mockDataMapper);
-               $mockTypo3DbQueryParser->_set('databaseHandle', $mockDatabaseHandle);
-               $mockTypo3DbQueryParser->_callRef('parseComparison', $comparison, $mockSource, $sql);
-               $expectedSql = array('where' => array($dummyTablename . '.uid IN (SELECT uid_foreign FROM sys_category_record_mm WHERE uid_local IN (:categories) AND tablenames = \'' . $dummyTablename . '\' AND fieldname = \'categories\')'));
-               $this->assertSame($expectedSql, $sql);
-       }
-
        public function providerForVisibilityConstraintStatement() {
                return array(
                        'in be: include all' => array('BE', TRUE, array(), TRUE, NULL),