Skip to content

Commit ee45ea6

Browse files
authoredMar 30, 2025
feat: execute stmt under cursor (supabase-community#257)
1 parent 384f3fc commit ee45ea6

33 files changed

+726
-186
lines changed
 

‎.cargo/config.toml

-3
This file was deleted.

‎.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"postgrestools.bin": "./target/debug/postgrestools"
3+
}

‎Cargo.lock

+33-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ serde = "1.0.195"
3939
serde_json = "1.0.114"
4040
similar = "2.6.0"
4141
smallvec = { version = "1.13.2", features = ["union", "const_new", "serde"] }
42+
strum = { version = "0.27.1", features = ["derive"] }
4243
# this will use tokio if available, otherwise async-std
4344
sqlx = { version = "0.8.2", features = ["runtime-tokio", "runtime-async-std", "postgres", "json"] }
4445
syn = "1.0.109"
@@ -56,7 +57,6 @@ pgt_analyse = { path = "./crates/pgt_analyse", version = "0.0.0"
5657
pgt_analyser = { path = "./crates/pgt_analyser", version = "0.0.0" }
5758
pgt_base_db = { path = "./crates/pgt_base_db", version = "0.0.0" }
5859
pgt_cli = { path = "./crates/pgt_cli", version = "0.0.0" }
59-
pgt_commands = { path = "./crates/pgt_commands", version = "0.0.0" }
6060
pgt_completions = { path = "./crates/pgt_completions", version = "0.0.0" }
6161
pgt_configuration = { path = "./crates/pgt_configuration", version = "0.0.0" }
6262
pgt_console = { path = "./crates/pgt_console", version = "0.0.0" }

‎crates/pgt_commands/Cargo.toml

-21
This file was deleted.

‎crates/pgt_commands/src/command.rs

-32
This file was deleted.

‎crates/pgt_commands/src/execute_statement.rs

-44
This file was deleted.

‎crates/pgt_commands/src/lib.rs

-5
This file was deleted.

‎crates/pgt_configuration/src/database.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use biome_deserialize::StringSet;
12
use biome_deserialize_macros::{Merge, Partial};
23
use bpaf::Bpaf;
34
use serde::{Deserialize, Serialize};
@@ -28,6 +29,9 @@ pub struct DatabaseConfiguration {
2829
#[partial(bpaf(long("database")))]
2930
pub database: String,
3031

32+
#[partial(bpaf(long("allow_statement_executions_against")))]
33+
pub allow_statement_executions_against: StringSet,
34+
3135
/// The connection timeout in seconds.
3236
#[partial(bpaf(long("conn_timeout_secs"), fallback(Some(10)), debug_fallback))]
3337
pub conn_timeout_secs: u16,
@@ -41,6 +45,7 @@ impl Default for DatabaseConfiguration {
4145
username: "postgres".to_string(),
4246
password: "postgres".to_string(),
4347
database: "postgres".to_string(),
48+
allow_statement_executions_against: Default::default(),
4449
conn_timeout_secs: 10,
4550
}
4651
}

‎crates/pgt_configuration/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl PartialConfiguration {
111111
password: Some("postgres".to_string()),
112112
database: Some("postgres".to_string()),
113113
conn_timeout_secs: Some(10),
114+
allow_statement_executions_against: Default::default(),
114115
}),
115116
}
116117
}

‎crates/pgt_lsp/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pgt_workspace = { workspace = true }
2828
rustc-hash = { workspace = true }
2929
serde = { workspace = true, features = ["derive"] }
3030
serde_json = { workspace = true }
31+
strum = { workspace = true }
3132
tokio = { workspace = true, features = ["rt", "io-std"] }
3233
tower-lsp = { version = "0.20.0" }
3334
tracing = { workspace = true, features = ["attributes"] }

‎crates/pgt_lsp/src/capabilities.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
use pgt_lsp_converters::{PositionEncoding, WideEncoding, negotiated_encoding};
2+
use pgt_workspace::code_actions::{CommandActionCategory, CommandActionCategoryIter};
3+
use strum::{EnumIter, IntoEnumIterator};
24
use tower_lsp::lsp_types::{
3-
ClientCapabilities, CompletionOptions, PositionEncodingKind, SaveOptions, ServerCapabilities,
4-
TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions,
5-
TextDocumentSyncSaveOptions, WorkDoneProgressOptions,
5+
ClientCapabilities, CodeActionOptions, CompletionOptions, ExecuteCommandOptions,
6+
PositionEncodingKind, SaveOptions, ServerCapabilities, TextDocumentSyncCapability,
7+
TextDocumentSyncKind, TextDocumentSyncOptions, TextDocumentSyncSaveOptions,
8+
WorkDoneProgressOptions,
69
};
710

11+
use crate::handlers::code_actions::command_id;
12+
813
/// The capabilities to send from server as part of [`InitializeResult`]
914
///
1015
/// [`InitializeResult`]: lspower::lsp::InitializeResult
@@ -46,10 +51,19 @@ pub(crate) fn server_capabilities(capabilities: &ClientCapabilities) -> ServerCa
4651
work_done_progress: None,
4752
},
4853
}),
54+
execute_command_provider: Some(ExecuteCommandOptions {
55+
commands: CommandActionCategory::iter()
56+
.map(|c| command_id(&c))
57+
.collect::<Vec<String>>(),
58+
59+
..Default::default()
60+
}),
4961
document_formatting_provider: None,
5062
document_range_formatting_provider: None,
5163
document_on_type_formatting_provider: None,
52-
code_action_provider: None,
64+
code_action_provider: Some(tower_lsp::lsp_types::CodeActionProviderCapability::Simple(
65+
true,
66+
)),
5367
rename_provider: None,
5468
..Default::default()
5569
}

‎crates/pgt_lsp/src/handlers.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
pub(crate) mod code_actions;
12
pub(crate) mod completions;
3+
mod helper;
24
pub(crate) mod text_document;

0 commit comments

Comments
 (0)