naveentiwari / 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

INSERT tag structure inconsistent with structure in SELECT, FROM, UPDATE... #75

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

INSERT INTO `foo`.`bar` (col1, col2) VALUES (bla1, bla2)

will be inconstantly parsed into

      ["INSERT"] => array(4) {
        ["table"] => string(22) "`foo`.`bar`"
        ["columns"] => array(2) {
          [0] => array(3) {
            ["expr_type"] => string(6) "colref"
            ["base_expr"] => string(4) "col1"
            ["position"] => int(36)
          }
          [1] => array(3) {
            ["expr_type"] => string(6) "colref"
            ["base_expr"] => string(4) "col2"
            ["position"] => int(42)
          }
        }
        ["base_expr"] => string(22) "`foo`.`bar`"
        ["position"] => int(12)
      }
      ["VALUES"] => array(1) {
        [0] => array(4) {
          ["expr_type"] => string(6) "record"
          ["base_expr"] => string(12) "(bla1, bla2)"
          ["data"] => array(2) {
            [0] => array(4) {
              ["expr_type"] => string(6) "colref"
              ["base_expr"] => string(4) "bla1"
              ["sub_tree"] => bool(false)
              ["position"] => int(56)
            }
            [1] => array(4) {
              ["expr_type"] => string(6) "colref"
              ["base_expr"] => string(4) "bla2"
              ["sub_tree"] => bool(false)
              ["position"] => int(62)
            }
          }
          ["position"] => int(55)
        }
      }

What is the expected output? What do you see instead?

I would expect this to be parsed into the following to be consistent:

      ["INSERT"] => array(4) {
        [0] => array(4) {
        ["table"] => string(22) "`foo`.`bar`"
        ["columns"] => array(2) {
          [0] => array(3) {
            ["expr_type"] => string(6) "colref"
            ["base_expr"] => string(4) "col1"
            ["position"] => int(36)
          }
          [1] => array(3) {
            ["expr_type"] => string(6) "colref"
            ["base_expr"] => string(4) "col2"
            ["position"] => int(42)
          }
        }
        ["base_expr"] => string(22) "`foo`.`bar`"
        ["position"] => int(12)
        }
      }
      ...

i.e. the content of the INSERT node should be put into an array.

What version of the product are you using? 

Latest SVN r339

Original issue reported on code.google.com by adrian.p...@googlemail.com on 28 Aug 2012 at 4:12

GoogleCodeExporter commented 8 years ago
Check r341, I have changed the code. It has influences to all client software, 
which uses INSERT or REPLACE statements.

Original comment by pho...@gmx.de on 29 Aug 2012 at 8:19

GoogleCodeExporter commented 8 years ago
issue seems to be fixed now. parse tree is now consistent.

thx for the fix!

Original comment by adrian.p...@googlemail.com on 3 Sep 2012 at 8:59

GoogleCodeExporter commented 8 years ago

Original comment by pho...@gmx.de on 3 Sep 2012 at 9:59