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

TRUNCATE in SELECT ends up in its own category #338

Open
Herz3h opened this issue May 19, 2021 · 0 comments
Open

TRUNCATE in SELECT ends up in its own category #338

Herz3h opened this issue May 19, 2021 · 0 comments

Comments

@Herz3h
Copy link
Contributor

Herz3h commented May 19, 2021

Consider this query:

SELECT id, date, type as type, libelle as libelle, TRUNCATE(debit, 2) as debit, TRUNCATE(credit, 2) as credit, ROUND(COALESCE(credit, 0) - COALESCE(debit, 0), 2) as solde FROM compte_cp

Is it intended that the truncate/round end up in their own category ? :

Capture d’écran 2021-05-19 à 15 37 12

I'm editing the where part using the parser, and this makes it problematic because after I make changes to the parsed Array (the one in the picture) and use the Creator, it doesn't include the TRUNCATE part anymore. Instead the creator generates the following:

SELECT id, date, type as type, libelle as libelle, FROM compte_cp

Notice the last comma before FROM.

Either way thank you for this amazing tool !

Edit: I completely forgot that you can write TRUNCATE as the first Keyword of the query (Like SELECT, UPDATE, etc), but also as a function (which is what I do in this case). That seems to be the issue. Not sure if it could be fixed.

Herz3h added a commit to Herz3h/PHP-SQL-Parser that referenced this issue May 28, 2021
greenlion added a commit that referenced this issue Mar 12, 2023
* Fix: Tests.

* Fix issue #322.

* Fix: Handle SubQuery in ref_clause.

* Fix: Handle TRUNCATE() function and TRUNCATE keyword. Issue #338.

---------

Co-authored-by: Justin Swanhart <greenlion@gmail.com>
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

No branches or pull requests

1 participant