Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5f6332f
fix(macos): keep T-SQL blocks and rewinds whole, stop CSV sanitizing …
datlechin Nov 11, 2026
f6dfc0f
Merge remote-tracking branch 'origin/main' into fix/audit-wave-4-macos
datlechin Nov 11, 2026
5b9d13a
docs(macos): add the changelog fragments for #4185
datlechin Nov 11, 2026
4bd9bc7
build(pluginkit): raise the kit to 44 for the additive API
datlechin Nov 11, 2026
8a8ba11
feat(macos): add manual commit, table auto refresh, query tab history…
datlechin Nov 11, 2026
e6b1131
Merge remote-tracking branch 'origin/main' into feat/audit-wave-5-fea…
datlechin Nov 11, 2026
61987e4
fix(macos): keep manual commit to engines whose DDL waits for commit
datlechin Nov 11, 2026
f614b99
fix(macos): hold MCP row inserts and keep manual commit off Redshift …
datlechin Nov 11, 2026
1ebbc62
fix(macos): leave auto refresh to the menu in the narrow status bar a…
datlechin Nov 11, 2026
905d462
Merge remote-tracking branch 'origin/main' into feat/audit-wave-5-fea…
datlechin Nov 11, 2026
658a16c
refactor(macos): read the commit mode inside the parameterized multi-…
datlechin Nov 11, 2026
1a07475
chore(macos): add the new strings to the catalog
datlechin Nov 11, 2026
dd45c00
fix(macos): take back a whole insert_rows call that fails inside an o…
datlechin Nov 11, 2026
502c797
chore(macos): drop the catalog additions before extracting them again
datlechin Nov 11, 2026
1fcd698
chore(macos): add the new strings to the catalog
datlechin Nov 11, 2026
1b722cd
docs(macos): add the changelog fragments for #4214
datlechin Nov 11, 2026
98e12f4
test(macos): turn Auto Refresh on from the Database menu in its UI flow
datlechin Nov 11, 2026
2c1e012
Merge remote-tracking branch 'origin/main' into feat/audit-wave-5-fea…
datlechin Nov 12, 2026
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
1 change: 1 addition & 0 deletions .claude/rules/data-sync-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ This path holds user data. A silent wrong answer here looks exactly like an empt
| Light and dark theme ids (iCloud-synced, category `appearance`) | UserDefaults | `AppearanceSettings` through `AppSettingsManager` |
| User themes (iCloud-synced, one `AppSettings` record `theme.<id>` each) | JSON, one file per theme | `ThemeCatalog` (sync rules: `.claude/rules/theme.md`, Sync) |
| Query history | SQLite FTS5 | `QueryHistoryStorage` |
| Query tab edit history: up to 50 versions per tab, kept 30 days or the shorter Query History window, after the tab closes too; purged with the connection and by Clear History | SQLite `query_tab_versions.db`, device-local, never synced | `QueryTabVersionStorage` |
| Tab state | JSON | `TabPersistenceCoordinator`, `TabDiskActor` |
| Filter defaults and presets | UserDefaults | `FilterSettingsStorage`, `FilterPresetStorage` |
| Per-table filters | JSON, one file per table | `FilterSettingsStorage` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public enum ConnectionFieldCatalog {
"bqMaxBytesBilled": .setting,
"cassandraConsistency": .setting,
"cassandraSerialConsistency": .setting,
"commitMode": .setting,
"completionIdentifierCase": .setting,
"connectionOptions": .setting,
"connectTimeoutSeconds": .setting,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,23 @@ public enum MySQLObjectQueries {
"""
}

// The sidebar's read, apart from export's `eventList`, which keeps the four columns every server answers.
// A name narrows it to the one event a source tab reads again.
public static func eventDetails(schema: String, name: String? = nil, exactSchema: Bool) -> String {
let namePredicate = name.map { "\n AND EVENT_NAME = '\(escapeLiteral($0))'" } ?? ""
return """
SELECT EVENT_NAME, EVENT_TYPE, STATUS, EVENT_SCHEMA,
EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STARTS, ENDS,
ON_COMPLETION, LAST_EXECUTED, DEFINER, EVENT_COMMENT
FROM information_schema.EVENTS
WHERE \(schemaMatch("EVENT_SCHEMA", schema, exact: exactSchema))\(namePredicate)
ORDER BY EVENT_NAME
"""
}

// Its own statement, so a server without the variable loses that one attribute rather than the list.
public static let eventScheduler = "SELECT @@global.event_scheduler"

/// Qualified with the schema. Unqualified, the server resolves the name against the session
/// database instead of the one being browsed, and returns a different routine's body or none.
public static func routineDefinition(kind: String, schema: String?, name: String) -> String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ nonisolated public struct PostgreSQLCapabilities: Sendable, Equatable {
/// Every range gained a companion multirange in 14, with a name the creator may choose.
public var hasMultirangeTypes: Bool { serverVersion >= 140_000 }
public var hasForeignTablesCatalog: Bool { serverVersion >= 90_100 }
// `pg_extension` and CREATE EXTENSION landed in 9.1.
public var hasExtensionsCatalog: Bool { serverVersion >= 90_100 }
public var hasSequencesCatalog: Bool { serverVersion >= 100_000 }
public var hasBypassRLS: Bool { serverVersion >= 90_500 }
public var hasProcedureKind: Bool { serverVersion >= 110_000 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ public struct SQLCatalogObjectKinds: OptionSet, Sendable, Hashable {
public static let types = SQLCatalogObjectKinds(rawValue: 1 << 3)
public static let schemas = SQLCatalogObjectKinds(rawValue: 1 << 4)
public static let databases = SQLCatalogObjectKinds(rawValue: 1 << 5)
// The kinds a driver declares for the sidebar, such as MySQL events and PostgreSQL extensions.
public static let serverObjects = SQLCatalogObjectKinds(rawValue: 1 << 6)

public static let objects: SQLCatalogObjectKinds = [.tables, .routines, .triggers, .types]
public static let objects: SQLCatalogObjectKinds = [.tables, .routines, .triggers, .types, .serverObjects]
public static let everything: SQLCatalogObjectKinds = [.objects, .schemas, .databases]
}

Expand Down Expand Up @@ -200,7 +202,7 @@ public enum SQLCatalogEffectClassifier {
"SYNONYM": .tables, "FIELD": .tables,
"FUNCTION": .routines, "PROCEDURE": .routines, "PROC": .routines, "ROUTINE": .routines,
"AGGREGATE": .routines, "MACRO": .routines, "PACKAGE": .routines, "OPERATOR": .routines,
"TRIGGER": .triggers, "EVENT": .triggers,
"TRIGGER": .triggers, "EVENT": [.triggers, .serverObjects],
"TYPE": .types, "DOMAIN": .types, "ENUM": .types,
"SCHEMA": [.schemas, .objects], "NAMESPACE": [.schemas, .objects], "OWNED": [.schemas, .objects],
"DATABASE": .everything, "KEYSPACE": .everything, "CATALOG": .everything,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,48 @@ struct MySQLObjectQueryTests {
#expect(sql.hasSuffix("ORDER BY EVENT_NAME"))
}

private func selectedColumns(_ sql: String) throws -> [String] {
let select = try #require(sql.components(separatedBy: "FROM").first)
return select
.replacingOccurrences(of: "SELECT", with: "")
.split(separator: ",")
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
}

// Export reads these four by position on every flavor, including ones the sidebar leaves out.
@Test("Export's event list keeps the four columns it shipped with")
func eventListKeepsItsShippedProjection() throws {
let sql = MySQLObjectQueries.eventList(schema: "app", exactSchema: false)
#expect(try selectedColumns(sql) == ["EVENT_NAME", "EVENT_TYPE", "STATUS", "EVENT_SCHEMA"])
#expect(!sql.contains("@@"))
}

@Test("The sidebar's event read starts with export's columns and appends the schedule columns in order")
func eventDetailsAppendsScheduleColumns() throws {
let sql = MySQLObjectQueries.eventDetails(schema: "app", exactSchema: true)
#expect(try selectedColumns(sql) == [
"EVENT_NAME", "EVENT_TYPE", "STATUS", "EVENT_SCHEMA",
"EXECUTE_AT", "INTERVAL_VALUE", "INTERVAL_FIELD", "STARTS", "ENDS",
"ON_COMPLETION", "LAST_EXECUTED", "DEFINER", "EVENT_COMMENT",
])
#expect(sql.contains("EVENT_SCHEMA = 'app' AND CAST(EVENT_SCHEMA AS BINARY) = CAST('app' AS BINARY)"))
#expect(!sql.contains("EVENT_NAME ="))
#expect(!sql.contains("@@"))
#expect(sql.hasSuffix("ORDER BY EVENT_NAME"))
}

@Test("A re-read of one event names it as an escaped literal")
func eventDetailsForOneEvent() {
let sql = MySQLObjectQueries.eventDetails(schema: "app", name: "it's", exactSchema: false)
#expect(sql.contains("AND EVENT_NAME = 'it''s'"))
#expect(sql.contains("EVENT_SCHEMA = 'app'"))
}

@Test("The event scheduler is read in a statement of its own")
func eventSchedulerIsItsOwnStatement() {
#expect(MySQLObjectQueries.eventScheduler == "SELECT @@global.event_scheduler")
}

@Test("A routine's recorded mode is read by schema, name and type, with the name selected for an exact match")
func routineCreationSettings() {
let sql = MySQLObjectQueries.routineCreationSettings(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import Foundation
import TableProPluginKit
import Testing

private final class StubServerObjectDriver: PluginDatabaseDriver, @unchecked Sendable {
var supportsSchemas: Bool { false }
var supportsTransactions: Bool { false }
var currentSchema: String? { nil }
var serverVersion: String? { nil }

func connect() async throws {}
func disconnect() {}
func ping() async throws {}
func execute(query: String) async throws -> PluginQueryResult {
PluginQueryResult(columns: [], columnTypeNames: [], rows: [], rowsAffected: 0, executionTime: 0)
}

func fetchTables(schema: String?) async throws -> [PluginTableInfo] { [] }
func fetchColumns(table: String, schema: String?) async throws -> [PluginColumnInfo] { [] }
func fetchIndexes(table: String, schema: String?) async throws -> [PluginIndexInfo] { [] }
func fetchForeignKeys(table: String, schema: String?) async throws -> [PluginForeignKeyInfo] { [] }
func fetchTableDDL(table: String, schema: String?) async throws -> String { "" }
func fetchViewDefinition(view: String, schema: String?) async throws -> String { "" }
func fetchTableMetadata(table: String, schema: String?) async throws -> PluginTableMetadata {
PluginTableMetadata(tableName: table)
}

func fetchDatabases() async throws -> [String] { [] }
func fetchDatabaseMetadata(_ database: String) async throws -> PluginDatabaseMetadata {
PluginDatabaseMetadata(name: database)
}
}

struct PluginServerObjectDefaultsTests {
@Test("A driver that implements nothing declares no kinds and lists no objects")
func defaultsDeclareNothing() async throws {
let driver = StubServerObjectDriver()
#expect(driver.serverObjectKinds.isEmpty)
#expect(try await driver.fetchServerObjects(ofKind: "event", schema: "app").isEmpty)
#expect(try await driver.fetchServerObjects(ofKind: "extension", schema: nil).isEmpty)
}

@Test("Reading an object again returns it when the listing carried its definition")
func rereadKeepsListedDefinition() async throws {
let listed = PluginServerObjectInfo(kindId: "event", name: "nightly", definition: "CREATE EVENT nightly")
let read = try await StubServerObjectDriver().fetchServerObject(listed)
#expect(read.name == "nightly")
#expect(read.definition == "CREATE EVENT nightly")
}

@Test("Reading an object again without a definition is unsupported, not missing")
func rereadWithoutDefinitionIsUnsupported() async {
let listed = PluginServerObjectInfo(kindId: "event", name: "nightly", definition: "")
var refusal: Error?
do {
_ = try await StubServerObjectDriver().fetchServerObject(listed)
} catch {
refusal = error
}
guard let sourceError = refusal as? PluginObjectSourceError, case .unsupported(let name) = sourceError else {
Issue.record("expected unsupported, got \(String(describing: refusal))")
return
}
#expect(name == "nightly")
}

@Test("A kind is listed per container unless it says otherwise")
func kindScopeDefaultsToContainer() {
let kind = PluginServerObjectKind(id: "event", displayName: "Event", pluralDisplayName: "Events", iconName: "calendar")
#expect(kind.scope == .container)
}

@Test("Kinds and objects round-trip through Codable")
func codableRoundTrip() throws {
let kind = PluginServerObjectKind(
id: "extension", displayName: "Extension", pluralDisplayName: "Extensions",
iconName: "puzzlepiece.extension", scope: .database
)
let decodedKind = try JSONDecoder().decode(PluginServerObjectKind.self, from: JSONEncoder().encode(kind))
#expect(decodedKind == kind)

let object = PluginServerObjectInfo(
kindId: "extension", name: "pgcrypto", schema: "public", identity: "16384", detail: "1.3",
isEnabled: true, definition: "CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;",
attributes: [PluginObjectAttribute(label: "Version", value: "1.3")]
)
let decoded = try JSONDecoder().decode(PluginServerObjectInfo.self, from: JSONEncoder().encode(object))
#expect(decoded.kindId == object.kindId)
#expect(decoded.name == object.name)
#expect(decoded.schema == object.schema)
#expect(decoded.identity == object.identity)
#expect(decoded.detail == object.detail)
#expect(decoded.isEnabled == object.isEnabled)
#expect(decoded.definition == object.definition)
#expect(decoded.attributes == object.attributes)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ struct SQLCatalogEffectClassifierTests {
#expect(kinds("CREATE TABLE copy AS SELECT * FROM t") == .tables)
}

@Test("An event changes the triggers and the server objects, an extension reaches the server objects")
func serverObjects() {
#expect(kinds("CREATE EVENT nightly ON SCHEDULE EVERY 1 DAY DO DELETE FROM log", "MySQL") == [.triggers, .serverObjects])
#expect(kinds("ALTER EVENT nightly DISABLE", "MySQL") == [.triggers, .serverObjects])
#expect(kinds("DROP EVENT IF EXISTS nightly", "MySQL") == [.triggers, .serverObjects])
#expect(kinds("CREATE EXTENSION IF NOT EXISTS pgcrypto").contains(.serverObjects))
#expect(kinds("DROP EXTENSION pgcrypto").contains(.serverObjects))
#expect(SQLCatalogObjectKinds.objects.contains(.serverObjects))
#expect(!kinds("CREATE TABLE t (id int)").contains(.serverObjects))
}

@Test("Row work and reads leave the catalog alone, except SELECT INTO")
func rowsAndReads() {
#expect(kinds("INSERT INTO t VALUES (1)").isEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,19 @@ public extension TextViewController {
defer { isApplyingUnfilteredEdits = false }
textView.replaceCharacters(in: span, with: rebuilt, skipUpdateSelection: true)
}

// A command's replacement, unlike `setText`, keeps the undo history: one undo group, no typing filters, no
// suggestion triggers. The binding gets the text before this returns, so a run right after reads it.
@discardableResult
func replaceTextAsOneEdit(in range: NSRange, with string: String) -> Bool {
guard let textView, textView.isEditable, NSMaxRange(range) <= textView.textStorage.length else { return false }
guard !range.isEmpty || !string.isEmpty else { return true }
textView.undoManager?.beginUndoGrouping()
isApplyingUnfilteredEdits = true
textView.replaceCharacters(in: range, with: string)
isApplyingUnfilteredEdits = false
textView.undoManager?.endUndoGrouping()
flushPendingTextWriteback()
return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import AppKit
@testable import TableProEditorKit
import TableProTextEngine
import Testing

@MainActor
struct ReplaceTextAsOneEditTests {
@Test("A command's replacement keeps the undo history and undoes in one step")
func replacementIsUndoable() {
let (window, controller) = Mock.focusedTextViewController(string: "SELECT 1")
defer { window.orderOut(nil) }
let whole = NSRange(location: 0, length: controller.textView.textStorage.length)

#expect(controller.replaceTextAsOneEdit(in: whole, with: "SELECT * FROM users"))
#expect(controller.textView.string == "SELECT * FROM users")
#expect(controller.textView.undoManager?.canUndo == true)

controller.textView.undoManager?.undo()
#expect(controller.textView.string == "SELECT 1")
}

@Test("A command's replacement skips the typing filters a typed edit runs")
func replacementSkipsTypingFilters() {
let typed = Mock.loadedTextViewController(string: "")
typed.textView.replaceCharacters(in: NSRange(location: 0, length: 0), with: "\t")
#expect(typed.textView.string == " ")

let controller = Mock.loadedTextViewController(string: "")
#expect(controller.replaceTextAsOneEdit(in: NSRange(location: 0, length: 0), with: "\t"))
#expect(controller.textView.string == "\t")
}

@Test("An editor that takes no edits refuses, so the caller writes the text itself")
func uneditableEditorRefuses() {
let controller = Mock.loadedTextViewController(string: "SELECT 1")
controller.textView.isEditable = false

#expect(!controller.replaceTextAsOneEdit(in: NSRange(location: 0, length: 8), with: "SELECT 2"))
#expect(controller.textView.string == "SELECT 1")
}

@Test("A range past the end of the text is refused")
func rangePastTheTextIsRefused() {
let controller = Mock.loadedTextViewController(string: "SELECT 1")

#expect(!controller.replaceTextAsOneEdit(in: NSRange(location: 4, length: 20), with: "x"))
#expect(controller.textView.string == "SELECT 1")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ final class KingbaseESPluginDriver: PostgreSQLPluginDriver, @unchecked Sendable
)
}

// Not measured against a KingbaseES catalog yet, so no Extensions group.
override var serverObjectKinds: [PluginServerObjectKind] { [] }

override func probeAfterConnect() async throws {
let result = try await catalogRead(KingbaseESCompatibilityMode.probeQuery)
let detected = try KingbaseESCompatibilityMode(setting: result.rows.first?.first?.asText)
Expand Down
Loading
Loading