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

oracledb

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oracledb - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

test/plsqlBinding.js

20

CHANGELOG.md
# Change Log
## node-oracledb v1.6.0 (30 Jan 2016)
- Added support for binding PL/SQL Collection Associative Array
(Index-by) types containing numbers and strings.
- Fixed a LOB problem causing an uncaught error to be generated.
- Removed the 'close' event that was incorrectly emitted for LOB Writable
Streams. The Node.js Streams documentation specifies it only for
Readable Streams.
- Updated the LOB examples to show connection release.
- Updated README so first-time users see pre-requisites earlier.
- Extended the OS X install instructions with a way to install that doesn't
need root access for Instant Client 11.2 on El Capitan.
- Added RPATH link option when building on OS X in preparation for future client.
## node-oracledb v1.5.0 (21 Dec 2015)

@@ -4,0 +24,0 @@

21

lib/oracledb.js

@@ -1,2 +0,2 @@

/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */
/* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. */

@@ -65,4 +65,5 @@ /******************************************************************************

if (err) {
self.close();
self.close(); // Ignore if any error occurs during close
self.emit('error', err);
self.emit('close');
return;

@@ -73,3 +74,7 @@ }

process.nextTick(function() {
self.close();
err = self.close();
if (err) {
self.emit('error', err);
}
self.emit('close');
});

@@ -89,3 +94,3 @@ }

if (err) {
self.close();
self.close(); // Ignore if any error occurs during close
return cb(err);

@@ -106,6 +111,10 @@ }

if (self.iLob != null) {
self.iLob.release();
try {
self.iLob.release();
} catch(err) {
self.iLob = null;
return err;
}
self.iLob = null;
}
self.emit('close');
}

@@ -112,0 +121,0 @@

{
"name": "oracledb",
"version": "1.5.0",
"version": "1.6.0",
"description": "Oracle Database driver by Oracle Corp.",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -1,4 +0,4 @@

# node-oracledb version 1.5
# node-oracledb version 1.6
## <a name="about"></a> 1. About node-oracledb
## <a name="about"></a> About node-oracledb

@@ -41,2 +41,19 @@ The node-oracledb add-on for Node.js powers high performance Oracle Database applications.

## <a name="installation"></a> Installation
Prerequisites:
- [Python 2.7](https://www.python.org/downloads/)
- C Compiler with support for C++ 11 (Xcode, gcc, Visual Studio or similar)
- The small, free [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-100365.html) libraries if your database is remote. Or use a locally installed database such as the free [Oracle XE](http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html) release
- Set `OCI_LIB_DIR` and `OCI_INC_DIR` during installation if the Oracle libraries and headers are in a non-default location
Run `npm install oracledb` to install from the [NPM registry](https://www.npmjs.com/package/oracledb).
See [INSTALL](https://github.com/oracle/node-oracledb/tree/master/INSTALL.md) for details.
## <a name="examples"></a> Examples
There are examples in the [examples](https://github.com/oracle/node-oracledb/tree/master/examples) directory.
### A simple query example:

@@ -76,32 +93,17 @@

## <a name="examples"></a> 2. Examples
## <a name="doc"></a> Documentation
There are examples in the [examples](https://github.com/oracle/node-oracledb/tree/master/examples) directory.
## <a name="installation"></a> 3. Installation
The basic install steps are:
- Install the small, free [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-100365.html) libraries if your database is remote. Or use a locally installed database such as the free [Oracle XE](http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html) release.
- Run `npm install oracledb` to install from the [NPM registry](https://www.npmjs.com/package/oracledb).
See [INSTALL](https://github.com/oracle/node-oracledb/tree/master/INSTALL.md) for details.
## <a name="doc"></a> 4. Documentation
See [Documentation for the Oracle Database Node.js Add-on](https://github.com/oracle/node-oracledb/tree/master/doc/api.md).
## <a name="changes"></a> 5. Changes
## <a name="changes"></a> Changes
See [CHANGELOG](https://github.com/oracle/node-oracledb/tree/master/CHANGELOG.md)
*Note* there were two small, backward-compatibility breaking attribute name changes in node-oracledb 0.5.
## <a name="testing"></a> Testsuite
## <a name="testing"></a> 6. Testsuite
To run the included testsuite see [test/README](https://github.com/oracle/node-oracledb/tree/master/test/README.md).
## <a name="contrib"></a> 7. Contributing
## <a name="contrib"></a> Contributing
Node-oracledb is an open source project. See
Node-oracledb is an open source project. See
[CONTRIBUTING](https://github.com/oracle/node-oracledb/tree/master/CONTRIBUTING.md)

@@ -112,5 +114,5 @@ for details.

## <a name="license"></a> 8. License
## <a name="license"></a> License
Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.

@@ -117,0 +119,0 @@ You may not use the identified files except in compliance with the Apache

@@ -29,2 +29,5 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */

