phpmyadmin / phpmyadmin/sql-parser

CASE with alias is not properly parsed

未关闭
#588 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先通过 Parser 重现所提供的 CASE 表达式,并比较报告的错误和 build() 的输出。跟踪 CASE 表达式如何使用别名和关键字,然后添加一个回归用例,表明此 SQL 可以无错误地解析,并且 build() 生成的结果正确保留了别名。

由索引模型根据 Issue 内容生成。

评估

技术栈
php, sql
领域
compilers, databases
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。