Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 11 additions & 3 deletions TablePro/Core/Services/Query/TableQueryBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ struct TableQueryBuilder {

private let databaseType: DatabaseType
private var pluginDriver: (any PluginDatabaseDriver)?
private let dialectQuote: (String) -> String

// MARK: - Initialization

init(databaseType: DatabaseType, pluginDriver: (any PluginDatabaseDriver)? = nil) {
init(
databaseType: DatabaseType,
pluginDriver: (any PluginDatabaseDriver)? = nil,
dialectQuote: ((String) -> String)? = nil
) {
self.databaseType = databaseType
self.pluginDriver = pluginDriver
self.dialectQuote = dialectQuote ?? { name in
let escaped = name.replacingOccurrences(of: "\"", with: "\"\"")
return "\"\(escaped)\""
}
}

mutating func setPluginDriver(_ driver: (any PluginDatabaseDriver)?) {
Expand All @@ -31,8 +40,7 @@ struct TableQueryBuilder {

private func quote(_ name: String) -> String {
if let pluginDriver { return pluginDriver.quoteIdentifier(name) }
let escaped = name.replacingOccurrences(of: "\"", with: "\"\"")
return "\"\(escaped)\""
return dialectQuote(name)
}

// MARK: - Query Building
Expand Down
7 changes: 6 additions & 1 deletion TablePro/Views/Main/MainContentCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ final class MainContentCoordinator {
self.filterStateManager = filterStateManager
self.columnVisibilityManager = columnVisibilityManager
self.toolbarState = toolbarState
self.queryBuilder = TableQueryBuilder(databaseType: connection.type)
self.queryBuilder = TableQueryBuilder(
databaseType: connection.type,
dialectQuote: quoteIdentifierFromDialect(
PluginManager.shared.sqlDialect(for: connection.type)
)
)
self.persistence = TabPersistenceCoordinator(connectionId: connection.id)

self.schemaProvider = SchemaProviderRegistry.shared.getOrCreate(for: connection.id)
Expand Down
Loading