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 摘要。