From 38b683a99c06d7848634bf643c0c6034f8e043ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Qu=E1=BB=91c=20=C4=90=E1=BA=A1t?= Date: Wed, 27 May 2026 16:31:46 +0700 Subject: [PATCH] feat(plugin-oracle): add SID connection option --- CHANGELOG.md | 1 + .../OracleDriverPlugin/OracleConnection.swift | 8 +++-- Plugins/OracleDriverPlugin/OraclePlugin.swift | 30 +++++++++++++++++-- docs/databases/oracle.mdx | 2 +- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63029bac1..69187b4c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - BigQuery: the sidebar now shows every dataset as an expandable node, with each dataset's tables loading when you open it, instead of showing one dataset at a time behind a picker. - OpenCode Zen as an AI provider. Add it from the provider list and paste an OpenCode key, or leave the key blank to use the free models; the model list loads automatically, covering the Claude, GPT, Gemini, and open models Zen serves. (#1400) - Oracle Database 11g (11.1 and 11.2) now connects. Previously only 12c and later worked, so 11g servers failed with a "Server Version Not Supported" error. (#1425) +- Oracle connections can now use a SID instead of a service name. Set Connection Type to SID in the connection form and enter the SID. (#1425) - Cmd-click a foreign key arrow to open the referenced table in a new tab instead of the current one. The right-click menu has the same Open in New Tab option. (#1421) ### Changed diff --git a/Plugins/OracleDriverPlugin/OracleConnection.swift b/Plugins/OracleDriverPlugin/OracleConnection.swift index 4f5d840fe..226ad9e59 100644 --- a/Plugins/OracleDriverPlugin/OracleConnection.swift +++ b/Plugins/OracleDriverPlugin/OracleConnection.swift @@ -117,6 +117,7 @@ final class OracleConnectionWrapper: @unchecked Sendable { private let password: String private let database: String private let serviceName: String + private let useSID: Bool private let sslConfig: SSLConfiguration private struct LockedState: Sendable { @@ -140,6 +141,7 @@ final class OracleConnectionWrapper: @unchecked Sendable { password: String, database: String, serviceName: String = "", + useSID: Bool = false, sslConfig: SSLConfiguration = SSLConfiguration() ) { self.host = host @@ -148,18 +150,20 @@ final class OracleConnectionWrapper: @unchecked Sendable { self.password = password self.database = database self.serviceName = serviceName + self.useSID = useSID self.sslConfig = sslConfig } // MARK: - Connection func connect() async throws { - let service = serviceName.isEmpty ? database : serviceName + let identifier = serviceName.isEmpty ? database : serviceName + let service: OracleServiceMethod = useSID ? .sid(identifier) : .serviceName(identifier) let tls = try OracleSSLMapping.tls(for: sslConfig) let config = OracleNIO.OracleConnection.Configuration( host: host, port: port, - service: .serviceName(service), + service: service, username: user, password: password, tls: tls diff --git a/Plugins/OracleDriverPlugin/OraclePlugin.swift b/Plugins/OracleDriverPlugin/OraclePlugin.swift index fef5f2be3..a1d47de61 100644 --- a/Plugins/OracleDriverPlugin/OraclePlugin.swift +++ b/Plugins/OracleDriverPlugin/OraclePlugin.swift @@ -18,7 +18,27 @@ final class OraclePlugin: NSObject, TableProPlugin, DriverPlugin, PluginDiagnost static let iconName = "oracle-icon" static let defaultPort = 1_521 static let additionalConnectionFields: [ConnectionField] = [ - ConnectionField(id: "oracleServiceName", label: "Service Name", placeholder: "ORCL") + ConnectionField( + id: "oracleConnectionType", + label: "Connection Type", + defaultValue: "service", + fieldType: .dropdown(options: [ + ConnectionField.DropdownOption(value: "service", label: "Service Name"), + ConnectionField.DropdownOption(value: "sid", label: "SID") + ]) + ), + ConnectionField( + id: "oracleServiceName", + label: "Service Name", + placeholder: "ORCL", + visibleWhen: FieldVisibilityRule(fieldId: "oracleConnectionType", values: ["service"]) + ), + ConnectionField( + id: "oracleSID", + label: "SID", + placeholder: "XE", + visibleWhen: FieldVisibilityRule(fieldId: "oracleConnectionType", values: ["sid"]) + ) ] // MARK: - UI/Capability Metadata @@ -185,14 +205,18 @@ final class OraclePluginDriver: PluginDatabaseDriver, @unchecked Sendable { // MARK: - Connection func connect() async throws { - let serviceName = config.additionalFields["oracleServiceName"] ?? "" + let useSID = config.additionalFields["oracleConnectionType"] == "sid" + let identifier = useSID + ? config.additionalFields["oracleSID"] ?? "" + : config.additionalFields["oracleServiceName"] ?? "" let conn = OracleConnectionWrapper( host: config.host, port: config.port, user: config.username, password: config.password, database: config.database, - serviceName: serviceName, + serviceName: identifier, + useSID: useSID, sslConfig: config.ssl ) try await conn.connect() diff --git a/docs/databases/oracle.mdx b/docs/databases/oracle.mdx index fab4632bd..5222687b4 100644 --- a/docs/databases/oracle.mdx +++ b/docs/databases/oracle.mdx @@ -36,7 +36,7 @@ The Oracle driver is available as a downloadable plugin. When you select Oracle |-------|---------|-------| | **Host** | `localhost` | | | **Port** | `1521` | Listener port | -| **Service Name** | - | **Required**. Use service name not SID. Check `tnsnames.ora` if unclear. | +| **Service Name** | - | **Required**. Check `tnsnames.ora` if unclear. To connect by SID instead, set **Connection Type** to SID and enter the SID. | | **Username** | - | Requires username/password auth (no OS auth) | ## Example Configurations