apache / apache/datafusion-sqlparser-rs
MySql dialect doesn't handle slash-escaped single quotes
- Lingua principale
- Rust
- Stelle
- 3.5k
- Fork
- 772
- Merge medio
- 4g 9h
- PR unite (30g)
- 17
Descrizione
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?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia con il tokenizer e il percorso MySqlDialect utilizzato da Parser::parse_sql, quindi riproduci l'esempio INSERT fornito per tracciare come vengono tokenizzati gli apici singoli con escape tramite barra. Il lavoro è completo quando questo input MySQL viene analizzato correttamente senza trattare gli apici con escape come la fine della stringa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- mysql, rust
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100