@@ -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