Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplication operator wrongly identified as a "colref" #335

Closed
nicoder opened this issue Apr 19, 2021 · 1 comment · Fixed by #336
Closed

Multiplication operator wrongly identified as a "colref" #335

nicoder opened this issue Apr 19, 2021 · 1 comment · Fixed by #336

Comments

@nicoder
Copy link
Contributor

nicoder commented Apr 19, 2021

Hi,

If a multiplication operator is positioned before a function expression its expr_type is parsed as 'operator':

        $parser = new PHPSQLParser();

        $parser->parse('SELECT 15 * ROUND(3, 1) FROM dual');
        var_dump($parser->parsed['SELECT'][0]['sub_tree'][1]['base_expr']); // string(1) "*"
        var_dump($parser->parsed['SELECT'][0]['sub_tree'][1]['expr_type']); // string(8) "operator"

But if it comes after the function expression its expr_type is parsed as 'colref':

        $parser = new PHPSQLParser();

        $parser->parse('SELECT ROUND(3, 1) * 15 FROM dual');
        var_dump($parser->parsed['SELECT'][0]['sub_tree'][1]['base_expr']); // string(1) "*"
        var_dump($parser->parsed['SELECT'][0]['sub_tree'][1]['expr_type']); // string(8) "colref" <== why?
nicoder added a commit to nicoder/PHP-SQL-Parser that referenced this issue Apr 19, 2021
nicoder added a commit to nicoder/PHP-SQL-Parser that referenced this issue Apr 19, 2021
instead of `'operator'`

(if it was positioned after the function expression, as in the second test)
nicoder added a commit to nicoder/PHP-SQL-Parser that referenced this issue Apr 19, 2021
instead of `'operator'`

(if it was positioned after the function expression, as in the second test)
@greenlion
Copy link
Owner

Hmm. Handling * as a colref is for handling:
select * from ...

That can also be select expr1, ..., * from table

I am not sure this fix makes this work properly. If not I will have to inspect this more thoroughly myself.

greenlion pushed a commit that referenced this issue Aug 11, 2022
* #335 tidy

* fix issue #335 multiplication operator was parsed as `'colref'`

instead of `'operator'`

(if it was positioned after the function expression, as in the second test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants