phpmyadmin / phpmyadmin/sql-parser
Re-formating LIMIT destroys DELETE and UPDATE queries
未關閉
還沒有人認領這個 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.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 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