Skip to content

Commit 620a81c

Browse files
committed
Fix broken test by updating INSERT syntax to standard SQL VALUES clause
1 parent 48cc47b commit 620a81c

2 files changed

Lines changed: 3 additions & 20 deletions

File tree

specs/query-language.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The `INSERT` statement is used to add new documents to a collection.
1616

1717
```sql
1818
INSERT INTO <collection_name>
19-
VALUES `json_object` [, `json_object` ...]
19+
VALUES (`json_object`) [, (`json_object`) ...]
2020
```
2121

2222
**Parameters:**
@@ -28,7 +28,7 @@ VALUES `json_object` [, `json_object` ...]
2828

2929
```sql
3030
INSERT INTO people
31-
VALUES `{"name": "Alice", "age": 30, "address": {"city": "Paris", "zip": "75001"}}`
31+
VALUES (`{"name": "Alice", "age": 30, "address": {"city": "Paris", "zip": "75001"}}`)
3232
```
3333

3434
### SELECT

src/parser.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -263,27 +263,10 @@ fn convert_expr(expr: &Expr) -> Result<Expression, String> {
263263
#[cfg(test)]
264264
mod tests {
265265
use super::*;
266-
use sqlparser::dialect::GenericDialect;
267-
268-
#[test]
269-
fn debug_ast() {
270-
let dialect = GenericDialect {};
271-
let sql = "INSERT INTO t VALUES (1)";
272-
if let Ok(ast) = Parser::parse_sql(&dialect, sql) {
273-
println!("INSERT AST: {:?}", ast);
274-
} else {
275-
println!("Parse failed");
276-
}
277-
278-
let sql = "SELECT * FROM t LIMIT 1 OFFSET 2";
279-
if let Ok(ast) = Parser::parse_sql(&dialect, sql) {
280-
println!("SELECT AST: {:?}", ast);
281-
}
282-
}
283266

284267
#[test]
285268
fn test_parse_insert() {
286-
let sql = r#"INSERT INTO users VALUES `{"name": "Alice", "age": 30}`, `{"name": "Bob"}`"#;
269+
let sql = r#"INSERT INTO users VALUES (`{"name": "Alice", "age": 30}`), (`{"name": "Bob"}`)"#;
287270
let stmt = parse(sql).unwrap();
288271
match stmt {
289272
Statement::Insert {

0 commit comments

Comments
 (0)