Fixed bug #14496: SQL parser does not handle ALTER TABLE with character set operation
[Packages/TYPO3.CMS.git] / typo3 / sysext / dbal / tests / sqlparser_general_testcase.php
index 7c9fadc..ac45bf8 100644 (file)
@@ -117,11 +117,36 @@ class sqlparser_general_testcase extends BaseTestCase {
 
        /**
         * @test
+        * @see http://bugs.typo3.org/view.php?id=13104
         */
        public function canGetStringValue() {
-               $parseString = '"some owner\\\' string"';
+               $parseString = '"some owner\\\'s string"';
                $value = $this->fixture->_callRef('getValue', $parseString);
-               $expected = array('some owner\' string', '"');
+               $expected = array('some owner\'s string', '"');
+
+               $this->assertEquals($expected, $value);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13104
+        */
+       public function canGetStringValueWithSingleQuote() {
+               $parseString = "'some owner\'s string'";
+               $value = $this->fixture->_callRef('getValue', $parseString);
+               $expected = array('some owner\'s string', "'");
+
+               $this->assertEquals($expected, $value);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13104
+        */
+       public function canGetStringValueWithDoubleQuote() {
+               $parseString = '"the \"owner\" is here"';
+               $value = $this->fixture->_callRef('getValue', $parseString);
+               $expected = array('the "owner" is here', '"');
 
                $this->assertEquals($expected, $value);
        }
@@ -146,6 +171,209 @@ class sqlparser_general_testcase extends BaseTestCase {
        /**
         * @test
         */
+       public function parseWhereClauseReturnsArray() {
+               $parseString = 'uid IN (1,2) AND (starttime < ' . time() . ' OR cruser_id + 10 < 20)';
+               $where = $this->fixture->parseWhereClause($parseString);
+
+               $this->assertTrue(is_array($where), $where);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
+        */
+       public function canSelectAllFieldsFromPages() {
+               $sql = 'SELECT * FROM pages';
+               $expected = $sql;
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql)); 
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       /**
+        * @test
+        * http://bugs.typo3.org/view.php?id=13504
+        */
+       public function canParseTruncateTable() {
+               $sql = 'TRUNCATE TABLE be_users';
+               $expected = $sql;
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13412
+        */
+       public function canParseAndCompileBetweenOperator() {
+               $parseString = '((scheduled BETWEEN 1265068628 AND 1265068828 ) OR scheduled <= 1265068728) AND NOT exec_time AND NOT process_id AND page_id=1 AND parameters_hash = \'854e9a2a77\'';
+               $where = $this->fixture->parseWhereClause($parseString);
+
+               $this->assertTrue(is_array($where), $where);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+
+               $whereClause = $this->cleanSql($this->fixture->compileWhereClause($where));
+               $expected = '((scheduled BETWEEN 1265068628 AND 1265068828) OR scheduled <= 1265068728) AND NOT exec_time AND NOT process_id AND page_id = 1 AND parameters_hash = \'854e9a2a77\'';
+               $this->assertEquals($expected, $whereClause);
+       }
+
+       /**
+        * @test
+        * http://bugs.typo3.org/view.php?id=13430
+        */
+       public function canParseInsertWithoutSpaceAfterValues() {
+               $parseString = "INSERT INTO static_country_zones VALUES('483', '0', 'NL', 'NLD', '528', 'DR', 'Drenthe', '');";
+               $components = $this->fixture->_callRef('parseINSERT', $parseString);
+
+               $this->assertTrue(is_array($components), $components);
+               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $expected = "INSERT INTO static_country_zones VALUES ('483', '0', 'NL', 'NLD', '528', 'DR', 'Drenthe', '')";
+               $this->assertEquals($expected, $insert);
+       }
+
+       /**
+        * @test
+        * http://bugs.typo3.org/view.php?id=13430
+        */
+       public function canParseInsertWithSpaceAfterValues() {
+               $parseString = "INSERT INTO static_country_zones VALUES ('483', '0', 'NL', 'NLD', '528', 'DR', 'Drenthe', '');";
+               $components = $this->fixture->_callRef('parseINSERT', $parseString);
+
+               $this->assertTrue(is_array($components), $components);
+               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $expected = "INSERT INTO static_country_zones VALUES ('483', '0', 'NL', 'NLD', '528', 'DR', 'Drenthe', '')";
+               $this->assertEquals($expected, $insert);
+       }
+
+       /**
+        * @test
+        */
+       public function canParseInsertWithFields() {
+               $parseString = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
+               $parseString .= "VALUES ('1', '0', '2', '0', 'Africa');";
+               $components = $this->fixture->_callRef('parseINSERT', $parseString);
+
+               $this->assertTrue(is_array($components), $components);
+               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $expected = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
+               $expected .= "VALUES ('1', '0', '2', '0', 'Africa')";
+               $this->assertEquals($expected, $insert);
+       }
+
+       /**
+        * @test
+        * http://bugs.typo3.org/view.php?id=13209
+        */
+       public function canParseExtendedInsert() {
+               $parseString = "INSERT INTO static_territories VALUES ('1', '0', '2', '0', 'Africa'),('2', '0', '9', '0', 'Oceania')," .
+                       "('3', '0', '19', '0', 'Americas'),('4', '0', '142', '0', 'Asia');";
+               $components = $this->fixture->_callRef('parseINSERT', $parseString);
+
+               $this->assertTrue(is_array($components), $components);
+               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $expected = "INSERT INTO static_territories VALUES ('1', '0', '2', '0', 'Africa'), ('2', '0', '9', '0', 'Oceania'), " .
+                       "('3', '0', '19', '0', 'Americas'), ('4', '0', '142', '0', 'Asia')";
+               $this->assertEquals($expected, $insert);
+       }
+
+       /**
+        * @test
+        * http://bugs.typo3.org/view.php?id=13209
+        */
+       public function canParseExtendedInsertWithFields() {
+               $parseString = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
+               $parseString .= "VALUES ('1', '0', '2', '0', 'Africa'),('2', '0', '9', '0', 'Oceania');";
+               $components = $this->fixture->_callRef('parseINSERT', $parseString);
+
+               $this->assertTrue(is_array($components), $components);
+               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $expected = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
+               $expected .= "VALUES ('1', '0', '2', '0', 'Africa'), ('2', '0', '9', '0', 'Oceania')";
+               $this->assertEquals($expected, $insert);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=6196
+        */
+       public function canParseIfNullOperator() {
+               $parseString = 'IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22)';
+               $whereParts = $this->fixture->parseWhereClause($parseString);
+
+               $this->assertTrue(is_array($whereParts), $whereParts);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=6196
+        */
+       public function canParseIfNullOperatorWithAdditionalClauses() {
+               $parseString = '1=1 AND IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22) AND tt_news.sys_language_uid IN (0,-1) ';
+               $parseString .= 'AND tt_news.pid > 0 AND tt_news.pid IN (61) AND tt_news.deleted=0 AND tt_news.t3ver_state<=0 ';
+               $parseString .= 'AND tt_news.hidden=0 AND tt_news.starttime<=1266065460 AND (tt_news.endtime=0 OR tt_news.endtime>1266065460) ';
+               $parseString .= 'AND (tt_news.fe_group=\'\' OR tt_news.fe_group IS NULL OR tt_news.fe_group=\'0\' ';
+               $parseString .= 'OR (tt_news.fe_group LIKE \'%,0,%\' OR tt_news.fe_group LIKE \'0,%\' OR tt_news.fe_group LIKE \'%,0\' ';
+               $parseString .= 'OR tt_news.fe_group=\'0\') OR (tt_news.fe_group LIKE \'%,-1,%\' OR tt_news.fe_group LIKE \'-1,%\' ';
+               $parseString .= 'OR tt_news.fe_group LIKE \'%,-1\' OR tt_news.fe_group=\'-1\'))';
+               $whereParts = $this->fixture->parseWhereClause($parseString);
+
+               $this->assertTrue(is_array($whereParts), $whereParts);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=6196
+        */
+       public function canCompileIfNullOperator() {
+               $parseString = 'SELECT * FROM tx_irfaq_q_cat_mm WHERE IFNULL(tx_irfaq_q_cat_mm.uid_foreign,0) = 1';
+               $components = $this->fixture->_callRef('parseSELECT', $parseString);
+
+               $this->assertTrue(is_array($components), $components);
+               $select = $this->cleanSql($this->fixture->_callRef('compileSELECT', $components));
+               $expected = 'SELECT * FROM tx_irfaq_q_cat_mm WHERE IFNULL(tx_irfaq_q_cat_mm.uid_foreign, 0) = 1';
+               $this->assertEquals($expected, $select);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=14456
+        */
+       public function canParseAlterEngineStatement() {
+               $parseString = 'ALTER TABLE tx_realurl_pathcache ENGINE=InnoDB';
+               $components = $this->fixture->_callRef('parseALTERTABLE', $parseString);
+
+               $this->assertTrue(is_array($components), $components);
+               $alterTable = $this->cleanSql($this->fixture->_callRef('compileALTERTABLE', $components));
+               $expected = 'ALTER TABLE tx_realurl_pathcache ENGINE = InnoDB';
+               $this->assertTrue(is_array($alterTable), $alterTable);
+               $this->assertEquals($expected, $alterTable[0]);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=14496
+        */
+       public function canParseAlterCharacterSetStatement() {
+               $parseString = 'ALTER TABLE `index_phash` DEFAULT CHARACTER SET utf8';
+               $components = $this->fixture->_callRef('parseALTERTABLE', $parseString);
+
+               $this->assertTrue(is_array($components), $components);
+               $alterTable = $this->cleanSql($this->fixture->_callRef('compileALTERTABLE', $components));
+               $expected = 'ALTER TABLE index_phash DEFAULT CHARACTER SET utf8';
+               $this->assertTrue(is_array($alterTable), $alterTable);
+               $this->assertEquals($expected, $alterTable[0]);
+       }
+
+       ///////////////////////////////////////
+       // Tests concerning JOINs
+       ///////////////////////////////////////
+
+       /**
+        * @test
+        */
        public function parseFromTablesWithInnerJoinReturnsArray() {
                $parseString = 'be_users INNER JOIN pages ON pages.cruser_id = be_users.uid';
                $tables = $this->fixture->parseFromTables($parseString);
@@ -203,20 +431,20 @@ class sqlparser_general_testcase extends BaseTestCase {
        /**
         * @test
         */
-       public function parseWhereClauseReturnsArray() {
-               $parseString = 'uid IN (1,2) AND (starttime < ' . time() . ' OR cruser_id + 10 < 20)';
-               $where = $this->fixture->parseWhereClause($parseString);
+       public function canUseInnerJoinInSelect() {
+               $sql = 'SELECT pages.uid, be_users.username FROM be_users INNER JOIN pages ON pages.cruser_id = be_users.uid';
+               $expected = 'SELECT pages.uid, be_users.username FROM be_users INNER JOIN pages ON pages.cruser_id=be_users.uid';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql)); 
 
-               $this->assertTrue(is_array($where), $where);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $this->assertEquals($expected, $actual);
        }
 
        /**
         * @test
         */
-       public function canSelectAllFieldsFromPages() {
-               $sql = 'SELECT * FROM pages';
-               $expected = $sql;
+       public function canUseMultipleInnerJoinsInSelect() {
+               $sql = 'SELECT * FROM tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid = tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid = tt_news_cat_mm.uid_local';
+               $expected = 'SELECT * FROM tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid=tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid=tt_news_cat_mm.uid_local';
                $actual = $this->cleanSql($this->fixture->debug_testSQL($sql)); 
 
                $this->assertEquals($expected, $actual);
@@ -224,31 +452,37 @@ class sqlparser_general_testcase extends BaseTestCase {
 
        /**
         * @test
+        * @see http://bugs.typo3.org/view.php?id=14182
         */
-       public function canUseInnerJoinInSelect() {
-               $sql = 'SELECT pages.uid, be_users.username FROM be_users INNER JOIN pages ON pages.cruser_id = be_users.uid';
-               $expected = 'SELECT pages.uid, be_users.username FROM be_users INNER JOIN pages ON pages.cruser_id=be_users.uid';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql)); 
+       public function canParseMultipleJoinConditions() {
+               $sql = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.pid = T1.uid AND T2.size = 4 WHERE T1.cr_userid = 1';
+               $expected = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.pid=T1.uid AND T2.size=4 WHERE T1.cr_userid = 1';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
 
                $this->assertEquals($expected, $actual);
        }
 
        /**
         * @test
+        * @see http://bugs.typo3.org/view.php?id=14182 
         */
-       public function canUseMultipleInnerJoinsInSelect() {
-               $sql = 'SELECT * FROM tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid = tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid = tt_news_cat_mm.uid_local';
-               $expected = 'SELECT * FROM tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid=tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid=tt_news_cat_mm.uid_local';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql)); 
+       public function canParseMultipleJoinConditionsWithLessThanOperator() {
+               $sql = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.size < 4 OR T2.pid = T1.uid WHERE T1.cr_userid = 1';
+               $expected = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.size<4 OR T2.pid=T1.uid WHERE T1.cr_userid = 1';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
 
                $this->assertEquals($expected, $actual);
        }
 
+       ///////////////////////////////////////
+       // Tests concerning DB management
+       ///////////////////////////////////////
+
        /** 
         * @test
         * @see http://bugs.typo3.org/view.php?id=4466
         */
-       public function indexMayContainALengthRestriction() {
+       public function indexMayContainALengthRestrictionInCreateTable() {
                $parseString = '
                        CREATE TABLE tx_realurl_uniqalias (
                                uid int(11) NOT NULL auto_increment,
@@ -271,5 +505,171 @@ class sqlparser_general_testcase extends BaseTestCase {
                $createTables = $this->fixture->_callRef('parseCREATETABLE', $parseString);
                $this->assertTrue(is_array($createTables), $createTables);
        }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=12829
+        */
+       public function indexMayContainALengthRestrictionInAlterTable() {
+               $parseString = 'ALTER TABLE tx_realurl_uniqalias ADD KEY bk_realurl02 (tablename,field_alias,field_id,value_alias(220),expire)';
+               $alterTables = $this->fixture->_callRef('parseALTERTABLE', $parseString);
+               $this->assertTrue(is_array($alterTables), $alterTables);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=2186
+        */
+       public function canParseUniqueIndexCreation() {
+               $sql = 'ALTER TABLE static_territories ADD UNIQUE uid (uid)';
+               $expected = $sql;
+               $alterTables = $this->fixture->_callRef('parseALTERTABLE', $sql);
+               $queries = $this->fixture->compileSQL($alterTables);
+
+               $this->assertTrue(is_array($queries), $queries);
+               $this->assertTrue(count($queries) == 1, $queries);
+               $this->assertEquals($expected, $queries[0]);
+       }
+
+       ///////////////////////////////////////
+       // Tests concerning subqueries
+       ///////////////////////////////////////
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=12758
+        */
+       public function inWhereClauseSupportsSubquery() {
+               $parseString = 'process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)';
+               $whereParts = $this->fixture->parseWhereClause($parseString);
+
+               $this->assertTrue(is_array($whereParts), $whereParts);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=12758
+        */
+       public function inWhereClauseWithSubqueryIsProperlyCompiled() {
+               $sql = 'SELECT * FROM tx_crawler_queue WHERE process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)';
+               $expected = 'SELECT * FROM tx_crawler_queue WHERE process_id IN (SELECT process_id FROM tx_crawler_process WHERE active = 0 AND deleted = 0)';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=12758
+        */
+       public function whereClauseSupportsExistsKeyword() {
+               $parseString = 'EXISTS (SELECT * FROM tx_crawler_queue WHERE tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)';
+               $whereParts = $this->fixture->parseWhereClause($parseString);
+
+               $this->assertTrue(is_array($whereParts), $whereParts);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=12758
+        */
+       public function existsClauseIsProperlyCompiled() {
+               $sql = 'SELECT * FROM tx_crawler_process WHERE active = 0 AND NOT EXISTS (SELECT * FROM tx_crawler_queue WHERE tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)';
+               $expected = 'SELECT * FROM tx_crawler_process WHERE active = 0 AND NOT EXISTS (SELECT * FROM tx_crawler_queue WHERE tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       ///////////////////////////////////////
+       // Tests concerning advanced operators
+       ///////////////////////////////////////
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13135
+        */
+       public function caseWithBooleanConditionIsSupportedInFields() {
+               $parseString = 'CASE WHEN 1>0 THEN 2 ELSE 1 END AS foo, other_column';
+               $fieldList = $this->fixture->parseFieldList($parseString);
+
+               $this->assertTrue(is_array($fieldList), $fieldList);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13135
+        */
+       public function caseWithBooleanConditionIsProperlyCompiled() {
+               $sql = 'SELECT CASE WHEN 1>0 THEN 2 ELSE 1 END AS foo, other_column FROM mytable';
+               $expected = 'SELECT CASE WHEN 1 > 0 THEN 2 ELSE 1 END AS foo, other_column FROM mytable';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13135
+        */
+       public function caseWithMultipleWhenIsSupportedInFields() {
+               $parseString = 'CASE column WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS number';
+               $fieldList = $this->fixture->parseFieldList($parseString);
+
+               $this->assertTrue(is_array($fieldList), $fieldList);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13135
+        */
+       public function caseWithMultipleWhenIsProperlyCompiled() {
+               $sql = 'SELECT CASE column WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS number FROM mytable';
+               $expected = 'SELECT CASE column WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS number FROM mytable';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13134
+        */
+       public function locateIsSupported() {
+               $sql = 'SELECT * FROM tx_templavoila_tmplobj WHERE LOCATE(\'(fce)\', datastructure)>0';
+               $expected = 'SELECT * FROM tx_templavoila_tmplobj WHERE LOCATE(\'(fce)\', datastructure) > 0';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13134
+        */
+       public function locateWithPositionIsSupported() {
+               $sql = 'SELECT * FROM tx_templavoila_tmplobj WHERE LOCATE(\'(fce)\'  , datastructure  ,10)>0';
+               $expected = 'SELECT * FROM tx_templavoila_tmplobj WHERE LOCATE(\'(fce)\', datastructure, 10) > 0';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13134
+        * @see http://bugs.typo3.org/view.php?id=13135
+        */
+       public function locateWithinCaseIsSupported() {
+               $sql = 'SELECT *, CASE WHEN LOCATE(\'(fce)\', datastructure)>0 THEN 2 ELSE 1 END AS scope FROM tx_templavoila_tmplobj';
+               $expected = 'SELECT *, CASE WHEN LOCATE(\'(fce)\', datastructure) > 0 THEN 2 ELSE 1 END AS scope FROM tx_templavoila_tmplobj';
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
+
+               $this->assertEquals($expected, $actual);
+       }
 }
 ?>
\ No newline at end of file