Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion crates/postgresql-cst-parser/src/tree_sitter/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ fn walk_and_build(
| SyntaxKind::select_no_parens
| SyntaxKind::simple_select
| SyntaxKind::select_clause
| SyntaxKind::opt_target_list => {
| SyntaxKind::opt_select_limit
| SyntaxKind::opt_target_list
| SyntaxKind::opt_sort_clause => {
// [Node: Removal]
//
// Ignore current node, and continue building its children.
Expand Down Expand Up @@ -279,6 +281,26 @@ FROM
let (new_root, _) = get_ts_tree_and_range_map(input, &root);
assert_not_exists(&new_root, SyntaxKind::opt_target_list);
}

#[test]
fn no_opt_select_limit() {
let input = "select a from t for update limit 5 offset 5;";
let root = cst::parse(input).unwrap();
assert_exists(&root, SyntaxKind::opt_select_limit);

let (new_root, _) = get_ts_tree_and_range_map(input, &root);
assert_not_exists(&new_root, SyntaxKind::opt_select_limit);
}

#[test]
fn no_opt_sort_clause() {
let input = "select a from t order by a desc limit 5;";
let root = cst::parse(input).unwrap();
assert_exists(&root, SyntaxKind::opt_sort_clause);

let (new_root, _) = get_ts_tree_and_range_map(input, &root);
assert_not_exists(&new_root, SyntaxKind::opt_sort_clause);
}
}

mod flatten {
Expand Down