/** * @test */ public function multipleExpressiosInWhereClauseAreBracedCorrectly() { $listMaxExpressions = 1000; $mockSpecificsOci8 = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\Specifics\\Oci8', array(), array(), '', FALSE); $mockSpecificsOci8->expects($this->any())->method('getSpecific')->will($this->returnValue($listMaxExpressions)); $INitems = range(0, 1250); $NOTINItems = range(0, 1001); $where = 'uid = 1981 AND uid IN(' . implode(',', $INitems) . ') OR uid = 42 AND uid NOT IN(' . implode(',', $NOTINItems) . ')'; $result = $this->subject->SELECTquery('uid, pid', 'tt_content', $where); $chunks = array_chunk($INitems, $listMaxExpressions); $INItemsWhereExpr = array(); foreach ($chunks as $chunk) { $INItemsWhereExpr[] = '"uid" IN (' . implode(',', $chunk) . ')'; } $chunks = array_chunk($NOTINItems, $listMaxExpressions); $NOTINItemsWhereExpr = array(); foreach ($chunks as $chunk) { $NOTINItemsWhereExpr[] = '"uid" NOT IN (' . implode(',', $chunk) . ')'; } /** * $expectedWhere: * "uid" = 1981 AND ( * "uid" IN (1,2,3,4,...,1000) * OR "uid" IN (1001,1002,...,1250) * ) OR "uid" = 42 AND ( * "uid" NOT IN (1,2,3,4,...,1000) * AND "uid" NOT IN (1001) * ) */ $expectedWhere = '"uid" = 1981 AND (' . implode(' OR ', $INItemsWhereExpr) . ') OR "uid" = 42 AND (' . implode(' AND ', $NOTINItemsWhereExpr) . ')'; $expectedQuery = 'SELECT "uid", "pid" FROM "tt_content" WHERE ' . $expectedWhere; $this->assertEquals($expectedQuery, $this->cleanSql($result)); }
/** * @test * @see http://forge.typo3.org/issues/21514 */ public function notLikeBinaryOperatorIsKept() { $result = $this->cleanSql($this->subject->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE BINARY \'test\'')); $expected = 'SELECT * FROM tt_content WHERE bodytext NOT LIKE BINARY \'test\''; $this->assertEquals($expected, $this->cleanSql($result)); }
/** * @test * @see http://forge.typo3.org/issues/32626 */ public function notEqualAnsiOperatorCanBeParsed() { $result = $this->subject->SELECTquery('*', 'pages', 'pid<>3'); $expected = 'SELECT * FROM "pages" WHERE "pid" <> 3'; $this->assertEquals($expected, $this->cleanSql($result)); }
/** * @test * @see http://forge.typo3.org/issues/43262 */ public function someCountFieldsInOrderByAreNotInGroupBy() { $result = $this->subject->SELECTquery('COUNT(title), COUNT(pid)', 'pages', '', 'title', 'title, pid'); $expected = 'SELECT COUNT("title"), COUNT("pid") FROM "pages" GROUP BY "title" ORDER BY "title"'; $this->assertEquals($expected, $this->cleanSql($result)); }
/** * @test * @see http://forge.typo3.org/issues/27760 */ public function singleQuotesAreProperlyEscaped() { $result = $this->subject->SELECTquery('ISEC.phash', 'index_section ISEC, index_fulltext IFT', 'IFT.fulltextdata LIKE \'%' . $this->subject->quoteStr("Don't worry", 'index_fulltext') . '%\' AND ISEC.phash = IFT.phash', 'ISEC.phash'); $expected = 'SELECT "ISEC"."phash" FROM "index_section" "ISEC", "index_fulltext" "IFT" WHERE "IFT"."fulltextdata" LIKE \'%Don\'\'t worry%\' AND "ISEC"."phash" = "IFT"."phash" GROUP BY "ISEC"."phash"'; $this->assertEquals($expected, $this->cleanSql($result)); }
/** * @test * @see http://forge.typo3.org/issues/21514 */ public function likeBinaryOperatorIsRemoved() { $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext LIKE BINARY \'test\''); $expected = 'SELECT * FROM "tt_content" WHERE (dbms_lob.instr("bodytext", \'test\',1,1) > 0)'; $this->assertEquals($expected, $this->cleanSql($result)); }
/** * @test * @see http://forge.typo3.org/issues/17552 */ public function IfNullIsProperlyRemapped() { $result = $this->subject->SELECTquery('*', 'tt_news_cat_mm', 'IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22)'); $expected = 'SELECT * FROM "tt_news_cat_mm" WHERE ISNULL("tt_news_cat_mm"."uid_foreign", 0) IN (21,22)'; $this->assertEquals($expected, $this->cleanSql($result)); }