Fixed bug #12596: RIGHT OUTER JOIN is not supported
authorXavier Perseguers <typo3@perseguers.ch>
Sun, 15 Nov 2009 15:27:35 +0000 (15:27 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Sun, 15 Nov 2009 15:27:35 +0000 (15:27 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@26547 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/ChangeLog
typo3/sysext/dbal/class.ux_t3lib_sqlparser.php
typo3/sysext/dbal/tests/sqlparser_general_testcase.php

index 8b166e2..ff1146c 100644 (file)
@@ -1,3 +1,7 @@
+2009-11-15  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * Fixed bug #12596: RIGHT OUTER JOIN is not supported
+
 2009-11-11  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Added unit test for bug #11093: bigint (int8) values get converted to int4 by int-cast 
index 1251869..9657210 100644 (file)
@@ -75,7 +75,7 @@ class ux_t3lib_sqlparser extends t3lib_sqlparser {
                                        $this->lastStopKeyWord = strtoupper(str_replace(array(' ',"\t","\r","\n"), '', $this->lastStopKeyWord));
                                        return $stack;
                                }
-                               if (!preg_match('/^(LEFT|JOIN|INNER)[[:space:]]+/i', $parseString)) {
+                               if (!preg_match('/^(LEFT|RIGHT|JOIN|INNER)[[:space:]]+/i', $parseString)) {
                                        $stack[$pnt]['as_keyword'] = $this->nextPart($parseString,'^(AS[[:space:]]+)');
                                        $stack[$pnt]['as'] = $this->nextPart($parseString,'^([[:alnum:]_]+)[[:space:]]*');
                                }
@@ -83,7 +83,7 @@ class ux_t3lib_sqlparser extends t3lib_sqlparser {
 
                                // Looking for JOIN
                        $joinCnt = 0;
-                       while ($join = $this->nextPart($parseString,'^(LEFT[[:space:]]+JOIN|LEFT[[:space:]]+OUTER[[:space:]]+JOIN|INNER[[:space:]]+JOIN|JOIN)[[:space:]]+')) {
+                       while ($join = $this->nextPart($parseString,'^(LEFT[[:space:]]+JOIN|LEFT[[:space:]]+OUTER[[:space:]]+JOIN|RIGHT[[:space:]]+JOIN|RIGHT[[:space:]]+OUTER[[:space:]]+JOIN|INNER[[:space:]]+JOIN|JOIN)[[:space:]]+')) {
                                $stack[$pnt]['JOIN'][$joinCnt]['type'] = $join;
                                if ($stack[$pnt]['JOIN'][$joinCnt]['withTable'] = $this->nextPart($parseString, '^([[:alnum:]_]+)[[:space:]]+', 1)) {
                                        if (!preg_match('/^ON[[:space:]]+/i', $parseString)) {
index 6bc4284..78ae611 100644 (file)
@@ -167,6 +167,18 @@ class sqlparser_general_testcase extends BaseTestCase {
 
        /**
         * @test
+        * @see http://bugs.typo3.org/view.php?id=12596
+        */
+       public function parseFromTablesWithRightOuterJoinReturnsArray() {
+               $parseString = 'tx_powermail_fieldsets RIGHT JOIN tt_content ON tx_powermail_fieldsets.tt_content = tt_content.uid';
+               $tables = $this->fixture->parseFromTables($parseString);
+
+               $this->assertTrue(is_array($tables), $tables);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
         */
        public function parseFromTablesWithMultipleJoinsReturnsArray() {
                $parseString = 'be_users LEFT OUTER JOIN pages ON be_users.uid = pages.cruser_id INNER JOIN cache_pages cp ON cp.page_id = pages.uid';
@@ -178,6 +190,18 @@ class sqlparser_general_testcase extends BaseTestCase {
 
        /**
         * @test
+        * @see http://bugs.typo3.org/view.php?id=12596
+        */
+       public function parseFromTablesWithMultipleJoinsAndParenthesesReturnsArray() {
+               $parseString = 'tx_powermail_fieldsets RIGHT JOIN tt_content ON tx_powermail_fieldsets.tt_content = tt_content.uid LEFT JOIN tx_powermail_fields ON tx_powermail_fieldsets.uid = tx_powermail_fields.fieldset';
+               $tables = $this->fixture->parseFromTables($parseString);
+
+               $this->assertTrue(is_array($tables), $tables);
+               $this->assertTrue(empty($parseString), 'parseString is not empty');
+       }
+
+       /**
+        * @test
         */
        public function parseWhereClauseReturnsArray() {
                $parseString = 'uid IN (1,2) AND (starttime < ' . time() . ' OR cruser_id + 10 < 20)';