apache / apache/datafusion-sqlparser-rs

MySQL Compatibility Issues

Đang mở
#295 0 bình luận 6 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
3.5k
Fork
772
Merge trung bình
4 ngày 9 giờ
Pull request đã merge (30 ngày)
17

Mô tả

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!

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu với parser mainline và các biến thể Statement được đề cập trong issue, sau đó tái hiện từng truy vấn MySQL trong số bảy truy vấn để xác định các lỗi parse hiện tại của chúng. Hoàn thành khi tất cả các dạng INSERT, UPDATE, DELETE và BINARY được liệt kê đều được chấp nhận mà không có lỗi parser, đồng thời đã bổ sung coverage cho từng biến thể cú pháp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
mysql, rust, sql
Lĩnh vực
databases
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.