mirror of
https://github.com/knex/knex.git
synced 2025-12-13 07:50:50 +00:00
Support non-standard Oracle port (#4147)
This commit is contained in:
parent
073df48cc6
commit
c47e00de64
@ -81,6 +81,24 @@ Client_Oracledb.prototype.prepBindings = function (bindings) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function resolveConnectString(connectionSettings) {
|
||||||
|
if (connectionSettings.connectString) {
|
||||||
|
return connectionSettings.connectString;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!connectionSettings.port) {
|
||||||
|
return connectionSettings.host + '/' + connectionSettings.database;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
connectionSettings.host +
|
||||||
|
':' +
|
||||||
|
connectionSettings.port +
|
||||||
|
'/' +
|
||||||
|
connectionSettings.database
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Get a raw connection, called by the `pool` whenever a new
|
// Get a raw connection, called by the `pool` whenever a new
|
||||||
// connection needs to be added to the pool.
|
// connection needs to be added to the pool.
|
||||||
Client_Oracledb.prototype.acquireRawConnection = function () {
|
Client_Oracledb.prototype.acquireRawConnection = function () {
|
||||||
@ -96,9 +114,9 @@ Client_Oracledb.prototype.acquireRawConnection = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// In the case of external authentication connection string will be given
|
// In the case of external authentication connection string will be given
|
||||||
oracleDbConfig.connectString =
|
oracleDbConfig.connectString = resolveConnectString(
|
||||||
client.connectionSettings.connectString ||
|
client.connectionSettings
|
||||||
client.connectionSettings.host + '/' + client.connectionSettings.database;
|
);
|
||||||
|
|
||||||
if (client.connectionSettings.prefetchRowCount) {
|
if (client.connectionSettings.prefetchRowCount) {
|
||||||
oracleDbConfig.prefetchRows = client.connectionSettings.prefetchRowCount;
|
oracleDbConfig.prefetchRows = client.connectionSettings.prefetchRowCount;
|
||||||
@ -142,60 +160,68 @@ Client_Oracledb.prototype.acquireRawConnection = function () {
|
|||||||
throw new Error('not found oracledb.outFormat constants');
|
throw new Error('not found oracledb.outFormat constants');
|
||||||
}
|
}
|
||||||
if (options.resultSet) {
|
if (options.resultSet) {
|
||||||
connection.execute(sql, bindParams || [], options, function (
|
connection.execute(
|
||||||
err,
|
sql,
|
||||||
result
|
bindParams || [],
|
||||||
) {
|
options,
|
||||||
if (err) {
|
function (err, result) {
|
||||||
if (isConnectionError(err)) {
|
if (err) {
|
||||||
connection.close().catch(function (err) {});
|
if (isConnectionError(err)) {
|
||||||
connection.__knex__disposed = err;
|
connection.close().catch(function (err) {});
|
||||||
}
|
connection.__knex__disposed = err;
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
const fetchResult = { rows: [], resultSet: result.resultSet };
|
|
||||||
const numRows = 100;
|
|
||||||
const fetchRowsFromRS = function (connection, resultSet, numRows) {
|
|
||||||
resultSet.getRows(numRows, function (err, rows) {
|
|
||||||
if (err) {
|
|
||||||
if (isConnectionError(err)) {
|
|
||||||
connection.close().catch(function (err) {});
|
|
||||||
connection.__knex__disposed = err;
|
|
||||||
}
|
|
||||||
resultSet.close(function () {
|
|
||||||
return cb(err);
|
|
||||||
});
|
|
||||||
} else if (rows.length === 0) {
|
|
||||||
return cb(null, fetchResult);
|
|
||||||
} else if (rows.length > 0) {
|
|
||||||
if (rows.length === numRows) {
|
|
||||||
fetchResult.rows = fetchResult.rows.concat(rows);
|
|
||||||
fetchRowsFromRS(connection, resultSet, numRows);
|
|
||||||
} else {
|
|
||||||
fetchResult.rows = fetchResult.rows.concat(rows);
|
|
||||||
return cb(null, fetchResult);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
return cb(err);
|
||||||
};
|
|
||||||
fetchRowsFromRS(connection, result.resultSet, numRows);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
connection.execute(sql, bindParams || [], options, function (
|
|
||||||
err,
|
|
||||||
result
|
|
||||||
) {
|
|
||||||
if (err) {
|
|
||||||
// dispose the connection on connection error
|
|
||||||
if (isConnectionError(err)) {
|
|
||||||
connection.close().catch(function (err) {});
|
|
||||||
connection.__knex__disposed = err;
|
|
||||||
}
|
}
|
||||||
return cb(err);
|
const fetchResult = { rows: [], resultSet: result.resultSet };
|
||||||
|
const numRows = 100;
|
||||||
|
const fetchRowsFromRS = function (
|
||||||
|
connection,
|
||||||
|
resultSet,
|
||||||
|
numRows
|
||||||
|
) {
|
||||||
|
resultSet.getRows(numRows, function (err, rows) {
|
||||||
|
if (err) {
|
||||||
|
if (isConnectionError(err)) {
|
||||||
|
connection.close().catch(function (err) {});
|
||||||
|
connection.__knex__disposed = err;
|
||||||
|
}
|
||||||
|
resultSet.close(function () {
|
||||||
|
return cb(err);
|
||||||
|
});
|
||||||
|
} else if (rows.length === 0) {
|
||||||
|
return cb(null, fetchResult);
|
||||||
|
} else if (rows.length > 0) {
|
||||||
|
if (rows.length === numRows) {
|
||||||
|
fetchResult.rows = fetchResult.rows.concat(rows);
|
||||||
|
fetchRowsFromRS(connection, resultSet, numRows);
|
||||||
|
} else {
|
||||||
|
fetchResult.rows = fetchResult.rows.concat(rows);
|
||||||
|
return cb(null, fetchResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
fetchRowsFromRS(connection, result.resultSet, numRows);
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
connection.execute(
|
||||||
|
sql,
|
||||||
|
bindParams || [],
|
||||||
|
options,
|
||||||
|
function (err, result) {
|
||||||
|
if (err) {
|
||||||
|
// dispose the connection on connection error
|
||||||
|
if (isConnectionError(err)) {
|
||||||
|
connection.close().catch(function (err) {});
|
||||||
|
connection.__knex__disposed = err;
|
||||||
|
}
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
|
||||||
return cb(null, result);
|
return cb(null, result);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connection.executeAsync = function (sql, bindParams, options) {
|
connection.executeAsync = function (sql, bindParams, options) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user