phpmyadmin / phpmyadmin/sql-parser
CASE with alias is not properly parsed
未关闭
还没有人认领这个 Issue。
bug
- 主要语言
- PHP
- 星标
- 485
- 派生
- 119
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先通过 Parser 重现所提供的 CASE 表达式,并比较报告的错误和 build() 的输出。跟踪 CASE 表达式如何使用别名和关键字,然后添加一个回归用例,表明此 SQL 可以无错误地解析,并且 build() 生成的结果正确保留了别名。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php, sql
- 领域
- compilers, databases
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100