apache / apache/datafusion-sqlparser-rs
The field name in SQL cannot be the same as the keyword name
- 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ả
test SQL:
```text
UPDATE tag_group SET name=?, updated_time=?, app=?, app_name=?, is_preset=?, is_default=?, classification=?, sort=?, can_edit=?, can_delete=?, can_add_child=?, can_add_partner=?, can_add_tag=? WHERE id=?
```
```text
update attacker set update_time=$1, attacker_country_name=$2, attacker_desc=$3, attacker_ioc_id=$4, attacker_label=$5, attacker_name=$6, attacker_skill_level=$7, attacker_type=$8, event_diamond_id=$9, incident_id=$10, value=$11 where attacker_id=$12
```
result:
```text
called `Result::unwrap()` on an `Err` value: ParserError("Expected =, found: value")
thread 'interceptor::pg::tests::test_sql' panicked at 'called `Result::unwrap()` on an `Err` value: ParserError("Expected =, found: value")', src/interceptor/pg.rs:719:42
stack backtrace:
```
I think the reason for this mistake is that:
```rust
pub fn parse_assignment(&mut self) -> Result {
let id = self.parse_identifiers_non_keywords()?;
println!("id : {:?}", id);
self.expect_token(&Token::Eq)?;
let value = self.parse_expr()?;
println!("value : {:?}", value.to_string());
Ok(Assignment { id, value })
}
```
```text
word: NoKeyword
id : [Ident { value: "update_time", quote_style: None }]
value : "$1"
word: NoKeyword
id : [Ident { value: "attacker_country_name", quote_style: None }]
value : "$2"
word: NoKeyword
id : [Ident { value: "attacker_desc", quote_style: None }]
value : "$3"
word: NoKeyword
id : [Ident { value: "attacker_ioc_id", quote_style: None }]
value : "$4"
word: NoKeyword
id : [Ident { value: "attacker_label", quote_style: None }]
value : "$5"
word: NoKeyword
id : [Ident { value: "attacker_name", quote_style: None }]
value : "$6"
word: NoKeyword
id : [Ident { value: "attacker_skill_level", quote_style: None }]
value : "$7"
word: NoKeyword
id : [Ident { value: "attacker_type", quote_style: None }]
value : "$8"
word: NoKeyword
id : [Ident { value: "event_diamond_id", quote_style: None }]
value : "$9"
word: NoKeyword
id : [Ident { value: "incident_id", quote_style: None }]
value : "$10"
word: VALUE
id : []
```
expected:
The parameter type after set should be Nokeywork
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 parse_assignment trong src/interceptor/pg.rs và chạy trường hợp interceptor::pg::tests::test_sql được nêu trong báo cáo. Tái hiện các câu lệnh UPDATE, đặc biệt là phép gán sử dụng value, và theo dõi cách parser phân loại từ đó sau SET. Được xem là hoàn tất khi các ví dụ này được phân tích mà không gặp ParserError đã nêu và hành vi trường giống từ khóa như mong đợi được bao quát.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- rust, sql
- Lĩnh vực
- databases
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 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