Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d79e889

Browse files
authoredMay 7, 2025
flatten insert_column_list ,index_params, and values_clause (#22)
* change(tree-sitter module): flatten insert_column_list and index_params * change(tree-sitter module): flatten values_clause
1 parent 92b440c commit d79e889

File tree

1 file changed

+31
-1
lines changed
  • crates/postgresql-cst-parser/src/tree_sitter

1 file changed

+31
-1
lines changed
 

‎crates/postgresql-cst-parser/src/tree_sitter/convert.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ fn walk_and_build(
151151
| SyntaxKind::cte_list
152152
| SyntaxKind::name_list
153153
| SyntaxKind::set_clause_list
154-
| SyntaxKind::set_target_list) => {
154+
| SyntaxKind::set_target_list
155+
| SyntaxKind::insert_column_list
156+
| SyntaxKind::index_params
157+
| SyntaxKind::values_clause) => {
155158
if parent_kind == child_kind {
156159
// [Node: Flatten]
157160
//
@@ -466,5 +469,32 @@ FROM
466469

467470
assert_no_direct_nested_kind(&new_root, SyntaxKind::set_target_list);
468471
}
472+
473+
#[test]
474+
fn no_nested_insert_column_list() {
475+
let input = "insert into t (a, b, c) values (1, 2, 3);";
476+
let root = cst::parse(input).unwrap();
477+
let (new_root, _) = get_ts_tree_and_range_map(&input, &root);
478+
479+
assert_no_direct_nested_kind(&new_root, SyntaxKind::insert_column_list);
480+
}
481+
482+
#[test]
483+
fn no_nested_index_params() {
484+
let input = "insert into t (a, b, c) values (1, 2, 3) on conflict (a, b) do nothing;";
485+
let root = cst::parse(input).unwrap();
486+
let (new_root, _) = get_ts_tree_and_range_map(&input, &root);
487+
488+
assert_no_direct_nested_kind(&new_root, SyntaxKind::index_params);
489+
}
490+
491+
#[test]
492+
fn no_nested_values_clause() {
493+
let input = "values (1,2,3), (4,5,6), (7,8,9);";
494+
let root = cst::parse(input).unwrap();
495+
let (new_root, _) = get_ts_tree_and_range_map(&input, &root);
496+
497+
assert_no_direct_nested_kind(&new_root, SyntaxKind::values_clause);
498+
}
469499
}
470500
}

0 commit comments

Comments
 (0)
Please sign in to comment.