Skip to content

A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.

C++

fix(grid): re-introspect schema on Cmd+R and sidebar double-click (#63)

Tobia96e7dc5173a
diff --git a/macos/Presentation/Views/DataGrid/DataGridView.swift b/macos/Presentation/Views/DataGrid/DataGridView.swift
index d8b9708..3f9f1c8 100644
--- a/macos/Presentation/Views/DataGrid/DataGridView.swift
+++ b/macos/Presentation/Views/DataGrid/DataGridView.swift
@@ -183,7 +183,7 @@ private struct DataGridContentView: View {
Button("Cancel", role: .cancel) {}
Button("Discard", role: .destructive) {
viewModel.discardAllChanges()
- Task { await viewModel.loadPage(viewModel.currentPage) }
+ Task { await viewModel.reloadAfterStructureChange() }
}
} message: {
Text("Discard all changes?\nTips: You can commit the changes by\n1. Command + S.\n2. Use the top left segment control.")
@@ -203,12 +203,13 @@ private struct DataGridContentView: View {
.onReceive(NotificationCenter.default.publisher(for: .deleteSelectedRows)) { _ in
viewModel.deleteSelectedRows()
}
- // Cmd+R: reload (with warning if pending changes)
+ // Cmd+R: reload (with warning if pending changes). Re-introspects the
+ // schema so external column changes (ADD/DROP COLUMN) take effect.
.onReceive(NotificationCenter.default.publisher(for: .reloadData)) { _ in
if viewModel.hasPendingChanges {
showDiscardWarning = true
} else {
- Task { await viewModel.loadPage(viewModel.currentPage) }
+ Task { await viewModel.reloadAfterStructureChange() }
}
}
// Cmd+F: toggle filter bar
diff --git a/macos/Presentation/Views/Sidebar/SidebarView.swift b/macos/Presentation/Views/Sidebar/SidebarView.swift
index 0b09990..d6ee079 100644
--- a/macos/Presentation/Views/Sidebar/SidebarView.swift
+++ b/macos/Presentation/Views/Sidebar/SidebarView.swift
@@ -342,6 +342,17 @@ struct SidebarItemRow: View {
.tag(item.type)
.contentShape(Rectangle())
.pointerCursor()
+ // Double-click on a table/view forces a refresh of the active grid
+ // (re-introspects schema so external ADD/DROP COLUMN takes effect).
+ .onTapGesture(count: 2) {
+ switch item.type {
+ case .table(let name), .view(let name):
+ appState.openTable(name: name, schema: nil)
+ NotificationCenter.default.post(name: .reloadData, object: nil)
+ default:
+ break
+ }
+ }
.onTapGesture {
appState.selectedSidebarItem = item.type
// Open table/view on single click