*
* When the types of bind out variables are not STRING or BUFFER,
* maxSize option will not take effect.
*
* NUMBERING RULE

@@ -42,2 +45,3 @@ * Test numbers follow this numbering rule:

var should = require('should');
var stream = require('stream');
var dbConfig = require('./dbConfig.js');

@@ -56,3 +60,3 @@ var assist = require('./dataTypeAssist.js');

var tableName = "oracledb_myclobs";
before('get one connection, prepare table', function(done) {

@@ -62,7 +66,7 @@ async.series([

oracledb.getConnection(
credential,
credential,
function(err, conn) {
should.not.exist(err);
connection = conn;
callback();
should.not.exist(err);
connection = conn;
callback();
}

@@ -73,16 +77,6 @@ );

assist.createTable(connection, tableName, callback);
},
function(callback) {
connection.execute(
"INSERT INTO oracledb_myclobs (num, content) VALUES (1, 'abcdefghijklmnopqrstuvwxyz')",
function(err) {
should.not.exist(err);
callback();
}
);
}
], done);
}) // before
})
after('release connection', function(done) {

@@ -106,35 +100,120 @@ async.series([

], done);
}) // after
})
describe('60.1 BIND OUT as STRING', function() {
before('insert data', function(done) {
connection.execute(
"INSERT INTO oracledb_myclobs (num, content) VALUES (1, 'abcdefghijklmnopqrstuvwxyz')",
function(err) {
should.not.exist(err);
done();
}
);
}) // before
it('60.1.1 PL/SQL OUT CLOB parameters can also be bound as STRING', function(done) {
connection.execute(
"BEGIN SELECT content INTO :cbv FROM oracledb_myclobs WHERE num = :id; END;",
{
id: 1,
cbv: { type: oracledb.STRING, dir: oracledb.BIND_OUT}
},
function(err, result) {
should.not.exist(err);
(result.outBinds.cbv).should.be.a.String;
(result.outBinds.cbv).should.eql('abcdefghijklmnopqrstuvwxyz');
done();
}
);
}) // 60.1.1
it('60.1 PL/SQL OUT CLOB parameters can also be bound as STRING', function(done) {
connection.execute(
"BEGIN SELECT content INTO :cbv FROM oracledb_myclobs WHERE num = :id; END;",
{
id: 1,
cbv: { type: oracledb.STRING, dir: oracledb.BIND_OUT}
},
function(err, result) {
should.not.exist(err);
(result.outBinds.cbv).should.be.a.String;
(result.outBinds.cbv).should.eql('abcdefghijklmnopqrstuvwxyz');
done();
}
);
})
it('60.1.2 The returned length is limited to the maximum size', function(done) {
connection.execute(
"BEGIN SELECT content INTO :cbv FROM oracledb_myclobs WHERE num = :id; END;",
{
id: 1,
cbv: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 5 }
},
function(err, result) {
should.exist(err);
(err.message).should.startWith('ORA-06502'); // PL/SQL: numeric or value error
done();
}
);
}) // 60.1.2
}) // 60.1
it('60.2 The returned length is limited to the maximum size', function(done) {
connection.execute(
"BEGIN SELECT content INTO :cbv FROM oracledb_myclobs WHERE num = :id; END;",
{
id: 1,
cbv: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 5 }
},
function(err, result) {
should.exist(err);
(err.message).should.startWith('ORA-06502'); // PL/SQL: numeric or value error
done();
}
);
})
describe('60.2 BIND OUT as CLOB', function() {
var dataLength = 1000000;
var rawData = assist.createCharString(dataLength);
it('60.2.1 maxSize option does not take effect when bind out type is clob', function(done) {
async.series([
function doInsert(callback) {
connection.execute(
"INSERT INTO " + tableName + " VALUES (2, EMPTY_CLOB()) RETURNING content INTO :lobbv",
{ lobbv: {type: oracledb.CLOB, dir: oracledb.BIND_OUT} },
{ autoCommit: false },
function(err, result) {
should.not.exist(err);
var lob = result.outBinds.lobbv[0];
lob.on('error', function(err) {
should.not.exist(err);
return callback(err);
});
var inStream = new stream.Readable();
inStream._read = function noop() {};
inStream.push(rawData);
inStream.push(null);
inStream.on('error', function(err) {
should.not.exist(err);
return callback(err);
});
inStream.on('end', function() {
connection.commit(function(err) {
should.not.exist(err);
callback();
});
});
inStream.pipe(lob);
}
);
},
function doQuery(callback) {
connection.execute(
"BEGIN SELECT content INTO :bv FROM " + tableName + " WHERE num = 2; END;",
{ bv: {dir: oracledb.BIND_OUT, type: oracledb.CLOB} },
{ maxRows: 500 },
function(err, result) {
should.not.exist(err);
var content = '';
var lob = result.outBinds.bv;
lob.setEncoding('utf8');
lob.on('data', function(chunk) {
content += chunk;
});
lob.on('end', function() {
(content.length).should.be.exactly(dataLength);
(content).should.eql(rawData);
callback();
});
lob.on('error', function(err) {
should.not.exist(err);
});
}
);
}
], done);
})
}) // 60.2
})

