phpmyadmin / phpmyadmin/sql-parser

Re-formating LIMIT destroys DELETE and UPDATE queries

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

还没有人认领这个 Issue。

bug
主要语言
PHP
星标
485
派生
119
PR 合并指标
30 天内没有已合并 PR

描述

When building queries, the LIMIT is re-formatted. For example SELECT * FROM tbl LIMIT 1 is changed to SELECT * FROM tbl LIMIT 0, 1. This works just fine for SELECT queries, but not for DELETE or UPDATE queries.

Example:

$query1 = "DELETE FROM a LIMIT 1";
$parser = new PhpMyAdmin\SqlParser\Parser($query1);
$statement = $parser->statements[0];

$table2 = new \PhpMyAdmin\SqlParser\Components\Expression("", "b", "", "");
$statement->from[0] = $table2;

echo $statement->build();

results in

DELETE  FROM `b` LIMIT 0, 1

The changed query fails, while the original query is perfect SQL.

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先使用报告中所示的 Parser 构造函数和 statement->build() 示例重现该问题,然后跟踪 DELETE 和 UPDATE 语句中 LIMIT 的构建方式。Issue 未指定文件或测试;完成标准是重建后的 DELETE 和 UPDATE 查询保留有效的 LIMIT 语法,同时 SELECT 的行为保持正确。

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

评估

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

把新 issue 发到你的邮箱

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