sanjosh / php-sql-parser

Automatically exported from code.google.com/p/php-sql-parser
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

NATURAL JOINS parse error #138

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
While parsing the NATURAL JOIN in a query like

SELECT ivoid, access_url, name, ucd, description FROM rr.capability NATURAL 
JOIN rr.interface NATURAL JOIN rr.table_column NATURAL JOIN rr.res_table WHERE 
standard_id='ivo://ivoa.net/std/TAP' AND 1=ivo_hasword(table_description, 
'quasar') AND ucd='phot.mag;em.opt.V'

the NATURAL JOIN part has NATURAL as an alias and only JOIN in the join_type 
element:

  ["FROM"]=>
  array(4) {
    [0]=>
    array(10) {
      ["expr_type"]=>
      string(5) "table"
      ["table"]=>
      string(13) "rr.capability"
      ["no_quotes"]=>
      array(2) {
        ["delim"]=>
        string(1) "."
        ["parts"]=>
        array(2) {
          [0]=>
          string(2) "rr"
          [1]=>
          string(10) "capability"
        }
      }
      ["alias"]=>
      array(4) {
        ["as"]=>
        bool(false)
        ["name"]=>
        string(7) "NATURAL"
        ["no_quotes"]=>
        array(2) {
          ["delim"]=>
          bool(false)
          ["parts"]=>
          array(1) {
            [0]=>
            string(7) "NATURAL"
          }
        }
        ["base_expr"]=>
        string(7) "NATURAL"
      }
      ["hints"]=>
      bool(false)
      ["join_type"]=>
      string(4) "JOIN"
      ["ref_type"]=>
      bool(false)
      ["ref_clause"]=>
      bool(false)
      ["base_expr"]=>
      string(13) "rr.capability"
      ["sub_tree"]=>
      bool(false)
    }

NATURAL should not end up as an alias

Original issue reported on code.google.com by adrian.p...@googlemail.com on 8 May 2014 at 1:43

GoogleCodeExporter commented 8 years ago
See r1398, I have added some code to fix this issue.

Original comment by pho...@gmx.de on 15 Sep 2014 at 7:34

GoogleCodeExporter commented 8 years ago

Original comment by pho...@gmx.de on 22 Sep 2014 at 11:49