phpmyadmin / phpmyadmin/sql-parser
CASE with alias is not properly parsed
Open
Nobody has claimed this yet.
bug
- Dominant language
- PHP
- Stars
- 485
- Forks
- 119
- PR merge metrics
- No merged PRs in 30d
Description
Feeding this SQL to the Parser:
SELECT
CASE
WHEN a.kol = 1 THEN 'one'
ELSE a.kol
END as 'case'
FROM foo a;
will result in errors, and calling build() on the statement will result in this SQL:
SELECT CASE 'case' ELSE a.kol AS `END` END FROM foo AS `a`
The errors array contains these errors:
An alias was previously found.An alias was expected.Unexpected keyword.Unexpected end of CASE expression
I encountered this problem since I upgraded from 5.8.2 to 5.9.1.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied CASE expression through the Parser and comparing the reported errors and build() output. Trace how CASE expressions consume aliases and keywords, then add a regression case showing that this SQL parses without errors and builds with the alias preserved correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, sql
- Domain
- compilers, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100