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): refresh metadata before applying sort (#67)

Tobi2fc965b82904
diff --git a/macos/Presentation/Views/DataGrid/DataGridView.swift b/macos/Presentation/Views/DataGrid/DataGridView.swift
index d394387..15a2823 100644
--- a/macos/Presentation/Views/DataGrid/DataGridView.swift
+++ b/macos/Presentation/Views/DataGrid/DataGridView.swift
@@ -596,6 +596,19 @@ final class DataGridViewState: ObservableObject {
func reloadAfterStructureChange() async {
Self.metadataCache.removeValue(forKey: cacheKey)
guard let adapter else { return }
+
+ do {
+ let description = try await adapter.describeTable(name: tableName, schema: schema)
+ self.primaryKeyColumns = description.columns.filter { $0.isPrimaryKey }.map { $0.name }
+ self.tableDescription = description
+ if let sortColumn, !description.columns.contains(where: { $0.name == sortColumn }) {
+ self.sortColumn = nil
+ }
+ } catch {
+ errorMessage = Self.detailedErrorMessage(error)
+ return
+ }
+
await load(tableName: tableName, schema: schema, adapter: adapter)
}