phpmyadmin / phpmyadmin/sql-parser
unrecognised keyword 'CASE'
Open
Nobody has claimed this yet.
bug
help wanted
- Dominant language
- PHP
- Stars
- 485
- Forks
- 119
- PR merge metrics
- No merged PRs in 30d
Description
$ ./lint-query --query 'SELECT * FROM `Caracteristiques` WHERE CASE `an` WHEN 86400 THEN 4 WHEN 604800 THEN 5 WHEN 2419200 THEN 6 WHEN 31536000 THEN 7 ELSE -1 END < 0;'
#1: Unrecognised keyword. (near "CASE" at position 39)
#2: Unexpected token. (near "`an`" at position 44)
#3: Unrecognised keyword. (near "WHEN" at position 49)
#4: Unexpected token. (near "86400" at position 54)
#5: Unrecognised keyword. (near "THEN" at position 60)
#6: Unexpected token. (near "4" at position 65)
#7: Unrecognised keyword. (near "WHEN" at position 67)
#8: Unexpected token. (near "604800" at position 72)
#9: Unrecognised keyword. (near "THEN" at position 79)
#10: Unexpected token. (near "5" at position 84)
#11: Unrecognised keyword. (near "WHEN" at position 86)
#12: Unexpected token. (near "2419200" at position 91)
#13: Unrecognised keyword. (near "THEN" at position 99)
#14: Unexpected token. (near "6" at position 104)
#15: Unrecognised keyword. (near "WHEN" at position 106)
#16: Unexpected token. (near "31536000" at position 111)
#17: Unrecognised keyword. (near "THEN" at position 120)
#18: Unexpected token. (near "7" at position 125)
#19: Unrecognised keyword. (near "ELSE" at position 127)
#20: Unexpected token. (near "-1" at position 132)
#21: Unrecognised keyword. (near "END" at position 135)
#22: Unexpected token. (near "<" at position 139)
#23: Unexpected token. (near "0" at position 141)
I am using the version shipped with phpMyAdmin 4.9.1. The query works.
SELECT VERSION();
5.7.27-30-57-log
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 query with the lint-query entry point and inspect how the SQL parser handles CASE, WHEN, THEN, ELSE, and END tokens. Add coverage for this query and confirm that valid MySQL CASE expressions no longer produce the reported errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, php, sql
- Domain
- databases, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100