apache / apache/datafusion-sqlparser-rs

MySQL Compatibility Issues

Aperta
#295 0 commenti 6 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
3.5k
Fork
772
Merge medio
4g 9h
PR unite (30g)
17

Descrizione

Hi - first want to say what an amazing and fun to work with lib this is!

Looking to use this for a MySQL project, but some of the queries I'm working with aren't supported yet.

It seems for now you are accepting dialect-specific extensions in the mainline parser, so am happy to work on this. I have a fork which fixes each of the following issues. Should I open separate issues/PRs, or is it more helpful if I raise a PR for all them? (Several are just `bool`s on `Statement::{ }` variants)

##### `INSERT [IGNORE] ...` ([mysqltutorial](https://www.mysqltutorial.org/mysql-insert-ignore/))
__Summary:__ An optional `IGNORE` keyword after `INSERT`
__Query:__ `INSERT IGNORE INTO user (id) VALUES (1)`
__Result:__ `ParserError("Expected one of INTO or OVERWRITE, found: IGNORE")`

---

##### `INSERT [INTO] tbl_name ...` ([docs](https://dev.mysql.com/doc/refman/5.6/en/insert.html))
__Summary:__ The `INTO` keywords is optional
__Query:__ `INSERT user (id) VALUES (1)`
__Result:__ `ParserError("Expected one of INTO or OVERWRITE, found: users")`

---

##### `INSERT ... SET ` ([docs](https://dev.mysql.com/doc/refman/5.6/en/insert.html), [SO](https://stackoverflow.com/questions/861722/mysql-insert-into-table-values-vs-insert-into-table-set))
__Summary:__ Inserts can set fields with an alternate syntax, similar to an `UPDATE` query
__Query:__ `INSERT INTO user SET id = 1`
__Result:__ `ParserError("Expected SELECT, VALUES, or a subquery in the query body, found: SET")`

---

##### `INSERT ... [ON DUPLICATE KEY UPDATE ]` ([mysqltutorial](https://www.mysqltutorial.org/mysql-insert-or-update-on-duplicate-key-update/))
__Summary:__ Inserts can fallback to updates on a key collision
__Query:__ `INSERT INTO user (id, name) VALUES (1, 'Printer') ON DUPLICATE KEY UPDATE name = 'Central Printer'`
__Result:__ `ParserError("Expected end of statement, found: ON")`

---

##### `UPDATE ... [ORDER BY ...] [LIMIT row_count]` ([docs](https://dev.mysql.com/doc/refman/8.0/en/update.html))
__Summary:__ Updates can optionally include `ORDER BY` and `LIMIT` clauses
__Query:__ `UPDATE user SET id = 1 ORDER BY id LIMIT 1`
__Result:__ `ParserError("Expected end of statement, found: ORDER")`

---

##### `DELETE ... [ORDER BY ...] [LIMIT row_count]` ([docs](https://dev.mysql.com/doc/refman/5.6/en/delete.html))
__Summary:__ Deletes can optionally include `ORDER BY` and `LIMIT` clauses
__Query:__ `DELETE FROM user ORDER BY id LIMIT 1`
__Result:__ `ParserError("Expected end of statement, found: ORDER")`

---

##### `BINARY ` ([docs](https://dev.mysql.com/doc/refman/5.6/en/cast-functions.html#operator_binary))
__Summary:__ The `BINARY` operator/unary function can operate without parameters (similar to `INTERVAL 1 DAYS`)
__Query:__ `SELECT * FROM user WHERE name = BINARY 'name'`
__Result:__ `ParserError("Expected end of statement, found: \'name\'")`

---

Many thanks!

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia con il parser mainline e le varianti di Statement menzionate nell’issue, quindi riproduci ciascuna delle sette query MySQL per identificare gli errori di parsing attuali. Il lavoro è completato quando tutte le forme INSERT, UPDATE, DELETE e BINARY elencate vengono accettate senza errori del parser e viene aggiunta la coverage per ogni variante sintattica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
mysql, rust, sql
Ambito
databases
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.