Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-oracledb

Package Overview
Dependencies
Maintainers
1
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-oracledb - npm Package Compare versions

Comparing version 1.1.24 to 1.1.25

56

docs/api.md

@@ -83,2 +83,13 @@ ## Classes

**Example**
```js
//see oracledb documentation for more examples
connection.execute('SELECT department_id, department_name FROM departments WHERE manager_id < :id', [110], function onResults(error, results) {
if (error) {
//handle error...
} else {
//continue
}
});
```
<a name="Connection+query"></a>

@@ -1092,2 +1103,13 @@

**Example**
```js
//load the oracledb library
var oracledb = require('oracledb');
//load the simple oracledb
var SimpleOracleDB = require('simple-oracledb');
//modify the original oracledb library
SimpleOracleDB.extend(oracledb);
```
<a name="SimpleOracleDB+extend"></a>

@@ -1105,2 +1127,23 @@

**Example**
```js
//load the simple oracledb
var SimpleOracleDB = require('simple-oracledb');
function myFunction(pool) {
//modify the original oracledb pool instance
SimpleOracleDB.extend(pool);
//from this point connections fetched via pool.getConnection(...)
//have access to additional functionality.
pool.getConnection(function onConnection(error, connection) {
if (error) {
//handle error
} else {
//work with new capabilities or original oracledb capabilities
connection.query(...);
}
});
}
```
<a name="SimpleOracleDB+extend"></a>

@@ -1118,2 +1161,15 @@

**Example**
```js
//load the simple oracledb
var SimpleOracleDB = require('simple-oracledb');
function doSomething(connection, callback) {
//modify the original oracledb connection instance
SimpleOracleDB.extend(connection);
//from this point the connection has access to additional functionality as well as the original oracledb capabilities.
connection.query(...);
}
```
<a name="SimpleOracleDB+addExtension"></a>

@@ -1120,0 +1176,0 @@

2

docs/CHANGELOG.md
| Date | Version | Description |
| ----------- | ------- | ----------- |
| 2016-10-06 | v1.1.24 | Maintenance |
| 2016-10-06 | v1.1.25 | Maintenance |
| 2016-08-15 | v1.1.2 | Added 'metadata' event for connection.query with streaming |

@@ -5,0 +5,0 @@ | 2016-08-15 | v1.1.1 | Maintenance |

@@ -61,7 +61,7 @@ 'use strict';

