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

TIMESTAMPDIFF function issue #83

Open
NikitaKharkov opened this issue Oct 8, 2021 · 2 comments · May be fixed by #84
Open

TIMESTAMPDIFF function issue #83

NikitaKharkov opened this issue Oct 8, 2021 · 2 comments · May be fixed by #84

Comments

@NikitaKharkov
Copy link

NikitaKharkov commented Oct 8, 2021

So the problem is pretty simple:

The original:

TIMESTAMPDIFF(SECOND, uc_call.created_at, uc_call.ended_at) - uc_call.duration as waiting

The result:

TIMESTAMPDIFF(`SECOND`, `uc_call`.`created_at`, `uc_call`.`ended_at`) - `uc_call`.`duration` AS waiting

So, it makes the first argument as a ColRef, but should as... I even don't know :) Because I didn't find any class which can be matched with the date/time reserved words.

@homersimpsons
Copy link
Collaborator

homersimpsons commented Oct 11, 2021

Hello @NikitaKharkov, thank you for your report.

The parser is in fact returning this as a ColRef (instead of a Reserved). You can avoid the issue using the SQL_TSI_* constants as such:

TIMESTAMPDIFF(SQL_TSI_SECOND, uc_call.created_at, uc_call.ended_at) - uc_call.duration as waiting

@homersimpsons
Copy link
Collaborator

homersimpsons commented Oct 11, 2021

After a bit of digging this issue comes from https://github.com/greenlion/PHP-SQL-Parser and it seems that it has already been reported: greenlion/PHP-SQL-Parser#212.

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