Skip to content

Commit c73f754

Browse files
committed
fix: execute error
1 parent 4b87fe5 commit c73f754

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

lib/oracle.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OracleDB {
2323
*/
2424
async _getConnection() {
2525
try {
26-
return this.pool.getConnection();
26+
return await this.pool.getConnection();
2727
} catch (err) {
2828
this.log.error(err.message);
2929
try {
@@ -62,19 +62,13 @@ class OracleDB {
6262
* @return {ResultObject} result object, containing any fetched rows, the values of any OUT and IN OUT bind variables, and the number of rows affected by the execution of DML statements.
6363
*/
6464
async execute(sql, bindParams = {}, options = {}) {
65-
const connection = this.connection || await this._getConnection();
65+
const connection = this.connection || (this.connection = await this._getConnection());
6666
if (typeof sql === 'string' && bindParams instanceof Object) {
6767
try {
6868
const result = await connection.execute(sql, bindParams, options);
6969
return result;
7070
} catch (err) {
7171
this.log.error(err.message);
72-
try {
73-
await connection.close();
74-
} catch (error) {
75-
this.log.error(error.message);
76-
this.connection = await this._getConnection();
77-
}
7872
throw err;
7973
}
8074
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "egg-oracle",
3-
"version": "1.0.9",
3+
"version": "1.0.11",
44
"description": "Oracle database plugin for egg",
55
"eggPlugin": {
66
"name": "oracle"

0 commit comments

Comments
 (0)