@@ -1,2 +0,2 @@

/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */
/* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. */

@@ -37,5 +37,6 @@ /******************************************************************************

var oracledb = require('oracledb');
var should = require('should');
var assist = require('./dataTypeAssist.js');
var should = require('should');
var assist = require('./dataTypeAssist.js');
var dbConfig = require('./dbConfig.js');
var async = require('async');

@@ -110,2 +111,206 @@ describe('22. dataTypeChar.js', function(){

})
describe('22.3 PL/SQL binding scalar', function() {
it('22.3.1 PL/SQL binding scalar values IN', function(done) {
async.series([
function(callback) {
var proc = "CREATE OR REPLACE\n" +
"FUNCTION testchar(stringValue IN CHAR) RETURN CHAR\n" +
"IS\n" +
"BEGIN\n" +
" RETURN 'Hello ' || stringValue || ' world!';\n" +
"END testchar;";
connection.should.be.ok;
connection.execute(
proc,
function(err) {
should.not.exist(err);
callback();
}
);
},
function(callback) {
var bindvars = {
result: {type: oracledb.STRING, dir: oracledb.BIND_OUT},
stringValue: {type: oracledb.STRING, dir: oracledb.BIND_IN, val: 'Node.js'}
};
connection.execute(
"BEGIN :result := testchar(:stringValue); END;",
bindvars,
function(err, result) {
should.not.exist(err);
// console.log(result);
callback();
}
);
},
function(callback) {
connection.execute(
"DROP FUNCTION testchar",
function(err) {
should.not.exist(err);
callback();
}
);
}
], done);
}) // 22.3.1
it('22.3.2 bind scalar values INOUT', function(done) {
async.series([
function(callback) {
var proc = "CREATE OR REPLACE\n" +
"PROCEDURE test(stringValue IN OUT NOCOPY CHAR)\n" +
"IS\n" +
"BEGIN\n" +
" stringValue := '(' || stringValue || ')';\n" +
"END test;\n";
connection.execute(
proc,
function(err) {
should.not.exist(err);
callback();
}
);
},
function(callback) {
var bindvars = { stringValue: {type: oracledb.STRING, dir: oracledb.BIND_INOUT, val: 'Node.js'} };
connection.execute(
"BEGIN test(:stringValue); END;",
bindvars,
function(err, result) {
should.exist(err);
// Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
// For SQL*PLUS driver, the behavior is the same
callback();
}
);
},
function(callback) {
connection.execute(
"DROP PROCEDURE test",
function(err) {
should.not.exist(err);
callback();
}
);
}
], done);
}) // 22.3.2
it('22.3.3 bind scalar values OUT', function(done) {
async.series([
function(callback) {
var proc = "CREATE OR REPLACE\n" +
"PROCEDURE test(stringValue OUT NOCOPY CHAR)\n" +
"IS\n" +
"BEGIN\n" +
" stringValue := 'Hello Node.js World!';\n" +
"END test;\n";
connection.execute(
proc,
function(err) {
should.not.exist(err);
callback();
}
);
},
function(callback) {
var bindvars = { stringValue: {type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize:200} };
connection.execute(
"BEGIN test(:stringValue); END;",
bindvars,
function(err, result) {
should.not.exist(err);
// There are trailing spaces with the outBind value as CHAR is a kind of
// fix-size data type. So the case uses trim() function.
(result.outBinds.stringValue.trim()).should.be.exactly('Hello Node.js World!');
callback();
}
);
},
function(callback) {
connection.execute(
"DROP PROCEDURE test",
function(err) {
should.not.exist(err);
callback();
}
);
}
], done);
}) // 22.3.3
}) // 22.3
describe('22.4 PL/SQL binding indexed tables', function() {
it.skip('22.4.1 bind indexed table IN', function(done) {
async.series([
function(callback) {
var proc = "CREATE OR REPLACE PACKAGE\n" +
"oracledb_testpack\n" +
"IS\n" +
" TYPE stringsType IS TABLE OF CHAR(30) INDEX BY BINARY_INTEGER;\n" +
" FUNCTION test(strings IN stringsType) RETURN CHAR;\n" +
"END;";
connection.should.be.ok;
connection.execute(
proc,
function(err) {
should.not.exist(err);
callback();
}
);
},
function(callback) {
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
"oracledb_testpack\n" +
"IS\n" +
" FUNCTION test(strings IN stringsType) RETURN CHAR\n" +
" IS\n" +
" s CHAR(2000) := '';\n" +
" BEGIN\n" +
" FOR i IN 1 .. strings.COUNT LOOP\n" +
" s := s || strings(i);\n" +
" END LOOP;\n" +
" RETURN s;\n" +
" END;\n" +
"END;";
connection.execute(
proc,
function(err) {
should.not.exist(err);
callback();
}
);
},
function(callback) {
var bindvars = {
result: {type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 2000},
strings: {type: oracledb.STRING, dir: oracledb.BIND_IN, val: ['John', 'Doe']}
};
connection.execute(
"BEGIN :result := oracledb_testpack.test(:strings); END;",
bindvars,
function(err, result) {
should.not.exist(err);
console.log(result);
//result.outBinds.result.should.be.exactly('JohnDoe');
callback();
}
);
},
function(callback) {
connection.execute(
"DROP PACKAGE oracledb_testpack",
function(err) {
should.not.exist(err);
callback();
}
);
}
], done);
})
})
})

@@ -171,3 +171,2 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */

