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 0.0.4 to 0.0.5

81

docs/api.md

@@ -51,3 +51,6 @@ ## Classes

* [#insert([params])](#Connection+insert)
* [#update([params])](#Connection+update)
* [#release([callback])](#Connection+release)
* [#modifyParams(argumentsArray)](#Connection+modifyParams) ⇒ <code>object</code> ℗
* [#createCallback(callback, [output])](#Connection+createCallback) ⇒ <code>function</code> ℗
* _static_

@@ -124,2 +127,31 @@ * [.extend(connection)](#Connection.extend)

```
<a name="Connection+update"></a>
### Connection#update([params])
Provides simpler interface than the original oracledb connection.execute function to enable simple update invocation with LOB support.<br>
The callback output will be the same as oracledb conection.execute.<br>
All LOBs will be written to the DB via streams and only after all LOBs are written the callback will be called.<br>
The function arguments used to execute the 'update' are exactly as defined in the oracledb connection.execute function, however the options are mandatory.
**Access:** public
| Param | Type | Description |
| --- | --- | --- |
| [params] | <code>\*</code> | See oracledb connection.execute function |
**Example**
```js
connection.update('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)
}, {
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...
});
```
<a name="Connection+release"></a>

@@ -150,2 +182,27 @@ ### Connection#release([callback])

```
<a name="Connection+modifyParams"></a>
### Connection#modifyParams(argumentsArray) ⇒ <code>object</code> ℗
Internal function used to modify the INSERT/UPDATE SQL arguments.<br>
This function will add the RETURNING clause to the SQL to support LOBs modification after the INSERT/UPDATE finished.<br>
In addition it will modify the bind variables to specify the OUT bind to enable access to the LOB object.
**Returns**: <code>object</code> - LOB information used for SQL execution processing
**Access:** private
| Param | Type | Description |
| --- | --- | --- |
| argumentsArray | <code>Array</code> | Array of arguments provided in the insert/update functions |
<a name="Connection+createCallback"></a>
### Connection#createCallback(callback, [output]) ⇒ <code>function</code> ℗
Internal function used to wrap the original callback.
**Returns**: <code>function</code> - A wrapper callback
**Access:** private
| Param | Type | Description |
| --- | --- | --- |
| callback | <code>function</code> | The callback function to invoke |
| [output] | <code>object</code> | Optional output to pass to the callback |
<a name="Connection.extend"></a>

@@ -290,2 +347,7 @@ ### Connection.extend(connection)

**Author:** Sagie Gur-Ari
* [RecordWriter](#RecordWriter) : <code>object</code>
* [.write(outBindings, lobData, callback)](#RecordWriter.write)
* [.writeMultiple(outBindings, lobData, callback)](#RecordWriter.writeMultiple)
<a name="RecordWriter.write"></a>

@@ -304,2 +366,15 @@ ### RecordWriter.write(outBindings, lobData, callback)

<a name="RecordWriter.writeMultiple"></a>
### RecordWriter.writeMultiple(outBindings, lobData, callback)
Writes all LOBs columns via out bindings of the INSERT/UPDATE command with support of multiple rows.
**Kind**: static method of <code>[RecordWriter](#RecordWriter)</code>
**Access:** public
| Param | Type | Description |
| --- | --- | --- |
| outBindings | <code>object</code> | The output bindings of the INSERT/UPDATE result |
| lobData | <code>object</code> | The LOB data holder (key column name, value column value) |
| callback | <code>[AsyncCallback](#AsyncCallback)</code> | called when the row is fully written to or in case of an error |
<a name="ResultSetReader"></a>

@@ -433,7 +508,7 @@ ## ResultSetReader : <code>object</code>

* [Stream](#Stream) : <code>object</code>
* [.readFully(readableStream, binary, callback)](#Stream.readFully)
* [.read(readableStream, binary, callback)](#Stream.read)
* [.write(writableStream, data, callback)](#Stream.write)
<a name="Stream.readFully"></a>
### Stream.readFully(readableStream, binary, callback)
<a name="Stream.read"></a>
### Stream.read(readableStream, binary, callback)
Reads all data from the provided stream.

@@ -440,0 +515,0 @@

175

lib/connection.js

@@ -116,7 +116,120 @@ 'use strict';

var lobInfo = this.modifyParams(argumentsArray);
var lobColumns = lobInfo.lobColumns;
var lobData = lobInfo.lobData;
var callback = argumentsArray.pop();
argumentsArray.push(function onExecute(error, results) {
var wrapper = self.createCallback(callback, results);
if (error || (!results)) {
wrapper(error);
} else if ((results.rowsAffected === 1) && lobColumns && lobColumns.length) {
recordWriter.write(results.outBinds, lobData, wrapper);
} else {
wrapper(error);
}
});
self.execute.apply(self, argumentsArray);
};
/**
* Provides simpler interface than the original oracledb connection.execute function to enable simple update invocation with LOB support.<br>
* The callback output will be the same as oracledb conection.execute.<br>
* All LOBs will be written to the DB via streams and only after all LOBs are written the callback will be called.<br>
* The function arguments used to execute the 'update' are exactly as defined in the oracledb connection.execute function, however the options are mandatory.
*
* @function
* @memberof! Connection
* @public
* @param {*} [params] - See oracledb connection.execute function
* @example
* ```js
* connection.update('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)
* }, {
* 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.update = function () {
var self = this;
var argumentsArray = Array.prototype.slice.call(arguments, 0);
var lobInfo = this.modifyParams(argumentsArray);
var lobColumns = lobInfo.lobColumns;
var lobData = lobInfo.lobData;
var callback = argumentsArray.pop();
argumentsArray.push(function onExecute(error, results) {
var wrapper = self.createCallback(callback, results);
if (error || (!results)) {
wrapper(error);
} else if ((results.rowsAffected >= 1) && lobColumns && lobColumns.length) {
recordWriter.writeMultiple(results.outBinds, lobData, wrapper);
} else {
wrapper();
}
});
self.execute.apply(self, argumentsArray);
};
/**
* This function modifies the existing connection.release function by enabling the input
* callback to be an optional parameter.<br>
* Since there is no real way to release a connection that fails to be released, all that you can do in the callback
* is just log the error and continue.<br>
* Therefore this function allows you to ignore the need to pass a callback and makes it as an optional parameter.
*
* @function
* @memberof! Connection
* @public
* @param {function} [callback] - An optional release callback function (see oracledb docs)
* @example
* ```js
* connection.release(); //no callback needed
*
* //still possible to call with a release callback function
* connection.release(function onRelease(error) {
* if (error) {
* //now what?
* }
* });
* ```
*/
Connection.prototype.release = function (callback) {
callback = callback || this.noop;
this.baseRelease(callback);
};
/**
* Internal function used to modify the INSERT/UPDATE SQL arguments.<br>
* This function will add the RETURNING clause to the SQL to support LOBs modification after the INSERT/UPDATE finished.<br>
* In addition it will modify the bind variables to specify the OUT bind to enable access to the LOB object.
*
* @function
* @memberof! Connection
* @private
* @param {Array} argumentsArray - Array of arguments provided in the insert/update functions
* @returns {object} LOB information used for SQL execution processing
*/
Connection.prototype.modifyParams = function (argumentsArray) {
var lobMetaInfo;
var lobColumns;
var lobData;
if (argumentsArray.length === 4) {
lobMetaInfo = argumentsArray[2].lobMetaInfo || {};
if ((argumentsArray.length === 4) && argumentsArray[2] && argumentsArray[2].lobMetaInfo) {
lobMetaInfo = argumentsArray[2].lobMetaInfo;

@@ -178,49 +291,27 @@ lobColumns = Object.keys(lobMetaInfo);

var callback = argumentsArray.pop();
argumentsArray.push(function onExecute(error, results) {
if (error || (!results)) {
callback(error, results);
} else if ((results.rowsAffected === 1) && lobColumns && lobColumns.length) {
recordWriter.write(results.outBinds, lobData, function onWrite(writeError) {
if (writeError) {
callback(writeError);
} else {
callback(null, results);
}
});
} else {
callback(error, results);
}
});
self.execute.apply(self, argumentsArray);
return {
lobMetaInfo: lobMetaInfo,
lobColumns: lobColumns,
lobData: lobData
};
};
/**
* This function modifies the existing connection.release function by enabling the input
* callback to be an optional parameter.<br>
* Since there is no real way to release a connection that fails to be released, all that you can do in the callback
* is just log the error and continue.<br>
* Therefore this function allows you to ignore the need to pass a callback and makes it as an optional parameter.
* Internal function used to wrap the original callback.
*
* @function
* @memberof! Connection
* @public
* @param {function} [callback] - An optional release callback function (see oracledb docs)
* @example
* ```js
* connection.release(); //no callback needed
*
* //still possible to call with a release callback function
* connection.release(function onRelease(error) {
* if (error) {
* //now what?
* }
* });
* ```
* @private
* @param {function} callback - The callback function to invoke
* @param {object} [output] - Optional output to pass to the callback
* @returns {function} A wrapper callback
*/
Connection.prototype.release = function (callback) {
callback = callback || this.noop;
this.baseRelease(callback);
Connection.prototype.createCallback = function (callback, output) {
return function onCallback(error) {
if (error) {
callback(error);
} else {
callback(null, output);
}
};
};

@@ -227,0 +318,0 @@

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

var binary = (field.type === constants.blobType);
stream.readFully(field, binary, callback);
stream.read(field, binary, callback);
} else {

@@ -40,0 +40,0 @@ callback(new Error('Unsupported type provided: ' + field));

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

*/
write: function read(outBindings, lobData, callback) {
write: function write(outBindings, lobData, callback) {
var functions = [];

@@ -41,3 +41,33 @@ var bindVariableNames = Object.keys(lobData);

async.parallel(functions, callback);
},
/**
* Writes all LOBs columns via out bindings of the INSERT/UPDATE command with support of multiple rows.
*
* @function
* @memberof! RecordWriter
* @public
* @param {object} outBindings - The output bindings of the INSERT/UPDATE result
* @param {object} lobData - The LOB data holder (key column name, value column value)
* @param {AsyncCallback} callback - called when the row is fully written to or in case of an error
*/
writeMultiple: function writeMultiple(outBindings, lobData, callback) {
var functions = [];
var bindVariableNames = Object.keys(lobData);
bindVariableNames.forEach(function handleColumn(bindVariableName) {
var value = lobData[bindVariableName];
if (value && bindVariableName && outBindings[bindVariableName] && outBindings[bindVariableName].length) {
var lobStreams = outBindings[bindVariableName];
lobStreams.forEach(function (lobStream) {
functions.push(function writeField(asyncCallback) {
stream.write(lobStream, value, asyncCallback);
});
});
}
});
async.parallel(functions, callback);
}
};

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

*/
readAllRows: function readNextRows(columnNames, resultSet, callback, jsRowsBuffer) {
readAllRows: function readAllRows(columnNames, resultSet, callback, jsRowsBuffer) {
var self = this;

@@ -47,0 +47,0 @@

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

*/
readFully: function readFully(readableStream, binary, callback) {
read: function read(readableStream, binary, callback) {
if (!binary) {

@@ -23,0 +23,0 @@ readableStream.setEncoding('utf8');

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,2 +13,3 @@ # simple-oracledb

* [insert](#usage-insert)
* [update](#usage-update)
* [release](#usage-release)

@@ -136,2 +137,25 @@ * [Installation](#installation)

<a name="usage-update"></a>
## 'connection.update(sql, bindVariables, options, callback)'
Provides simpler interface than the original oracledb connection.execute function to enable simple update invocation with LOB support.<br>
The callback output will be the same as oracledb conection.execute.<br>
All LOBs will be written to the DB via streams and only after all LOBs are written the callback will be called.<br>
The function arguments used to execute the 'update' are exactly as defined in the oracledb connection.execute function, however the options are mandatory.
```js
connection.update('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)
}, {
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...
});
```
<a name="usage-release"></a>

@@ -180,2 +204,3 @@ ## 'connection.release([callback])'

| ----------- | ------- | ----------- |
| 2015-10-18 | v0.0.5 | Added connection.update support |
| 2015-10-18 | v0.0.4 | Added connection.insert support |

@@ -182,0 +207,0 @@ | 2015-10-16 | v0.0.3 | Maintenance |

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

var pool;
var testPool;
var initDB = function (tableName, data, cb) {

@@ -78,3 +78,3 @@ oracledb.getConnection(connAttrs, function (connErr, connection) {

}
})
});
});

@@ -86,23 +86,21 @@ });

if (asynErr) {
console.error(err);
console.error(asynErr);
assert.fail('UNABLE TO CREATE DB POOL.');
} else if (rerr) {
console.error('release error: ', rerr);
} else if (testPool) {
cb(testPool);
} else {
if (pool) {
cb(pool);
} else {
oracledb.createPool(connAttrs, function (perr, newPool) {
if (perr) {
console.error(perr);
assert.fail('UNABLE TO CREATE DB POOL.');
} else {
pool = newPool;
cb(pool)
}
});
}
oracledb.createPool(connAttrs, function (perr, newPool) {
if (perr) {
console.error(perr);
assert.fail('UNABLE TO CREATE DB POOL.');
} else {
testPool = newPool;
cb(testPool);
}
});
}
});
})
});
}

@@ -116,22 +114,2 @@ });

describe('query', function () {
var columnNames = [
{
name: 'COL1'
},
{
name: 'COL2'
}, {
name: 'COL3'
},
{
name: 'COL4'
},
{
name: 'LOB1'
},
{
name: 'LOB2'
}
];
it('error', function (done) {

@@ -322,23 +300,2 @@ var table = 'TEST_ORA1';

describe('insert', function () {
var columnNames = [
{
name: 'COL1'
},
{
name: 'COL2'
},
{
name: 'COL3'
},
{
name: 'COL4'
},
{
name: 'LOB1'
},
{
name: 'LOB2'
}
];
it('error', function (done) {

@@ -374,3 +331,15 @@ var table = 'TEST_ORA_INST1';

end(done, connection);
connection.query('SELECT * FROM ' + table, [], {
resultSet: false
}, function (queryError, jsRows) {
assert.isNull(queryError);
assert.deepEqual([
{
COL1: 'test',
COL2: 123
}
], jsRows);
end(done, connection);
});
});

@@ -405,3 +374,17 @@ });

end(done, connection);
connection.query('SELECT * FROM ' + table, [], {
resultSet: false
}, function (queryError, jsRows) {
assert.isNull(queryError);
assert.deepEqual([
{
COL1: 'test',
COL2: 123,
LOB1: longClobText,
LOB2: new Buffer('blob text here')
}
], jsRows);
end(done, connection);
});
});

@@ -408,0 +391,0 @@ });

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

var lobsWritten;
var lob1 = helper.createCLOB();

@@ -433,3 +432,4 @@ lob1.testData = 'clob text';

lob2.testData = 'second clob text';
lob2.end = function (data, encoding, cb) {
lob2.end = function () {
var cb = Array.prototype.pop.call(arguments);
lob2.emit('error', new Error('lob test error'));

@@ -525,2 +525,237 @@

describe('update', function () {
it('no lobs', function (done) {
var connection = {};
Connection.extend(connection);
connection.execute = function (sql, bindVars, options, callback) {
assert.equal(sql, 'UPDATE nolobs SET id = :id1, id2 = :id2');
assert.deepEqual(bindVars, {
id1: 1,
id2: 2
});
assert.deepEqual(options, {
lobMetaInfo: {}
});
callback(null, {
rowsAffected: 1,
outBinds: {}
});
};
connection.update('UPDATE nolobs SET id = :id1, id2 = :id2', {
id1: 1,
id2: 2
}, {
lobMetaInfo: {}
}, function (error, results) {
assert.isNull(error);
assert.equal(results.rowsAffected, 1);
done();
});
});
it('multiple lobs', function (done) {
var connection = {};
Connection.extend(connection);
var lobsWritten = 0;
connection.execute = function (sql, bindVars, options, callback) {
assert.equal(sql, 'UPDATE mylobs SET id = :id, c1 = EMPTY_CLOB(), c2 = EMPTY_CLOB(), b = EMPTY_CLOB() RETURNING c1, c2, b INTO :lob1, :lob2, :lob3');
assert.deepEqual(bindVars, {
id: 1,
lob1: {
type: constants.clobType,
dir: constants.bindOut
},
lob2: {
type: constants.clobType,
dir: constants.bindOut
},
lob3: {
type: constants.blobType,
dir: constants.bindOut
}
});
assert.deepEqual(options, {
lobMetaInfo: {
c1: 'lob1',
c2: 'lob2',
b: 'lob3'
}
});
var lob1 = helper.createCLOB();
lob1.testData = 'clob text';
lob1.on('end', function () {
lobsWritten++;
});
var lob2 = helper.createCLOB();
lob2.testData = 'second clob text';
lob2.on('end', function () {
lobsWritten++;
});
var lob3 = helper.createBLOB();
lob3.testData = 'binary data';
lob3.on('end', function () {
lobsWritten++;
});
callback(null, {
rowsAffected: 3,
outBinds: {
lob1: [lob1, lob1, lob1],
lob2: [lob2, lob2, lob2],
lob3: [lob3, lob3, lob3]
}
});
};
connection.update('UPDATE mylobs SET id = :id, c1 = EMPTY_CLOB(), c2 = EMPTY_CLOB(), b = EMPTY_CLOB()', {
id: 1,
lob1: 'clob text',
lob2: 'second clob text',
lob3: new Buffer('binary data')
}, {
lobMetaInfo: {
c1: 'lob1',
c2: 'lob2',
b: 'lob3'
}
}, function (error, results) {
assert.isNull(error);
assert.equal(results.rowsAffected, 3);
assert.equal(lobsWritten, 9);
done();
});
});
it('error while writing lobs', function (done) {
var connection = {};
Connection.extend(connection);
connection.execute = function (sql, bindVars, options, callback) {
assert.equal(sql, 'UPDATE mylobs SET id = :id, c1 = EMPTY_CLOB(), c2 = EMPTY_CLOB(), b = EMPTY_CLOB() RETURNING c1, c2, b INTO :lob1, :lob2, :lob3');
assert.deepEqual(bindVars, {
id: 1,
lob1: {
type: constants.clobType,
dir: constants.bindOut
},
lob2: {
type: constants.clobType,
dir: constants.bindOut
},
lob3: {
type: constants.blobType,
dir: constants.bindOut
}
});
assert.deepEqual(options, {
lobMetaInfo: {
c1: 'lob1',
c2: 'lob2',
b: 'lob3'
}
});
var lob1 = helper.createCLOB();
lob1.testData = 'clob text';
var lob2 = helper.createCLOB();
lob2.testData = 'second clob text';
lob2.end = function () {
var cb = Array.prototype.pop.call(arguments);
lob2.emit('error', new Error('lob test error'));
setTimeout(cb, 10);
};
var lob3 = helper.createBLOB();
lob3.testData = 'binary data';
callback(null, {
rowsAffected: 3,
outBinds: {
lob1: [lob1, lob1, lob1],
lob2: [lob2, lob2, lob2],
lob3: [lob3, lob3, lob3]
}
});
};
connection.update('UPDATE mylobs SET id = :id, c1 = EMPTY_CLOB(), c2 = EMPTY_CLOB(), b = EMPTY_CLOB()', {
id: 1,
lob1: 'clob text',
lob2: 'second clob text',
lob3: new Buffer('binary data')
}, {
lobMetaInfo: {
c1: 'lob1',
c2: 'lob2',
b: 'lob3'
}
}, function (error, results) {
assert.isDefined(error);
assert.equal(error.message, 'lob test error');
assert.isUndefined(results);
done();
});
});
it('error on execute', function (done) {
var connection = {};
Connection.extend(connection);
connection.execute = function (sql, bindVars, options, callback) {
assert.equal(sql, 'UPDATE mylobs SET id = :id, c1 = EMPTY_CLOB(), c2 = EMPTY_CLOB(), b = EMPTY_CLOB() RETURNING c1, c2, b INTO :lob1, :lob2, :lob3');
assert.deepEqual(bindVars, {
id: 1,
lob1: {
type: constants.clobType,
dir: constants.bindOut
},
lob2: {
type: constants.clobType,
dir: constants.bindOut
},
lob3: {
type: constants.blobType,
dir: constants.bindOut
}
});
assert.deepEqual(options, {
lobMetaInfo: {
c1: 'lob1',
c2: 'lob2',
b: 'lob3'
}
});
callback(new Error('execute error test'));
};
connection.update('UPDATE mylobs SET id = :id, c1 = EMPTY_CLOB(), c2 = EMPTY_CLOB(), b = EMPTY_CLOB()', {
id: 1,
lob1: 'clob text',
lob2: 'second clob text',
lob3: new Buffer('binary data')
}, {
lobMetaInfo: {
c1: 'lob1',
c2: 'lob2',
b: 'lob3'
}
}, function (error, results) {
assert.isDefined(error);
assert.equal(error.message, 'execute error test');
assert.isUndefined(results);
done();
});
});
});
describe('release', function () {

@@ -527,0 +762,0 @@ it('callback provided', function (done) {

@@ -167,2 +167,160 @@ 'use strict';

});
describe('writeMultiple Tests', function () {
it('string test', function (done) {
var writable = new EventEmitter();
writable.end = function (data, encoding, callback) {
assert.equal(data, 'TEST STRING DATA');
assert.equal(encoding, 'utf8');
assert.isFunction(callback);
callback();
};
recordWriter.writeMultiple({
LOBCOL1: [writable, writable]
}, {
BIND1: 'TEST STRING DATA'
}, function (error) {
assert.isNull(error);
assert.equal(0, writable.listeners('error').length);
done();
});
});
it('Buffer test', function (done) {
var writable = new EventEmitter();
writable.end = function (data, callback) {
assert.deepEqual(data, new Buffer('TEST STRING DATA'));
assert.isFunction(callback);
callback();
};
recordWriter.writeMultiple({
LOBCOL1: [writable, writable]
}, {
BIND1: new Buffer('TEST STRING DATA')
}, function (error) {
assert.isNull(error);
assert.equal(0, writable.listeners('error').length);
done();
});
});
it('null data test', function (done) {
var writable = new EventEmitter();
writable.end = function () {
assert.fail();
};
recordWriter.writeMultiple({
LOBCOL1: [writable, writable]
}, {
BIND1: null
}, function (error) {
assert.isNull(error);
assert.equal(0, writable.listeners('error').length);
done();
});
});
it('undefined data test', function (done) {
var writable = new EventEmitter();
writable.end = function () {
assert.fail();
};
recordWriter.writeMultiple({
LOBCOL1: [writable, writable]
}, {
BIND1: null
}, function (error) {
assert.isNull(error);
assert.equal(0, writable.listeners('error').length);
done();
});
});
it('empty array outbindings test', function (done) {
recordWriter.writeMultiple({
LOBCOL1: []
}, {
BIND1: 'TEST STRING DATA'
}, function (error) {
assert.isNull(error);
done();
});
});
it('undefined outbindings test', function (done) {
recordWriter.writeMultiple({}, {
BIND1: 'TEST STRING DATA'
}, function (error) {
assert.isNull(error);
done();
});
});
it('multiple array outbindings test', function (done) {
recordWriter.writeMultiple({
LOBCOL1: [{}, {}]
}, {
BIND1: 'TEST STRING DATA'
}, function (error) {
assert.isNull(error);
done();
});
});
it('multiple columns test', function (done) {
var lobsWritten = 0;
var writable1 = new EventEmitter();
writable1.end = function (data, encoding, callback) {
assert.equal(data, 'TEST STRING DATA');
assert.equal(encoding, 'utf8');
assert.isFunction(callback);
lobsWritten++;
callback();
};
var writable2 = new EventEmitter();
writable2.end = function (data, callback) {
assert.equal(data, 'TEST STRING DATA');
assert.isFunction(callback);
lobsWritten++;
callback();
};
recordWriter.writeMultiple({
BIND1: [writable1, writable1, writable1, writable1],
BIND2: [writable1, writable1, writable1, writable1],
BIND3: [writable2, writable2, writable2, writable2],
BIND4: [writable2, writable2, writable2, writable2]
}, {
BIND1: 'TEST STRING DATA',
BIND2: 'TEST STRING DATA',
BIND3: new Buffer('TEST STRING DATA'),
BIND4: new Buffer('TEST STRING DATA')
}, function (error) {
assert.isNull(error);
assert.equal(0, writable1.listeners('error').length);
assert.equal(lobsWritten, 16);
done();
});
});
});
});

@@ -10,4 +10,4 @@ 'use strict';

describe('stream Tests', function () {
describe('readFully Tests', function () {
it('readFully valid test', function (done) {
describe('read Tests', function () {
it('read valid test', function (done) {
var testStream = new EventEmitter();

@@ -18,3 +18,3 @@ testStream.setEncoding = function (encoding) {

stream.readFully(testStream, false, function (error, data) {
stream.read(testStream, false, function (error, data) {
assert.isNull(error);

@@ -41,3 +41,3 @@ assert.equal(data, 'first line\nsecond line, second part.');

it('readFully error test', function (done) {
it('read error test', function (done) {
var testStream = new EventEmitter();

@@ -48,3 +48,3 @@ testStream.setEncoding = function (encoding) {

stream.readFully(testStream, false, function (error, data) {
stream.read(testStream, false, function (error, data) {
assert.isDefined(error);

@@ -70,3 +70,3 @@ assert.isUndefined(data);

it('readFully close test', function (done) {
it('read close test', function (done) {
var testStream = new EventEmitter();

@@ -77,3 +77,3 @@ testStream.setEncoding = function (encoding) {

stream.readFully(testStream, false, function (error, data) {
stream.read(testStream, false, function (error, data) {
assert.isNull(error);

@@ -181,3 +181,4 @@ assert.equal(data, 'My Data.');

var writable = new EventEmitter();
writable.end = function (data, encoding, callback) {
writable.end = function () {
var callback = Array.prototype.pop.call(arguments);
writable.emit('error', new Error('test'));

@@ -184,0 +185,0 @@

Sorry, the diff of this file is not supported yet

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