Skip to content

Commit 7fa94b9

Browse files
committed
revert: undo MongoDB URI fix, bundling, and dedup changes
1 parent b1f17dc commit 7fa94b9

10 files changed

Lines changed: 15 additions & 203 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Keyboard focus navigation (Tab, Ctrl+J/K/N/P, arrow keys) for connection list, quick switcher, and database switcher
1313

14-
### Fixed
15-
16-
- MongoDB connection failing when importing `mongodb+srv://` URIs (#419)
17-
1814
## [0.22.1] - 2026-03-22
1915

2016
### Added

Plugins/MongoDBDriverPlugin/MongoDBConnection.swift

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ final class MongoDBConnection: @unchecked Sendable {
6262
private let authSource: String?
6363
private let readPreference: String?
6464
private let writeConcern: String?
65-
private let useSrv: Bool
66-
private let authMechanism: String?
67-
private let replicaSet: String?
68-
private let extraUriParams: [String: String]
6965

7066
private let stateLock = NSLock()
7167
private var _isConnected: Bool = false
@@ -118,11 +114,7 @@ final class MongoDBConnection: @unchecked Sendable {
118114
sslClientCertPath: String = "",
119115
authSource: String? = nil,
120116
readPreference: String? = nil,
121-
writeConcern: String? = nil,
122-
useSrv: Bool = false,
123-
authMechanism: String? = nil,
124-
replicaSet: String? = nil,
125-
extraUriParams: [String: String] = [:]
117+
writeConcern: String? = nil
126118
) {
127119
self.host = host
128120
self.port = port
@@ -135,10 +127,6 @@ final class MongoDBConnection: @unchecked Sendable {
135127
self.authSource = authSource
136128
self.readPreference = readPreference
137129
self.writeConcern = writeConcern
138-
self.useSrv = useSrv
139-
self.authMechanism = authMechanism
140-
self.replicaSet = replicaSet
141-
self.extraUriParams = extraUriParams
142130
}
143131

144132
deinit {
@@ -162,8 +150,7 @@ final class MongoDBConnection: @unchecked Sendable {
162150
// MARK: - URI Construction
163151

164152
private func buildUri() -> String {
165-
let scheme = useSrv ? "mongodb+srv" : "mongodb"
166-
var uri = "\(scheme)://"
153+
var uri = "mongodb://"
167154

168155
if !user.isEmpty {
169156
let encodedUser = user.addingPercentEncoding(withAllowedCharacters: .urlUserAllowed) ?? user
@@ -180,21 +167,10 @@ final class MongoDBConnection: @unchecked Sendable {
180167
let encodedHost = host.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? host
181168
let encodedDb = database.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? database
182169

183-
if useSrv {
184-
uri += encodedHost
185-
} else {
186-
uri += "\(encodedHost):\(port)"
187-
}
170+
uri += "\(encodedHost):\(port)"
188171
uri += database.isEmpty ? "/" : "/\(encodedDb)"
189172

190-
let effectiveAuthSource: String
191-
if let source = authSource, !source.isEmpty {
192-
effectiveAuthSource = source
193-
} else if !database.isEmpty {
194-
effectiveAuthSource = database
195-
} else {
196-
effectiveAuthSource = "admin"
197-
}
173+
let effectiveAuthSource = authSource.flatMap { $0.isEmpty ? nil : $0 } ?? "admin"
198174
let encodedAuthSource = effectiveAuthSource
199175
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? effectiveAuthSource
200176
var params: [String] = [
@@ -230,22 +206,6 @@ final class MongoDBConnection: @unchecked Sendable {
230206
if let wc = writeConcern, !wc.isEmpty {
231207
params.append("w=\(wc)")
232208
}
233-
if let mechanism = authMechanism, !mechanism.isEmpty {
234-
params.append("authMechanism=\(mechanism)")
235-
}
236-
if let rs = replicaSet, !rs.isEmpty {
237-
params.append("replicaSet=\(rs)")
238-
}
239-
240-
let explicitKeys: Set<String> = [
241-
"authSource", "readPreference", "w", "authMechanism", "replicaSet",
242-
"connectTimeoutMS", "serverSelectionTimeoutMS", "tls",
243-
"tlsAllowInvalidCertificates", "tlsCAFile", "tlsCertificateKeyFile"
244-
]
245-
for (key, value) in extraUriParams where !explicitKeys.contains(key) {
246-
let encodedValue = value.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? value
247-
params.append("\(key)=\(encodedValue)")
248-
}
249209

250210
uri += "?" + params.joined(separator: "&")
251211
return uri

Plugins/MongoDBDriverPlugin/MongoDBPlugin.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,6 @@ final class MongoDBPlugin: NSObject, TableProPlugin, DriverPlugin {
4141
.init(value: "3", label: "3"),
4242
])
4343
),
44-
ConnectionField(
45-
id: "mongoUseSrv",
46-
label: "Use SRV Record",
47-
defaultValue: "false",
48-
fieldType: .toggle,
49-
section: .advanced
50-
),
51-
ConnectionField(
52-
id: "mongoAuthMechanism",
53-
label: "Auth Mechanism",
54-
fieldType: .dropdown(options: [
55-
.init(value: "", label: "Default"),
56-
.init(value: "SCRAM-SHA-1", label: "SCRAM-SHA-1"),
57-
.init(value: "SCRAM-SHA-256", label: "SCRAM-SHA-256"),
58-
.init(value: "MONGODB-X509", label: "X.509"),
59-
.init(value: "MONGODB-AWS", label: "AWS IAM"),
60-
]),
61-
section: .authentication
62-
),
63-
ConnectionField(
64-
id: "mongoReplicaSet",
65-
label: "Replica Set",
66-
section: .advanced
67-
),
6844
]
6945

7046
// MARK: - UI/Capability Metadata

Plugins/MongoDBDriverPlugin/MongoDBPluginDriver.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ final class MongoDBPluginDriver: PluginDatabaseDriver {
3636
// MARK: - Connection Management
3737

3838
func connect() async throws {
39-
let useSrv = config.additionalFields["mongoUseSrv"] == "true"
40-
let authMechanism = config.additionalFields["mongoAuthMechanism"]
41-
let replicaSet = config.additionalFields["mongoReplicaSet"]
42-
43-
var extraParams: [String: String] = [:]
44-
for (key, value) in config.additionalFields where key.hasPrefix("mongoParam_") {
45-
let paramName = String(key.dropFirst("mongoParam_".count))
46-
if !paramName.isEmpty {
47-
extraParams[paramName] = value
48-
}
49-
}
50-
5139
let conn = MongoDBConnection(
5240
host: config.host,
5341
port: config.port,
@@ -59,11 +47,7 @@ final class MongoDBPluginDriver: PluginDatabaseDriver {
5947
sslClientCertPath: config.additionalFields["sslClientCertPath"] ?? "",
6048
authSource: config.additionalFields["mongoAuthSource"],
6149
readPreference: config.additionalFields["mongoReadPreference"],
62-
writeConcern: config.additionalFields["mongoWriteConcern"],
63-
useSrv: useSrv,
64-
authMechanism: authMechanism,
65-
replicaSet: replicaSet,
66-
extraUriParams: extraParams
50+
writeConcern: config.additionalFields["mongoWriteConcern"]
6751
)
6852

6953
try await conn.connect()

TablePro.xcodeproj/project.pbxproj

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
5ACE00012F4F000000000006 /* CodeEditTextView in Frameworks */ = {isa = PBXBuildFile; productRef = 5ACE00012F4F000000000007 /* CodeEditTextView */; };
3636
5ACE00012F4F00000000000A /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 5ACE00012F4F000000000009 /* Sparkle */; };
3737
5ACE00012F4F00000000000D /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 5ACE00012F4F00000000000C /* MarkdownUI */; };
38-
5A866000D00000000 /* MongoDBDriver.tableplugin in Copy Plug-Ins */ = {isa = PBXBuildFile; fileRef = 5A866000100000000 /* MongoDBDriver.tableplugin */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3938
5ADDB00000000000000000D0 /* DynamoDBDriverPlugin.tableplugin in Copy Plug-Ins */ = {isa = PBXBuildFile; fileRef = 5ADDB00300000000000000A0 /* DynamoDBDriverPlugin.tableplugin */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4039
5ADDB00100000000000000A1 /* DynamoDBConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ADDB00200000000000000A1 /* DynamoDBConnection.swift */; };
4140
5ADDB00100000000000000A2 /* DynamoDBItemFlattener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ADDB00200000000000000A2 /* DynamoDBItemFlattener.swift */; };
@@ -92,13 +91,6 @@
9291
remoteGlobalIDString = 5A865000000000000;
9392
remoteInfo = MySQLDriver;
9493
};
95-
5A866000B00000000 /* PBXContainerItemProxy */ = {
96-
isa = PBXContainerItemProxy;
97-
containerPortal = 5A1091BF2EF17EDC0055EA7C /* Project object */;
98-
proxyType = 1;
99-
remoteGlobalIDString = 5A866000000000000;
100-
remoteInfo = MongoDBDriver;
101-
};
10294
5A868000B00000000 /* PBXContainerItemProxy */ = {
10395
isa = PBXContainerItemProxy;
10496
containerPortal = 5A1091BF2EF17EDC0055EA7C /* Project object */;
@@ -164,7 +156,6 @@
164156
5A86B000D00000000 /* JSONExport.tableplugin in Copy Plug-Ins */,
165157
5A86C000D00000000 /* SQLExport.tableplugin in Copy Plug-Ins */,
166158
5ADDB00000000000000000D0 /* DynamoDBDriverPlugin.tableplugin in Copy Plug-Ins */,
167-
5A866000D00000000 /* MongoDBDriver.tableplugin in Copy Plug-Ins */,
168159
);
169160
name = "Copy Plug-Ins";
170161
runOnlyForDeploymentPostprocessing = 0;
@@ -833,7 +824,6 @@
833824
5A862000C00000000 /* PBXTargetDependency */,
834825
5A863000C00000000 /* PBXTargetDependency */,
835826
5A865000C00000000 /* PBXTargetDependency */,
836-
5A866000C00000000 /* PBXTargetDependency */,
837827
5A868000C00000000 /* PBXTargetDependency */,
838828
5A869000C00000000 /* PBXTargetDependency */,
839829
5A86A000C00000000 /* PBXTargetDependency */,
@@ -1756,11 +1746,6 @@
17561746
target = 5A865000000000000 /* MySQLDriver */;
17571747
targetProxy = 5A865000B00000000 /* PBXContainerItemProxy */;
17581748
};
1759-
5A866000C00000000 /* PBXTargetDependency */ = {
1760-
isa = PBXTargetDependency;
1761-
target = 5A866000000000000 /* MongoDBDriver */;
1762-
targetProxy = 5A866000B00000000 /* PBXContainerItemProxy */;
1763-
};
17641749
5A868000C00000000 /* PBXTargetDependency */ = {
17651750
isa = PBXTargetDependency;
17661751
target = 5A868000000000000 /* PostgreSQLDriver */;

TablePro/AppDelegate+ConnectionHandler.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ extension AppDelegate {
440440
tagId = ConnectionURLParser.tagId(fromEnvName: envName)
441441
}
442442

443-
var connection = DatabaseConnection(
443+
return DatabaseConnection(
444444
name: parsed.connectionName ?? parsed.suggestedName,
445445
host: parsed.host,
446446
port: parsed.port ?? parsed.type.defaultPort,
@@ -452,19 +452,8 @@ extension AppDelegate {
452452
color: color,
453453
tagId: tagId,
454454
mongoAuthSource: parsed.authSource,
455-
mongoUseSrv: parsed.useSrv,
456-
mongoAuthMechanism: parsed.mongoQueryParams["authMechanism"],
457-
mongoReplicaSet: parsed.mongoQueryParams["replicaSet"],
458455
redisDatabase: parsed.redisDatabase,
459456
oracleServiceName: parsed.oracleServiceName
460457
)
461-
462-
for (key, value) in parsed.mongoQueryParams where !value.isEmpty {
463-
if key != "authMechanism" && key != "replicaSet" {
464-
connection.additionalFields["mongoParam_\(key)"] = value
465-
}
466-
}
467-
468-
return connection
469458
}
470459
}

TablePro/Core/Plugins/PluginManager.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,6 @@ final class PluginManager {
400400
}
401401

402402
let bundleId = bundle.bundleIdentifier ?? url.lastPathComponent
403-
404-
// Skip user-installed plugin if a built-in version already exists
405-
if source == .userInstalled,
406-
let existing = plugins.first(where: { $0.id == bundleId }),
407-
existing.source == .builtIn
408-
{
409-
Self.logger.info("Skipping user-installed '\(bundleId)' — built-in version already loaded")
410-
return existing
411-
}
412-
413403
let disabled = disabledPluginIds
414404

415405
let driverType = principalClass as? any DriverPlugin.Type

TablePro/Core/Utilities/Connection/ConnectionURLParser.swift

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ struct ParsedConnectionURL {
3232
let filterValue: String?
3333
let filterCondition: String?
3434
let oracleServiceName: String?
35-
let useSrv: Bool
36-
let mongoQueryParams: [String: String]
3735

3836
var suggestedName: String {
3937
if let connectionName, !connectionName.isEmpty {
@@ -124,8 +122,6 @@ struct ConnectionURLParser {
124122
}
125123
}
126124

127-
let isSrv = scheme == "mongodb+srv"
128-
129125
if dbType == .sqlite {
130126
let path = String(trimmed[schemeEnd.upperBound...])
131127
return .success(ParsedConnectionURL(
@@ -154,9 +150,7 @@ struct ConnectionURLParser {
154150
filterOperation: nil,
155151
filterValue: nil,
156152
filterCondition: nil,
157-
oracleServiceName: nil,
158-
useSrv: false,
159-
mongoQueryParams: [:]
153+
oracleServiceName: nil
160154
))
161155
}
162156

@@ -187,7 +181,7 @@ struct ConnectionURLParser {
187181
database = String(database.dropFirst())
188182
}
189183

190-
var ext = parseQueryItems(components.queryItems, dbType: dbType)
184+
let ext = parseQueryItems(components.queryItems)
191185

192186
var sslMode = ext.sslMode
193187
// Redis-specific: parse database index from path and handle TLS scheme
@@ -209,19 +203,10 @@ struct ConnectionURLParser {
209203
database = ""
210204
}
211205

212-
// SRV implies TLS and no explicit port
213-
if isSrv {
214-
ext.useSrv = true
215-
if sslMode == nil {
216-
sslMode = .required
217-
}
218-
}
219-
let effectivePort = isSrv ? nil : port
220-
221206
return .success(ParsedConnectionURL(
222207
type: dbType,
223208
host: host,
224-
port: effectivePort,
209+
port: port,
225210
database: database,
226211
username: username,
227212
password: password,
@@ -244,9 +229,7 @@ struct ConnectionURLParser {
244229
filterOperation: ext.filterOperation,
245230
filterValue: ext.filterValue,
246231
filterCondition: ext.filterCondition,
247-
oracleServiceName: oracleServiceName,
248-
useSrv: ext.useSrv,
249-
mongoQueryParams: ext.mongoQueryParams
232+
oracleServiceName: oracleServiceName
250233
))
251234
}
252235

@@ -377,9 +360,7 @@ struct ConnectionURLParser {
377360
filterOperation: ext.filterOperation,
378361
filterValue: ext.filterValue,
379362
filterCondition: ext.filterCondition,
380-
oracleServiceName: oracleServiceName,
381-
useSrv: ext.useSrv,
382-
mongoQueryParams: ext.mongoQueryParams
363+
oracleServiceName: oracleServiceName
383364
))
384365
}
385366

@@ -401,16 +382,14 @@ struct ConnectionURLParser {
401382
var filterOperation: String?
402383
var filterValue: String?
403384
var filterCondition: String?
404-
var useSrv: Bool = false
405-
var mongoQueryParams: [String: String] = [:]
406385
}
407386

408-
private static func parseQueryItems(_ queryItems: [URLQueryItem]?, dbType: DatabaseType? = nil) -> ExtendedParams {
387+
private static func parseQueryItems(_ queryItems: [URLQueryItem]?) -> ExtendedParams {
409388
var ext = ExtendedParams()
410389
guard let queryItems else { return ext }
411390
for item in queryItems {
412391
guard let value = item.value, !value.isEmpty else { continue }
413-
applyQueryParam(key: item.name, value: value, to: &ext, dbType: dbType)
392+
applyQueryParam(key: item.name, value: value, to: &ext)
414393
}
415394
return ext
416395
}
@@ -441,7 +420,7 @@ struct ConnectionURLParser {
441420
return ext
442421
}
443422

444-
private static func applyQueryParam(key: String, value: String, to ext: inout ExtendedParams, dbType: DatabaseType? = nil) {
423+
private static func applyQueryParam(key: String, value: String, to ext: inout ExtendedParams) {
445424
switch key {
446425
case "sslmode":
447426
ext.sslMode = parseSSLMode(value)
@@ -477,18 +456,8 @@ struct ConnectionURLParser {
477456
if ext.sslMode == nil, let intValue = Int(value) {
478457
ext.sslMode = parseTlsModeInteger(intValue)
479458
}
480-
case "tls", "ssl":
481-
if value.lowercased() == "true" && ext.sslMode == nil {
482-
ext.sslMode = .required
483-
}
484-
case "authMechanism", "authmechanism":
485-
ext.mongoQueryParams["authMechanism"] = value
486-
case "replicaSet", "replicaset":
487-
ext.mongoQueryParams["replicaSet"] = value
488459
default:
489-
if dbType == .mongodb {
490-
ext.mongoQueryParams[key] = value
491-
}
460+
break
492461
}
493462
}
494463

0 commit comments

Comments
 (0)