var bindValue = assist.createBuffer(size);
// console.log("original value", bindValue.toString('hex'));

@@ -187,4 +186,2 @@ connection.execute(

// NJS-028: raw database type is not supported with DML Returning statements
// (result.outBinds.rc[0].toString('hex')).should.eql(bindValue.toString('hex'));
// (result.outBinds.rc[0].length).should.be.exactly(size);
done();

@@ -212,5 +209,2 @@ }

(err.message).should.startWith('NJS-028');
// console.log(result);
// (result.outBinds.rc[0].toString('hex')).should.eql(bindValue.toString('hex'));
// (result.outBinds.rc[0].length).should.be.exactly(size);
done();

@@ -238,5 +232,2 @@ }

(err.message).should.startWith('NJS-028');
// console.log(result);
// (result.outBinds.rc[0].toString('hex')).should.eql(bindValue.toString('hex'));
// (result.outBinds.rc[0].length).should.be.exactly(size);
done();

@@ -253,3 +244,2 @@ }

connection.execute(
//"INSERT INTO " + tableName + " VALUES (:n, :c) RETURNING num, content INTO :rid, :rc",
"UPDATE " + tableName + " SET content = :c WHERE num = :n RETURNING num, content INTO :rid, :rc",

@@ -266,5 +256,2 @@ {

(err.message).should.startWith('NJS-028');
// console.log(result);
// (result.outBinds.rc[0].toString('hex')).should.eql(bindValue.toString('hex'));
// (result.outBinds.rc[0].length).should.be.exactly(size);
done();

@@ -279,3 +266,2 @@ }

connection.execute(
// "INSERT INTO " + tableName + " VALUES (:n, :c) RETURNING num, content INTO :rid, :rc",
"DELETE FROM " + tableName + " WHERE num = :1 RETURNING num, content INTO :2, :3",

@@ -291,5 +277,2 @@ [

(err.message).should.startWith('NJS-028');
// console.log(result);
// (result.outBinds.rc[0].toString('hex')).should.eql(bindValue.toString('hex'));
// (result.outBinds.rc[0].length).should.be.exactly(size);
done();

@@ -304,3 +287,2 @@ }

connection.execute(
// "INSERT INTO " + tableName + " VALUES (:n, :c) RETURNING num, content INTO :rid, :rc",
"DELETE FROM " + tableName + " WHERE num > :n RETURNING num, content INTO :rid, :rc",

@@ -316,5 +298,2 @@ {

(err.message).should.startWith('NJS-028');
// console.log(result);
// (result.outBinds.rc[0].toString('hex')).should.eql(bindValue.toString('hex'));
// (result.outBinds.rc[0].length).should.be.exactly(size);
done();

@@ -435,2 +414,2 @@ }

})
})

