Skip to content

Commit aa20df8

Browse files
authored
feat(windows): production cue, database switchers, find and replace, sql files, redis key tab, cassandra paging and display settings (#4285)
1 parent 86fd78c commit aa20df8

96 files changed

Lines changed: 8887 additions & 367 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎core/crates/ffi/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ windows-sys.workspace = true
5757

5858
[dev-dependencies]
5959
tablepro-account = { workspace = true, features = ["fakes"] }
60+
tablepro-session = { workspace = true, features = ["fakes", "in-process-ssh"] }
61+
tablepro-test-support.workspace = true
6062
csbindgen.workspace = true
6163
russh.workspace = true
6264
tempfile.workspace = true

‎core/crates/ffi/src/core_handle.rs‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use tablepro_account::{AccountSettings, RefreshTokenVault};
88
use tablepro_core::credentials::{CredentialInteraction, CredentialPrompter, SecretItems, SecretKind, SecretVault};
99
use tablepro_core::{
1010
ConnectEnvironment, Credentials, DatabaseDriver, DriverError, DriverRegistry, FileEndpoint, LivenessPolicy,
11-
SafeModeLevel, WorkspaceSettings,
11+
SafeModeLevel, UnsupportedFeature, WorkspaceSettings,
1212
};
1313
use tablepro_session::runtime::Tasks;
1414
use tablepro_session::{
@@ -177,9 +177,11 @@ impl Core {
177177
}
178178

179179
// Typed secrets come first, then Credential Manager; `keep` is stored once it logs in; no prompter, no SSH asks.
180+
// `database`, in place of the saved one, opens the connection in another of the server's databases.
180181
pub async fn connect_saved(
181182
&self,
182183
id: String,
184+
database: Option<String>,
183185
secrets: ConnectionSecrets,
184186
keep: ConnectionSecrets,
185187
prompter: Option<Box<dyn HostPrompter>>,
@@ -215,8 +217,17 @@ impl Core {
215217
CredentialDemand::default(),
216218
)
217219
.await?;
220+
let request = match database.as_deref().filter(|name| !name.is_empty()) {
221+
Some(database) => refreshed
222+
.request
223+
.in_database(database)
224+
.ok_or(DriverError::Unsupported {
225+
feature: UnsupportedFeature::NetworkConnection,
226+
})?,
227+
None => refreshed.request,
228+
};
218229
let pending = connector
219-
.establish(refreshed.request, interaction(prompter.as_ref()), cancel.clone())
230+
.establish(request, interaction(prompter.as_ref()), cancel.clone())
220231
.await?;
221232
if cancel.is_cancelled() {
222233
let report = pending.discard().await;
@@ -657,7 +668,14 @@ mod tests {
657668
};
658669

659670
let connect = core
660-
.connect_saved(stored.id.to_string(), typed(), ConnectionSecrets::default(), None, None)
671+
.connect_saved(
672+
stored.id.to_string(),
673+
None,
674+
typed(),
675+
ConnectionSecrets::default(),
676+
None,
677+
None,
678+
)
661679
.await
662680
.unwrap_err();
663681
let test = core

‎core/crates/ffi/src/editor.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ impl QueryEditor {
7171
self.editor.state() == EditorSessionState::Lost
7272
}
7373

74-
// Where a definition names no database of its own, its text has to run in the one it was read from.
74+
// The database an unqualified name resolves to now, as the server last said, a typed USE included. None where
75+
// the engine does not follow it.
76+
pub fn database(&self) -> Option<String> {
77+
self.editor.database().filter(|name| !name.is_empty())
78+
}
79+
80+
// Moves the editor's connection, keeping its transaction. An engine that binds the database at connect refuses.
7581
pub async fn use_database(&self, database: String, cancel: Option<Arc<CancelToken>>) -> Result<(), CoreError> {
7682
let editor = self.editor.clone();
7783
let cancel = token(cancel);

‎core/crates/ffi/src/history.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@ impl QueryHistoryStore {
136136
.await
137137
}
138138

139+
// Drops unpinned entries older than `retention_days` (0 keeps every age), then the oldest past `max_entries`
140+
// (0 keeps the store's own cap). Returns how many went.
141+
pub async fn prune(&self, retention_days: u32, max_entries: u32) -> Result<u64, CoreError> {
142+
let history = self.history.clone();
143+
on_runtime(&self.tasks, async move {
144+
let report = match max_entries {
145+
0 => history.prune(retention_days).await?,
146+
kept => history.prune_keeping(retention_days, kept).await?,
147+
};
148+
Ok(report.total())
149+
})
150+
.await
151+
}
152+
139153
pub async fn clear(&self) -> Result<(), CoreError> {
140154
let history = self.history.clone();
141155
on_runtime(&self.tasks, async move {

0 commit comments

Comments
 (0)