/**
* Extends the original oracledb connection.execute to provide additional behavior.
* Returns the execute arguments if provided.
*
* @function
* @memberof! Connection
* @public
* @private
* @param {string} sql - The SQL to execute

@@ -71,61 +71,86 @@ * @param {object} [bindParams] - Optional bind parameters

* @param {AsyncCallback} [callback] - Callback function with the execution results
* @returns {Promise} In case of no callback provided in input, this function will return a promise
* @returns {Object} All the arguments found
* @example
* ```js
* //get object with actual named arguments by checking input parametrs
* var input = connection.getExecuteArguments('SELECT department_id, department_name FROM departments WHERE manager_id < :id', myCallback);
*
* var sql = input.sql;
* var bindParams = input.bindParams;
* var options = input.options;
* var callback = input.callback;
* ```
*/
Connection.prototype.execute = function () {
var argumentsArray = Array.prototype.slice.call(arguments, 0);
if (this.inTransaction && (argumentsArray.length >= 3)) {
if (typeof argumentsArray[2] !== 'function') {
argumentsArray[2].autoCommit = false;
}
Connection.prototype.getExecuteArguments = function (sql, bindParams, options, callback) {
if (bindParams && (typeof bindParams === 'function')) {
callback = bindParams;
bindParams = null;
options = null;
} else if (options && (typeof options === 'function')) {
callback = options;
options = null;
}
var sql;
if (argumentsArray[0] && (typeof argumentsArray[0] === 'string')) {
sql = argumentsArray[0];
}
this.diagnosticInfo.lastSQL = sql;
var bindParams;
if (argumentsArray[1] && (typeof argumentsArray[1] === 'object')) {
bindParams = argumentsArray[1];
}
debug('Execute, SQL: ', sql, ' Bind Params: ', bindParams);
return this.baseExecute.apply(this, argumentsArray);
return {
callback: callback,
sql: sql,
bindParams: bindParams,
options: options
};
};
/**
* Returns the query arguments if provided.
* Extends the original oracledb connection.execute to provide additional behavior.
*
* @function
* @memberof! Connection
* @private
* @param {Array} argumentsArray - Array holding all of the query arguments
* @returns {Object} All the arguments found
* @public
* @param {string} sql - The SQL to execute
* @param {object} [bindParams] - Optional bind parameters
* @param {object} [options] - Optional execute options
* @param {AsyncCallback} [callback] - Callback function with the execution results
* @returns {Promise} In case of no callback provided in input, this function will return a promise
* @example
* ```js
* //see oracledb documentation for more examples
* connection.execute('SELECT department_id, department_name FROM departments WHERE manager_id < :id', [110], function onResults(error, results) {
* if (error) {
* //handle error...
* } else {
* //continue
* }
* });
* ```
*/
Connection.prototype.getQueryArguments = function (argumentsArray) {
var callback;
if (typeof argumentsArray[argumentsArray.length - 1] === 'function') { //if last argument is callback
callback = argumentsArray.pop();
Connection.prototype.execute = function (sql, bindParams, options, callback) {
var input = this.getExecuteArguments(sql, bindParams, options, callback);
sql = input.sql;
bindParams = input.bindParams;
options = input.options;
callback = input.callback;
if (this.inTransaction && options) {
options.autoCommit = false;
}
//get arguments
var sql = argumentsArray[0];
var bindParams;
var options;
if (argumentsArray.length > 1) {
bindParams = argumentsArray[1];
this.diagnosticInfo.lastSQL = sql;
if (argumentsArray.length > 2) {
options = argumentsArray[2];
debug('Execute, SQL: ', sql, ' Bind Params: ', bindParams);
var args = [
sql
];
if (bindParams) {
args.push(bindParams);
if (options) {
args.push(options);
}
}
if (callback) {
args.push(callback);
}
return {
callback: callback,
sql: sql,
bindParams: bindParams,
options: options
};
return this.baseExecute.apply(this, args);
};

@@ -203,13 +228,11 @@

*/
Connection.prototype.query = function () {
Connection.prototype.query = function (sql, bindParams, options, callback) {
var self = this;
var argumentsArray = Array.prototype.slice.call(arguments, 0);
var input = self.getExecuteArguments(sql, bindParams, options, callback);
//get arguments
var queryArguments = self.getQueryArguments(argumentsArray);
var callback = queryArguments.callback;
var sql = queryArguments.sql;
var bindParams = queryArguments.bindParams;
var options = queryArguments.options;
sql = input.sql;
bindParams = input.bindParams;
options = input.options;
callback = input.callback;

@@ -323,8 +346,4 @@ var handleType = 0;

*/
Connection.prototype.insert = function () {
var argumentsArray = Array.prototype.slice.call(arguments, 0);
argumentsArray.unshift(true);
return this.insertOrUpdate.apply(this, argumentsArray);
Connection.prototype.insert = function (sql, bindParams, options, callback) {
return this.insertOrUpdate(true, sql, bindParams, options, callback);
};

@@ -367,8 +386,4 @@

*/
Connection.prototype.update = function () {
var argumentsArray = Array.prototype.slice.call(arguments, 0);
argumentsArray.unshift(false);
return this.insertOrUpdate.apply(this, argumentsArray);
Connection.prototype.update = function (sql, bindParams, options, callback) {
return this.insertOrUpdate(false, sql, bindParams, options, callback);
};

@@ -390,10 +405,46 @@

* @returns {Promise} In case of no callback provided in input and promise is supported, this function will return a promise
* @example
* ```js
* connection.insertOrUpdate(true, 'INSERT INTO mylobs (id, clob_column1, blob_column2) VALUES (:id, EMPTY_CLOB(), EMPTY_BLOB())', { //no need to specify the RETURNING clause in the SQL
* id: 110,
* clobText1: 'some long clob string', //add bind variable with LOB column name and text content (need to map that name in the options)
* blobBuffer2: new Buffer('some blob content, can be binary...') //add bind variable with LOB column name and text content (need to map that name in the options)
* }, {
* autoCommit: true, //must be set to true in options to support auto commit after update is done, otherwise the auto commit will be false (oracledb.autoCommit is not checked)
* lobMetaInfo: { //if LOBs are provided, this data structure must be provided in the options object and the bind variables parameter must be an object (not array)
* clob_column1: 'clobText1', //map oracle column name to bind variable name
* blob_column2: 'blobBuffer2'
* }
* }, function onResults(error, output) {
* //continue flow...
* });
*
* connection.insertOrUpdate(false, 'UPDATE mylobs SET name = :name, clob_column1 = EMPTY_CLOB(), blob_column2 = EMPTY_BLOB() WHERE id = :id', { //no need to specify the RETURNING clause in the SQL
* id: 110,
* name: 'My Name',
* clobText1: 'some long clob string', //add bind variable with LOB column name and text content (need to map that name in the options)
* blobBuffer2: new Buffer('some blob content, can be binary...') //add bind variable with LOB column name and text content (need to map that name in the options)
* }, {
* autoCommit: true, //must be set to true in options to support auto commit after update is done, otherwise the auto commit will be false (oracledb.autoCommit is not checked)
* lobMetaInfo: { //if LOBs are provided, this data structure must be provided in the options object and the bind variables parameter must be an object (not array)
* clob_column1: 'clobText1', //map oracle column name to bind variable name
* blob_column2: 'blobBuffer2'
* }
* }, function onResults(error, output) {
* //continue flow...
* });
* ```
*/
Connection.prototype.insertOrUpdate = function () {
Connection.prototype.insertOrUpdate = function (insert, sql, bindParams, options, callback) {
var self = this;
var argumentsArray = Array.prototype.slice.call(arguments, 0);
var insert = argumentsArray.shift();
var input = self.getExecuteArguments(sql, bindParams, options, callback);
var lobInfo = self.modifyParams(argumentsArray);
sql = input.sql;
bindParams = input.bindParams;
options = input.options;
callback = input.callback;
var lobInfo = self.modifyParams(sql, bindParams, options);
sql = lobInfo.sql;
var lobColumns = lobInfo.lobColumns;

@@ -403,4 +454,2 @@ var lobData = lobInfo.lobData;

var callback = argumentsArray.pop();
if (!callback) {

@@ -410,3 +459,3 @@ throw new Error('Callback not provided.');

argumentsArray.push(function onExecute(error, results) {
self.execute(sql, bindParams, options, function onExecute(error, results) {
var wrapper = self.createModifyCallback(callback, autoCommit, results);

@@ -426,4 +475,2 @@

});
self.execute.apply(self, argumentsArray);
};

@@ -434,3 +481,3 @@ //jscs:enable jsDoc

//add promise support
Connection.prototype.insertOrUpdate = promiseHelper.promisify(Connection.prototype.insertOrUpdate, true);
Connection.prototype.insertOrUpdate = promiseHelper.promisify(Connection.prototype.insertOrUpdate);

@@ -493,12 +540,8 @@ /*eslint-disable valid-jsdoc*/

*/
Connection.prototype.release = function () {
Connection.prototype.release = function (options, callback) {
var self = this;
var argumentsArray = Array.prototype.slice.call(arguments);
var callback = argumentsArray.pop(); //since we promisify this function, last arg is always callback
var options;
if (argumentsArray.length === 1) {
options = argumentsArray[0];
if (options && (typeof options === 'function')) {
callback = options;
options = null;
}

@@ -700,10 +743,13 @@

*/
Connection.prototype.queryJSON = function () {
Connection.prototype.queryJSON = function (sql, bindParams, options, callback) {
var self = this;
var argumentsArray = Array.prototype.slice.call(arguments, 0);
var input = self.getExecuteArguments(sql, bindParams, options, callback);
var callback = argumentsArray.pop();
sql = input.sql;
bindParams = input.bindParams;
options = input.options;
callback = input.callback;
argumentsArray.push(function onExecute(error, jsRows) {
var onExecute = function (error, jsRows) {
if (error) {

@@ -739,5 +785,11 @@ callback(error);

}
});
};
self.query.apply(self, argumentsArray);
if (options) {
self.query(sql, bindParams, options, onExecute);
} else if (bindParams) {
self.query(sql, bindParams, onExecute);
} else {
self.query(sql, onExecute);
}
};

@@ -1190,6 +1242,22 @@ //jscs:enable jsDoc

* @private
* @param {Array} argumentsArray - Array of arguments provided in the insert/update functions
* @param {string} sql - The SQL to execute
* @param {object} [bindParams] - The bind parameters used to specify the values for the columns
* @param {object} [options] - Any execute options
* @returns {object} LOB information used for SQL execution processing
* @example
* ```js
* connection.modifyParams('INSERT INTO mylobs (id, clob_column1, blob_column2) VALUES (:id, EMPTY_CLOB(), EMPTY_BLOB())', { //no need to specify the RETURNING clause in the SQL
* id: 110,
* clobText1: 'some long clob string', //add bind variable with LOB column name and text content (need to map that name in the options)
* blobBuffer2: new Buffer('some blob content, can be binary...') //add bind variable with LOB column name and text content (need to map that name in the options)
* }, {
* autoCommit: true, //must be set to true in options to support auto commit after update is done, otherwise the auto commit will be false (oracledb.autoCommit is not checked)
* lobMetaInfo: { //if LOBs are provided, this data structure must be provided in the options object and the bind variables parameter must be an object (not array)
* clob_column1: 'clobText1', //map oracle column name to bind variable name
* blob_column2: 'blobBuffer2'
* }
* });
* ```
*/
Connection.prototype.modifyParams = function (argumentsArray) {
Connection.prototype.modifyParams = function (sql, bindParams, options) {
var lobMetaInfo;

@@ -1199,4 +1267,4 @@ var lobColumns;

var autoCommit;
if ((argumentsArray.length >= 3) && argumentsArray[2] && argumentsArray[2].lobMetaInfo) {
lobMetaInfo = argumentsArray[2].lobMetaInfo;
if (bindParams && options && options.lobMetaInfo) {
lobMetaInfo = options.lobMetaInfo;

@@ -1207,8 +1275,7 @@ lobColumns = Object.keys(lobMetaInfo);

if (lobColumns && lobColumns.length) {
autoCommit = argumentsArray[2].autoCommit;
argumentsArray[2].autoCommit = false; //must disable auto commit to support LOBs
autoCommit = options.autoCommit;
options.autoCommit = false; //must disable auto commit to support LOBs
var additionalReturningInfo = argumentsArray[2].returningInfo;
var additionalReturningInfo = options.returningInfo;
var bindVariables = argumentsArray[1];
lobData = {};

@@ -1224,7 +1291,7 @@

bindVariableName = lobMetaInfo[columnName];
lobValue = bindVariables[bindVariableName];
lobValue = bindParams[bindVariableName];
lobData[bindVariableName] = lobValue;
if (typeof lobValue === 'string') { //CLOB
bindVariables[bindVariableName] = {
bindParams[bindVariableName] = {
type: constants.clobType,

@@ -1234,3 +1301,3 @@ dir: constants.bindOut

} else { //BLOB
bindVariables[bindVariableName] = {
bindParams[bindVariableName] = {
type: constants.blobType,

@@ -1242,3 +1309,3 @@ dir: constants.bindOut

argumentsArray[0] = this.generateReturningClause(argumentsArray[0], lobMetaInfo, lobColumns, additionalReturningInfo);
sql = this.generateReturningClause(sql, lobMetaInfo, lobColumns, additionalReturningInfo);
}

@@ -1248,2 +1315,3 @@ }

return {
sql: sql,
lobMetaInfo: lobMetaInfo,

@@ -1250,0 +1318,0 @@ lobColumns: lobColumns,

@@ -17,2 +17,3 @@ 'use strict';

var functions = Object.keys(EventEmitter.prototype);
functions.forEach(function addProperty(property) {

@@ -19,0 +20,0 @@ object[property] = EventEmitter.prototype[property];

@@ -73,9 +73,5 @@ 'use strict';

*/
OracleDB.prototype.getConnection = function () {
OracleDB.prototype.getConnection = function (connectionAttributes, callback) {
var self = this;
var argumentsArray = Array.prototype.slice.call(arguments, 0);
var callback = argumentsArray.pop();
var wrapperCallback = function onConnection(error, connection) {

@@ -93,5 +89,4 @@ /*istanbul ignore else*/

};
argumentsArray.push(Connection.wrapOnConnection(wrapperCallback));
self.baseGetConnection.apply(self, argumentsArray);
self.baseGetConnection(connectionAttributes, Connection.wrapOnConnection(wrapperCallback));
};

@@ -120,14 +115,11 @@ //jscs:enable jsDoc

*/
OracleDB.prototype.createPool = function () {
OracleDB.prototype.createPool = function (poolAttributes, callback) {
var self = this;
var argumentsArray = Array.prototype.slice.call(arguments, 0);
var callback = argumentsArray.pop();
var poolAttributes;
if (argumentsArray && argumentsArray.length) {
poolAttributes = argumentsArray[0];
if ((!callback) && poolAttributes && (typeof poolAttributes === 'function')) {
callback = poolAttributes;
poolAttributes = null;
}
argumentsArray.push(function onPool(error, pool) {
self.baseCreatePool(poolAttributes, function onPool(error, pool) {
if ((!error) && pool) {

@@ -145,4 +137,2 @@ Pool.extend(pool, poolAttributes);

});
self.baseCreatePool.apply(self, argumentsArray);
};

@@ -149,0 +139,0 @@ //jscs:enable jsDoc

@@ -128,5 +128,10 @@ 'use strict';

//if last element is callback but undefined was provided
if (argumentsArray.length && (argumentsArray[argumentsArray.length - 1] === undefined)) {
argumentsArray.pop();
}
var continueRemove = true;
do {
if (argumentsArray.length && (argumentsArray[argumentsArray.length - 1] === undefined)) {
argumentsArray.pop();
} else {
continueRemove = false;
}
} while (continueRemove);

@@ -133,0 +138,0 @@ var minArgs = (options.callbackMinIndex || 0) + 1;

@@ -158,16 +158,13 @@ 'use strict';

* @param {Array} resultSet - The oracle ResultSet object
* @param {object} options - Any options
* @param {object} [options] - Any options
* @param {ResultSetReadStream} stream - The stream used to read the results from
*/
ResultSetReader.prototype.stream = function (columnNames, resultSet) {
ResultSetReader.prototype.stream = function (columnNames, resultSet, options, stream) {
var self = this;
var argumentsArray = Array.prototype.slice.call(arguments, 0);
if (!stream) {
stream = options;
options = null;
}
var stream = argumentsArray.pop();
var options;
if (argumentsArray.length >= 3) {
options = argumentsArray.pop();
}
options = options || {};

@@ -174,0 +171,0 @@

@@ -124,2 +124,3 @@ 'use strict';

/*eslint-disable valid-jsdoc*/
//jscs:disable jsDoc
/**

@@ -133,3 +134,14 @@ * Extends the oracledb library which from that point will allow fetching the modified

* @param {oracledb} oracledb - The oracledb library
* @example
* ```js
* //load the oracledb library
* var oracledb = require('oracledb');
*
* //load the simple oracledb
* var SimpleOracleDB = require('simple-oracledb');
*
* //modify the original oracledb library
* SimpleOracleDB.extend(oracledb);
* ```
*
* @also

@@ -144,3 +156,24 @@ *

* @param {Pool} pool - The oracledb pool instance
* @example
* ```js
* //load the simple oracledb
* var SimpleOracleDB = require('simple-oracledb');
*
* function myFunction(pool) {
* //modify the original oracledb pool instance
* SimpleOracleDB.extend(pool);
*
* //from this point connections fetched via pool.getConnection(...)
* //have access to additional functionality.
* pool.getConnection(function onConnection(error, connection) {
* if (error) {
* //handle error
* } else {
* //work with new capabilities or original oracledb capabilities
* connection.query(...);
* }
* });
* }
* ```
*
* @also

@@ -155,11 +188,20 @@ *

* @param {Connection} connection - The oracledb connection instance
* @example
* ```js
* //load the simple oracledb
* var SimpleOracleDB = require('simple-oracledb');
*
* function doSomething(connection, callback) {
* //modify the original oracledb connection instance
* SimpleOracleDB.extend(connection);
*
* //from this point the connection has access to additional functionality as well as the original oracledb capabilities.
* connection.query(...);
* }
* ```
*/
SimpleOracleDB.prototype.extend = function () {
SimpleOracleDB.prototype.extend = function (oracle) {
var self = this;
var extendArgs = Array.prototype.slice.call(arguments, 0);
if (extendArgs.length === 1) {
var oracle = extendArgs.pop();
if (oracle) {
if (oracle.createPool) {

@@ -195,2 +237,3 @@ OracleDB.extend(oracle);

};
//jscs:enable jsDoc
/*eslint-enable valid-jsdoc*/

@@ -197,0 +240,0 @@

{
"name": "simple-oracledb",
"version": "1.1.24",
"version": "1.1.25",
"description": "Extend capabilities of oracledb with simplified API for quicker development.",

@@ -5,0 +5,0 @@ "author": {

@@ -102,6 +102,6 @@ # {"gitdown": "gitinfo", "name": "name"}

if (error) {
//handle error
//handle error
} else {
//work with new capabilities or original oracledb capabilities
connection.query(...);
//work with new capabilities or original oracledb capabilities
connection.query(...);
}

@@ -108,0 +108,0 @@ });

@@ -102,6 +102,6 @@ # simple-oracledb

if (error) {
//handle error
//handle error
} else {
//work with new capabilities or original oracledb capabilities
connection.query(...);
//work with new capabilities or original oracledb capabilities
connection.query(...);
}

@@ -870,3 +870,3 @@ });

| ----------- | ------- | ----------- |
| 2016-10-06 | v1.1.24 | Maintenance |
| 2016-10-06 | v1.1.25 | Maintenance |
| 2016-08-15 | v1.1.2 | Added 'metadata' event for connection.query with streaming |

@@ -873,0 +873,0 @@ | 2016-08-15 | v1.1.1 | Maintenance |

@@ -60,3 +60,3 @@ 'use strict';

var output = oracledb.getConnection(function (error, connection) {
var output = oracledb.getConnection({}, function (error, connection) {
assert.isNull(error);

@@ -83,7 +83,7 @@ assert.isDefined(connection);

OracleDB.extend(oracledb);
oracledb.baseGetConnection = function (callback) {
oracledb.baseGetConnection = function (attrs, callback) {
callback(new Error('test'));
};
oracledb.getConnection(function (error, connection) {
oracledb.getConnection({}, function (error, connection) {
assert.isDefined(error);

@@ -103,3 +103,3 @@ assert.isUndefined(connection);

oracledb.getConnection().then(function (connection) {
oracledb.getConnection({}).then(function (connection) {
assert.isDefined(connection);

@@ -126,7 +126,7 @@ assert.isTrue(connection.simplified);

oracledb.baseGetConnection = function (callback) {
oracledb.baseGetConnection = function (attrs, callback) {
callback(new Error('test'));
};
oracledb.getConnection().then(function () {
oracledb.getConnection({}).then(function () {
assert.fail();

@@ -147,7 +147,7 @@ }, function (error) {

oracledb.baseGetConnection = function (callback) {
oracledb.baseGetConnection = function (attrs, callback) {
callback(new Error('test'));
};
oracledb.getConnection().then(function () {
oracledb.getConnection({}).then(function () {
assert.fail();

@@ -173,3 +173,3 @@ }).catch(function (error) {

try {
oracledb.getConnection().then(function () {
oracledb.getConnection({}).then(function () {
assert.fail();

@@ -176,0 +176,0 @@ }).catch(function () {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc