Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions crates/squawk_ide/src/classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,13 @@ pub(crate) fn classify_name_ref(node: &SyntaxNode) -> Option<NameRefClass> {
// (anything in SELECT except FROM clause)
return Some(NameRefClass::SelectColumn);
}
if ast::CompoundSelect::can_cast(ancestor.kind())
&& in_order_by_clause
&& let Some(parent) = node.parent()
&& ast::SortBy::can_cast(parent.kind())
{
return Some(NameRefClass::SelectOrderByAliasOrColumn);
}
if ast::ColumnList::can_cast(ancestor.kind()) {
in_column_list = true;
}
Expand Down
84 changes: 84 additions & 0 deletions crates/squawk_ide/src/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,49 @@ select a$0 from t;
");
}

#[test]
fn goto_view_select_star_column_gap() {
assert_snapshot!(goto("
create table t(a int, b int);
create view v as select * from t;
select a$0 from v;
"), @"
╭▸
2 │ create table t(a int, b int);
│ ─ 2. destination
3 │ create view v as select * from t;
4 │ select a from v;
╰╴ ─ 1. source
");
}

#[test]
fn goto_view_table_query_column_gap() {
assert_snapshot!(goto("
create table t(a int);
create view v as table t;
select a$0 from v;
"), @"
╭▸
2 │ create table t(a int);
│ ─ 2. destination
3 │ create view v as table t;
4 │ select a from v;
╰╴ ─ 1. source
");
}

#[test]
fn goto_values_partial_alias_remaining_column_gap() {
assert_snapshot!(goto("
select column2$0 from (values (1, 2)) v(a);
"), @"
╭▸
2 │ select column2 from (values (1, 2)) v(a);
╰╴ ─ 1. source ─ 2. destination
");
}

#[test]
fn goto_create_table_inherits() {
assert_snapshot!(goto("
Expand Down Expand Up @@ -5504,6 +5547,25 @@ select a$0 from inserted;
");
}

#[test]
fn goto_cte_returning_qualified_star_column_gap() {
assert_snapshot!(goto("
create table t(a int, b int);
with changed as (
insert into t values (1, 2)
returning new.*
)
select a$0 from changed;
"), @"
╭▸
2 │ create table t(a int, b int);
│ ─ 2. destination
7 │ select a from changed;
╰╴ ─ 1. source
");
}

#[test]
fn goto_cte_delete_returning_star_column() {
assert_snapshot!(goto("
Expand Down Expand Up @@ -5592,6 +5654,16 @@ select a$0 from (select 1 a);
");
}

#[test]
fn goto_subquery_star_partial_alias_masks_original_column_gap() {
goto_not_found(
"
create table t(a int, b int);
select a$0 from (select * from t) u(x);
",
);
}

#[test]
fn goto_subquery_column_with_as() {
assert_snapshot!(goto("
Expand All @@ -5614,6 +5686,18 @@ select c$0 from (select 1 c union select 2 c);
");
}

#[test]
fn goto_subquery_compound_select_column_order_by() {
assert_snapshot!(goto("
with t as (select 1 a)
select 2 a from t union select 1 order by a$0;
"), @"
╭▸
3 │ select 2 a from t union select 1 order by a;
╰╴ ─ 2. destination ─ 1. source
");
}

#[test]
fn goto_subquery_compound_select_column_with_nested_parens() {
assert_snapshot!(goto("
Expand Down
Loading
Loading