Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORA: Add pool configuration (oracleOptions) #204

Merged
merged 2 commits into from
May 3, 2019
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
7 changes: 6 additions & 1 deletion .test-database/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@
"password": "root",
"port": 1521,
"username": "root",
"server": "localhost"
"server": "localhost",
"oracleOptions": {
"poolMax": 1,
"poolMin": 1,
"poolIncrement": 0
}
},
{
"askForPassword": false,
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
### v0.17.13

* **NEW** 🎉
* Enhanced connection hierarchy to allow multiple schemas and databases for Oracle, thanks to [@mickeypierce](https://github.com/mickeypierce)
* Enhanced connection hierarchy to allow multiple schemas and databases for Oracle, thanks to [@mickeypearce](https://github.com/mickeypearce)

* **Enhancements**
* Generate insert queries now includes database and schema prefixes accordingly with the dialect.
Expand Down
29 changes: 26 additions & 3 deletions docs/Connections/OracleDB.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ Connection example:

### 2.2 Alternative Connection Strings

ConnectionString maps directly from `database` property (If you omit `server` and `port`):
ConnectionString maps from `connectString` property:

```
"connectionString" = database
"connectionString" = connectString
```

For example if you have `tnsnames.ora` file with service name defined or any other alternative connection strings:
Expand All @@ -56,10 +56,33 @@ For example if you have `tnsnames.ora` file with service name defined or any oth
"password": "welcome",
"askForPassword": false,
"connectionTimeout": 15,
"database": "oraclpdb"
"connectString": "oraclpdb"
}
```

If you omit `server` and `port` properties, `database` can be used as an alias for `connectString`.

### 2.3 Specific Options

Oracle Connection Pool specific configurations can be passed using `oracleOptions` settings:

```json
{
"dialect": "OracleDB",
"name": "oracledb2",
"username": "hr",
"password": "welcome",
"connectString": "hostname:port/service_name",
"oracleOptions": {
"poolMax": 1,
"poolMin": 1,
"poolIncrement": 0
}
}
```

See https://github.com/oracle/node-oracledb/blob/master/doc/api.md#createpoolpoolattrs for additonal information.

## 3. Autocompletion

To enable autocompletion in PL/SQL files add:
Expand Down
1 change: 1 addition & 0 deletions packages/core/dialect/oracle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class OracleDB extends GenericDialect<OracleDBLib.IConnection> im
password: this.credentials.password,
user: this.credentials.username,
poolAlias: this.poolName,
...this.credentials.oracleOptions
});
this.registerPool();
return this.connection;
Expand Down
9 changes: 9 additions & 0 deletions packages/core/interface/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DatabaseDialect } from './dialect';
import { ClientConfig } from 'pg';
import { ConnectionConfig } from 'mysql';
import { DatabaseInterface } from '@sqltools/core/plugin-api';
import { IPoolAttributes } from 'oracledb';

export interface ConnectionInterface {
/**
Expand Down Expand Up @@ -112,6 +113,14 @@ export interface ConnectionInterface {
pgOptions?: {
ssl?: ClientConfig['ssl'];
}

/**
* OracleDB specific driver options (pool). See https://github.com/oracle/node-oracledb/blob/master/doc/api.md#createpoolpoolattrs
* @type {IPoolAttributes}
* @memberof ConnectionInterface
*/
oracleOptions?: IPoolAttributes

/**
* Connection domain (for MSSQL/Azure only)
* @type {string}
Expand Down
1 change: 1 addition & 0 deletions packages/core/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function decorateException(e: Error & { code?: number; data?: { [key: str
mssqlOptions: conn.mssqlOptions,
mysqlOptions: conn.mysqlOptions,
pgOptions: conn.pgOptions,
oracleOptions: JSON.stringify(conn.oracleOptions),
};
}
return new DecoratedException<typeof e.data>(e, data);
Expand Down
9 changes: 9 additions & 0 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,15 @@
}
}
},
"oracleOptions": {
"type": [
"object",
"null"
],
"default": {},
"required": false,
"description": "See https://vscode-sqltools.mteixeira.dev/connections/oracledb#2-3-specific-options for more details."
},
"connectionTimeout": {
"type": "number",
"description": "Connection timeout in seconds",
Expand Down