Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5707bb8
pickin up fast
juleswritescode Nov 7, 2025
8b96f00
so far
juleswritescode Nov 8, 2025
799f52d
changie
juleswritescode Nov 8, 2025
f8ca407
readied
juleswritescode Nov 8, 2025
6365f80
more removed
juleswritescode Nov 8, 2025
4324377
minor changes
juleswritescode Nov 8, 2025
9586d8c
Update crates/pgls_completions/src/relevance/filtering.rs
juleswritescode Nov 8, 2025
c3201e7
use indoc, add setup
juleswritescode Nov 9, 2025
cbbe1f2
Merge branch 'feat/completions-test-suite' of https://github.com/supa…
juleswritescode Nov 9, 2025
09664c1
ok
juleswritescode Nov 9, 2025
853929c
many fixings
juleswritescode Nov 22, 2025
ad45958
Merge branch 'main' of https://github.com/supabase-community/postgres…
juleswritescode Nov 22, 2025
0a9be8a
remove all commata?
juleswritescode Nov 22, 2025
6fabed2
use current version of bun
juleswritescode Nov 22, 2025
cdb4355
Merge branch 'feat/completions-test-suite' of https://github.com/supa…
juleswritescode Nov 22, 2025
c0e2d35
fixed aaaaaaaaaaaaaaat
juleswritescode Nov 22, 2025
324c4f5
commit
juleswritescode Nov 22, 2025
9c07d91
accept snaps
juleswritescode Nov 22, 2025
359a8ff
ok?
juleswritescode Nov 22, 2025
195c706
do not prefer public schema
juleswritescode Nov 22, 2025
9f8435f
more adjustments
juleswritescode Nov 22, 2025
61b02ff
snaps
juleswritescode Nov 22, 2025
0dc7f2b
ok
juleswritescode Nov 22, 2025
46c2596
slight improvement
juleswritescode Nov 22, 2025
faf3793
intermediary
juleswritescode Nov 29, 2025
f55386a
merged
juleswritescode Dec 12, 2025
4cf53b4
many changes
juleswritescode Dec 12, 2025
cf0c98d
this is gret
juleswritescode Dec 12, 2025
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
12 changes: 12 additions & 0 deletions crates/pgls_completions/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{
CompletionItemKind, CompletionText,
item::CompletionItem,
relevance::{filtering::CompletionFilter, scoring::CompletionScore},
sanitization,
};

use pgls_treesitter::TreesitterContext;
Expand All @@ -24,6 +25,12 @@ pub(crate) struct CompletionBuilder<'a> {

impl<'a> CompletionBuilder<'a> {
pub fn new(ctx: &'a TreesitterContext) -> Self {
println!(
"is sanitized: {:#?}",
ctx.get_node_under_cursor_content()
.map(|txt| sanitization::is_sanitized_token(txt.as_str()))
);

CompletionBuilder { items: vec![], ctx }
}

Expand All @@ -42,6 +49,11 @@ impl<'a> CompletionBuilder<'a> {
item.score.calc_score(self.ctx);
}

items = items
.into_iter()
.filter(|i| !i.score.should_skip())
.collect();

items.sort_by(|a, b| {
b.score
.get_score()
Expand Down
10 changes: 4 additions & 6 deletions crates/pgls_completions/src/providers/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ fn get_completion_text(ctx: &TreesitterContext, col: &Column) -> CompletionText

#[cfg(test)]
mod tests {
use pgls_test_utils::QueryWithCursorPosition;
use sqlx::PgPool;

use crate::test_helper::{TestCompletionsCase, TestCompletionsSuite};
use crate::test_helper::{TestCompletionsCase, TestCompletionsSuite, assert_complete_results};

#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")]
async fn handles_nested_queries(pool: PgPool) {
Expand All @@ -79,12 +80,12 @@ mod tests {
TestCompletionsCase::new()
.inside_static_statement(r#"
select * from (
<sql>
<sql> from private.audio_books
) as subquery
join public.users u
on u.id = subquery.id;
"#)
.type_sql("select id, narrator_id<1> from private.audio_books")
.type_sql("select id, narrator_id<1>")
.comment("Should prefer the one from private.audio_audiobooks, since the other tables are out of scope.")
)
.snapshot("handles_nested_queries")
Expand Down Expand Up @@ -459,9 +460,6 @@ mod tests {
"#;

TestCompletionsSuite::new(&pool, Some(setup))
.with_case(
TestCompletionsCase::new().type_sql("alter table instruments drop column name"),
)
.with_case(
TestCompletionsCase::new().type_sql("alter table instruments drop column name"),
)
Expand Down
6 changes: 6 additions & 0 deletions crates/pgls_completions/src/relevance/filtering.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use pgls_schema_cache::ProcKind;
use pgls_treesitter::context::{TreesitterContext, WrappingClause, WrappingNode};

use crate::is_sanitized_token;

use super::CompletionRelevanceData;

#[derive(Debug)]
Expand Down Expand Up @@ -43,6 +45,10 @@ impl CompletionFilter<'_> {
return None;
}

if ctx.before_cursor_matches_kind(&["ERROR"]) {
return None;
}

// "literal" nodes can be identfiers wrapped in quotes:
// `select "email" from auth.users;`
// Here, "email" is a literal node.
Expand Down
Loading
Loading