apache / apache/datafusion-sqlparser-rs

MySql dialect doesn't handle slash-escaped single quotes

未關閉
#362 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Rust
星號
3.5k
分支
772
平均合併
4 天 9 小時
30 天內合併 PR
17

描述

The following fails to parse:

```rust
fn main() {
println!("{:?}",
sqlparser::parser::Parser::parse_sql(
&sqlparser::dialect::MySqlDialect {},
r#"INSERT INTO `example` (`col`) VALUES ('foo \'bar\' baz');"#
)
);
}
```

Instead returning:

```
Err(ParserError("Expected ), found: bar"))
```

But I believe it shouldn't — `mysqldump` generates SQL that is escaped like this, and the [docs](https://dev.mysql.com/doc/refman/8.0/en/string-literals.html) explicitly mention this as a valid escaping (see Table 9.1).

This is, according to [this doc](https://www.ibm.com/docs/en/informix-servers/12.10?topic=statements-quotation-marks-escape-characters) a difference between ANSI SQL and MySQL, but unfortunately this needs to be fixed in the tokenizer, which AFAICT the dialect system doesn't have a way to hook into?

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

先從 Parser::parse_sql 使用的 tokenizer 和 MySqlDialect 路徑開始,然後重現提供的 INSERT 範例,以追蹤帶斜線跳脫的單引號是如何被分詞的。完成標準是:此 MySQL 輸入能夠成功解析,而不會將跳脫的引號當作字串結尾。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
mysql, rust
領域
databases
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。