Skip to content

Commit e1490cd

Browse files
authored
(tree-sitter module) flatten cte_list, name_list (#20)
* change(tree-sitter module): flatten cte_list * change(tree-sitter module): flatten name_list
1 parent b436543 commit e1490cd

File tree

1 file changed

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

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ fn walk_and_build(
147147
| SyntaxKind::group_by_list
148148
| SyntaxKind::sortby_list
149149
| SyntaxKind::qualified_name_list
150-
| SyntaxKind::for_locking_items) => {
150+
| SyntaxKind::for_locking_items
151+
| SyntaxKind::cte_list
152+
| SyntaxKind::name_list) => {
151153
if parent_kind == child_kind {
152154
// [Node: Flatten]
153155
//
@@ -426,5 +428,23 @@ FROM
426428

427429
assert_no_direct_nested_kind(&new_root, SyntaxKind::qualified_name_list);
428430
}
431+
432+
#[test]
433+
fn no_nested_cte_list() {
434+
let input = "with a as (select 1), b as (select 2) select * from a, b;";
435+
let root = cst::parse(input).unwrap();
436+
let (new_root, _) = get_ts_tree_and_range_map(&input, &root);
437+
438+
assert_no_direct_nested_kind(&new_root, SyntaxKind::cte_list);
439+
}
440+
441+
#[test]
442+
fn no_nested_name_list() {
443+
let input = "with t (a, b) as (select 1) select * from t;";
444+
let root = cst::parse(input).unwrap();
445+
let (new_root, _) = get_ts_tree_and_range_map(&input, &root);
446+
447+
assert_no_direct_nested_kind(&new_root, SyntaxKind::name_list);
448+
}
429449
}
430450
}

0 commit comments

Comments
 (0)