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

Scientific numbers incorrectly parsed #133

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Scientific numbers are incorrectly parsed as in this query:

SELECT x,y,z FROM MDR1.Particles85 WHERE RAND(154321) <= 2.91E-5

The 2.91E-5 part becomes:

    [2]=>
    array(4) {
      ["expr_type"]=>
      string(6) "colref"
      ["base_expr"]=>
      string(5) "2.91E"
      ["no_quotes"]=>
      array(2) {
        ["delim"]=>
        string(1) "."
        ["parts"]=>
        array(2) {
          [0]=>
          string(1) "2"
          [1]=>
          string(3) "91E"
        }
      }
      ["sub_tree"]=>
      bool(false)
    }
    [3]=>
    array(3) {
      ["expr_type"]=>
      string(8) "operator"
      ["base_expr"]=>
      string(1) "-"
      ["sub_tree"]=>
      bool(false)
    }
    [4]=>
    array(3) {
      ["expr_type"]=>
      string(5) "const"
      ["base_expr"]=>
      string(1) "5"
      ["sub_tree"]=>
      bool(false)
    }

Original issue reported on code.google.com by adrian.p...@googlemail.com on 25 Mar 2014 at 4:27

GoogleCodeExporter commented 8 years ago
Hehe, the parser has intelligence. It interprets unknown things, really cool, 
he?

Original comment by pho...@gmx.de on 31 Mar 2014 at 6:16

GoogleCodeExporter commented 8 years ago
Hm, there are a lot of different versions for scientific notation, so it seems 
to be a good idea to concat the tokens within the Lexer. This will increase the 
compute time for all statements :-(

Original comment by pho...@gmx.de on 31 Mar 2014 at 6:36

GoogleCodeExporter commented 8 years ago
I have added a function, which handles scientific numbers like 1e+5 or 1.29E-6. 
It should also recognize 1.29E2. See r1243.

Original comment by pho...@gmx.de on 31 Mar 2014 at 7:41

GoogleCodeExporter commented 8 years ago
Hehe :-) Cool, seems to work! Thanks!

Original comment by adrian.p...@googlemail.com on 1 Apr 2014 at 2:42

GoogleCodeExporter commented 8 years ago

Original comment by pho...@gmx.de on 1 Apr 2014 at 5:48