support connect oracle via SID
Some checks are pending
Run tests / test-runner (push) Waiting to run

This commit is contained in:
SPRINX0\prochazka 2024-09-02 10:46:43 +02:00
parent b87e53b704
commit 50583f928a
2 changed files with 34 additions and 2 deletions

View File

@ -142,7 +142,30 @@
{/if}
{#if driver?.showConnectionField('serviceName', $values, showConnectionFieldArgs)}
<FormTextField label="Service name" name="serviceName" disabled={isConnected} />
<div class="row">
<div class="col-9 mr-1">
<FormTextField
label={$values.serviceNameType == 'sid' ? 'SID' : 'Service name'}
name="serviceName"
disabled={isConnected}
templateProps={{ noMargin: true }}
/>
</div>
<div class="col-3">
<FormSelectField
label="Choose type"
isNative
name="serviceNameType"
defaultValue="serviceName"
disabled={isConnected}
templateProps={{ noMargin: true }}
options={[
{ value: 'serviceName', label: 'Service name' },
{ value: 'sid', label: 'SID' },
]}
/>
</div>
</div>
{/if}
{#if driver?.showConnectionField('socketPath', $values, showConnectionFieldArgs)}

View File

@ -60,6 +60,7 @@ const driver = {
databaseUrl,
useDatabaseUrl,
serviceName,
serviceNameType,
ssl,
isReadOnly,
authType,
@ -74,7 +75,15 @@ const driver = {
client = await oracledb.getConnection({
user,
password,
connectString: useDatabaseUrl ? databaseUrl : port ? `${server}:${port}/${serviceName}` : server,
connectString: useDatabaseUrl
? databaseUrl
: serviceName
? serviceNameType == 'sid'
? `(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=${server})(PORT=${
port || 1521
}))(CONNECT_DATA=(SID=${serviceName})))`
: `${server}:${port || 1521}/${serviceName}`
: `${server}:${port || 1521}`,
});
if (database) {
await client.execute(`ALTER SESSION SET CURRENT_SCHEMA = ${database}`);