@@ -26,2 +26,7 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */

* Testing driver DML Returning feature.
*
* When DML affects multiple rows we can still use the RETURING INTO,
* but now we must return the values into a collection using the
* BULK COLLECT clause.
*
*

@@ -581,2 +586,60 @@ * NUMBERING RULE

}) // 6.2
describe('6.3 BULK COLLECT clause', function() {
var connection = null;
var tableName = "oracledb_varchar2";
var dataLength = 500;
var rows = [];
for (var i = 0; i < dataLength; i++)
rows[i] = "Row Number " + i;
before(function(done) {
async.series([
function(cb) {
oracledb.getConnection(credential, function(err, conn) {
should.not.exist(err);
connection = conn;
cb();
});
},
function insertRows(cb) {
assist.setUp(connection, tableName, rows, cb);
}
], done);
}) // before
after(function(done) {
async.series([
function(cb) {
connection.execute(
"DROP table " + tableName,
function(err) {
should.not.exist(err);
cb();
}
);
},
function(cb) {
connection.release( function(err) {
should.not.exist(err);
cb();
});
}
], done);
}) // after
/* Pending case*/
it.skip('6.3.1 ', function(done) {
connection.execute(
"SELECT * FROM " + tableName,
function(err, result) {
//console.log(result);
console.log(result.rows.length);
done();
}
);
})
}) // 6.3
})

@@ -227,2 +227,8 @@ 1. connection.js

22.2.1 testing Null, Empty string and Undefined
22.3 PL/SQL binding scalar
22.3.1 PL/SQL binding scalar values IN
22.3.2 bind scalar values INOUT
22.3.3 bind scalar values OUT
22.4 PL/SQL binding indexed tables
- 22.4.1 bind indexed table IN

@@ -406,2 +412,33 @@ 23. dataTypeNchar.js

43. plsqlBinding.js
43.1 binding PL/SQL indexed table
43.1.1 binding PL/SQL indexed table IN
43.1.2 binding PL/SQL indexed table IN OUT
43.1.3 binding PL/SQL indexed table OUT
43.2 test exceptions when using PL/SQL indexed table bindings
43.2.1 maxArraySize is ignored when specifying BIND_IN
43.2.2 maxArraySize is mandatory for BIND_INOUT
42.2.3 maxArraySize cannot smaller than the number of array elements
42.2.4 DATE type has not been supported yet
42.2.5 the type of the array element should be compatible with binding type declaration
42.2.6 type compatibility
- 42.2.7 maxSize restriction
42.2.8 dose not allow array syntax of bindings
43.3 binding PL/SQL scalar
43.3.1 binding PL/SQL scalar IN
- 43.3.2 binding PL/SQL scalar IN/OUT
43.3.3 binding PL/SQL scalar OUT
43.4 test attribute - maxArraySize
43.4.1 maxArraySize property is ignored for BIND_IN
43.4.2 maxArraySize is mandatory for BIND_INOUT
43.4.3 maxArraySize cannot smaller than the number of array elements
43.4.4 maxArraySize can be equal to the number of array elements
- 43.4.5 negative case: large value
43.4.6 negative case: <0
43.4.7 negative case: = 0
43.4.8 negative case: assigning it to be a string
43.4.9 negative case: NaN
43.5 Indexed Table Null Elements
- 43.5.1 null elements work well
51. accessTerminatedPoolAttributes.js

@@ -501,4 +538,7 @@ can not access attributes of terminated pool

60. clobPlsqlString.js
60.1 PL/SQL OUT CLOB parameters can also be bound as STRING
60.2 The returned length is limited to the maximum size
60.1 BIND OUT as STRING
60.1.1 PL/SQL OUT CLOB parameters can also be bound as STRING
60.1.2 The returned length is limited to the maximum size
60.2 BIND OUT as CLOB
60.2.1 maxSize option does not take effect when bind out type is clob

@@ -505,0 +545,0 @@ 61. checkClassesTypes.js

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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