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

idb-pconnector

Package Overview
Dependencies
Maintainers
4
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idb-pconnector - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

18

lib/idb-pconnector.js

@@ -231,3 +231,3 @@ const dba = require('idb-connector');

async bind(params) {
return this.bindParam(params);
return await this.bindParam(params);
}

@@ -417,3 +417,3 @@

return new Promise((resolve, reject) => {
if (index && Number.isInteger(index)) {
if (Number.isInteger(index)) {
try {

@@ -423,3 +423,3 @@ response = stmt[`field${suffix}`](index);

if (suffix === 'Nullable') {
response = !!reponse;
response = !!response;
}

@@ -444,3 +444,3 @@

async fieldName(index) {
this.field('Name', index);
return await this.field('Name', index);
}

@@ -455,3 +455,3 @@

async fieldNullable(index) {
this.field('Nullable', index);
return await this.field('Nullable', index);
}

@@ -466,3 +466,3 @@

async fieldPrecise(index) {
this.field('Precise', index);
return await this.field('Precise', index);
}

@@ -477,3 +477,3 @@

async fieldScale(index) {
this.field('Scale', index);
return await this.field('Scale', index);
}

@@ -488,3 +488,3 @@

async fieldType(index) {
this.field('Type', index);
return await this.field('Type', index);
}

@@ -499,3 +499,3 @@

async fieldWidth(index) {
this.field('Width', index);
return await this.field('Width', index);
}

@@ -502,0 +502,0 @@

{
"name": "idb-pconnector",
"version": "0.0.6",
"version": "0.0.7",
"description": "Promised-based Db2 Connector for IBM i (pre-alpha, NOT PRODUCTION READY)",

@@ -21,7 +21,7 @@ "main": "lib/idb-pconnector.js",

"dependencies": {
"idb-connector": "^1.0.9",
"mocha": "^5.1.0",
"chai": "^4.1.2"
"idb-connector": "^1.0.10"
},
"devDependencies": {
"mocha": "^5.1.0",
"chai": "^4.1.2",
"jsdoc": "^3.5.5",

@@ -28,0 +28,0 @@ "jsdox": "^0.4.10"

@@ -10,10 +10,32 @@ /*

const expect = require('chai').expect;
const dba = require('../lib/idb-pconnector.js');
const dba = require('idb-pconnector');
// Test Connection Class
describe('connect', () => {
it('should return a newly connected dbconn object', async () => {
let dbConn = new dba.Connection();
console.log(dbConn);
let connReturned = dbConn.connect();
console.log(connReturned);
expect(connReturned.dbconn).to.be.a('dbconn');
});
});
describe('getStatement', () => {
it('should return a new statemetnt intiialized with the the dbconn', async () => {
let dbConn = new dba.Connection().connect();
console.log(dbConn);
let stmtReturned = dbConn.getStatement();
console.log(stmtReturned);
expect(stmtReturned.stmt).to.be.a('dbstmt');
});
});
//if successful returns String
describe('validStmt', () => {
it('if the SQL is valid, validStmt , should return type String', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbConn = new dba.Connection().connect();

@@ -142,3 +164,3 @@ let res = await dbConn.validStmt(sql);

it('Prepares valid SQL and sends it to the DBMS, if the input SQL Statement cannot be prepared error is returned. ', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -162,8 +184,17 @@ let res = await dbStmt.prepare(sql);

it('associate parameter markers in an SQL statement to app variables', async () => {
let sql = 'INSERT INTO AMUSSE.TABLE1 VALUES (?,?)';
let sql = 'INSERT INTO QIWS.QCUSTCDT(CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) VALUES (?,?,?,?,?,?,?,?,?,?,?) with NONE ';
let dbStmt = new dba.Connection().connect().getStatement();
await dbStmt.prepare(sql);
let res = await dbStmt.bindParam([
[2099, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC],
['Node.Js', dba.SQL_PARAM_INPUT, dba.SQL_CHAR]
[9997, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //CUSNUM
['Doe', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //LASTNAME
['J D', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //INITIAL
['123 Broadway', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //ADDRESS
['Hope', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //CITY
['WA', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //STATE
[98101, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //ZIP
[2000, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //CREDIT LIMIT
[1, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], // change
[250, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //BAL DUE
[0.00, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC] //CREDIT DUE
]);

@@ -177,8 +208,8 @@ await dbStmt.execute();

it('error caused by not providing correct params within the params[]', async () => {
let sql = 'INSERT INTO AMUSSE.TABLE1 VALUES (?,?)';
let sql = 'INSERT INTO QIWS.QCUSTCDT(CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) VALUES (?,?,?,?,?,?,?,?,?,?,?) with NONE ';
let dbStmt = new dba.Connection().connect().getStatement();
await dbStmt.prepare(sql);
let res = await dbStmt.bindParam([
[2099],
['Node.Js']
[1, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], // change
[250, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //BAL DUE
]);

@@ -190,6 +221,29 @@ await dbStmt.execute();

describe('bind', () => {
it('shorthand for the bindParams()', async () => {
let sql = 'INSERT INTO QIWS.QCUSTCDT(CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) VALUES (?,?,?,?,?,?,?,?,?,?,?) with NONE ';
let dbStmt = new dba.Connection().connect().getStatement();
await dbStmt.prepare(sql);
let res = await dbStmt.bindParam([
[9997, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //CUSNUM
['Johnson', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //LASTNAME
['A J', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //INITIAL
['453 Example', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //ADDRESS
['Fort', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //CITY
['TN', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //STATE
[37211, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //ZIP
[1000, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //CREDIT LIMIT
[1, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], // change
[150, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //BAL DUE
[0.00, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC] //CREDIT DUE
]);
await dbStmt.execute();
expect(res).to.be.a('undefined');
});
});
//if successful returns undefined
describe('close', () => {
it('frees the statement object. ', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -204,3 +258,3 @@ await dbStmt.exec(sql);

// it('error caused by calling close before statement was executed. ', async () =>{
// let sql = "SELECT * FROM AMUSSE.TABLE1";
// let sql = "SELECT * FROM QIWS.QCUSTCDT";
// let dbStmt = new dba.Connection().connect().getStatement();

@@ -216,3 +270,3 @@ // //await dbStmt.exec(sql);

it('closes any cursor associated with the dbstmt object and discards any pending results. ', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -227,3 +281,3 @@ await dbStmt.exec(sql);

// it('error caused by calling closeCursor before statement was executed. ', async () =>{
// let sql = "SELECT * FROM AMUSSE.TABLE1";
// let sql = "SELECT * FROM QIWS.QCUSTCDT";
// let dbStmt = new dba.Connection().connect().getStatement();

@@ -239,8 +293,17 @@ // //await dbStmt.exec(sql);

it('adds all changes to the database that have been made on the connection since connect time ', async () => {
let sql = 'INSERT INTO AMUSSE.TABLE1 VALUES (?,?)';
let sql = 'INSERT INTO QIWS.QCUSTCDT(CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) VALUES (?,?,?,?,?,?,?,?,?,?,?) with NONE ';
let dbStmt = new dba.Connection().connect().getStatement();
await dbStmt.prepare(sql);
await dbStmt.bindParam([
[4234, dba.PARM_TYPE_INPUT, 2],
['sublime', dba.PARM_TYPE_INPUT, 1]
[9997, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //CUSNUM
['Johnson', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //LASTNAME
['A J', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //INITIAL
['453 Example', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //ADDRESS
['Fort', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //CITY
['TN', dba.SQL_PARAM_INPUT, dba.SQL_CHAR], //STATE
[37211, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //ZIP
[1000, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //CREDIT LIMIT
[1, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], // change
[150, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], //BAL DUE
[0.00, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC] //CREDIT DUE
]);

@@ -256,3 +319,3 @@ await dbStmt.execute();

// it('error caused by calling commit before statement was executed. ', async () =>{
// let sql = "INSERT INTO AMUSSE.TABLE1 VALUES (?,?)";
// let sql = 'INSERT INTO QIWS.QCUSTCDT(CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) VALUES (?,?,?,?,?,?,?,?,?,?,?) with NONE ';
// let dbStmt = new dba.Connection().connect().getStatement();

@@ -270,3 +333,3 @@ // await dbStmt.prepare(sql);

it('performs action of given SQL String', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -283,3 +346,3 @@ let res = await dbStmt.exec(sql);

it('error caused by calling exec without params', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -297,3 +360,3 @@ let res = await dbStmt.exec();

it('retrieves results from execute function:', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -310,3 +373,3 @@ await dbStmt.prepare(sql);

it('error caused by calling execute before statement was prepared.', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -324,3 +387,3 @@ //await dbStmt.prepare(sql);

it('retrieves results from execute function:', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -337,3 +400,3 @@ await dbStmt.prepare(sql);

it('error caused by calling fetchAll before results were available', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -352,3 +415,3 @@ await dbStmt.prepare(sql);

it('retrieves results from execute function:', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -365,3 +428,3 @@ await dbStmt.prepare(sql);

it('error caused by calling fetch before results were available', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -379,3 +442,3 @@ await dbStmt.prepare(sql);

it('retrieves number of fields contained in result', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -392,3 +455,3 @@ await dbStmt.prepare(sql);

it('error caused by calling numFields before results were available.', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -406,3 +469,3 @@ await dbStmt.prepare(sql);

it('retrieves number of rows that were effected by a Querry', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -419,3 +482,3 @@ await dbStmt.prepare(sql);

it('error caused by calling numRows before results were available.', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -433,3 +496,3 @@ await dbStmt.prepare(sql);

it('requires an int index parameter. If a valid index is provided, returns the data type of the indicated column', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -449,3 +512,3 @@ await dbStmt.prepare(sql);

it('error caused by not providing an index as a param', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -466,3 +529,3 @@ await dbStmt.prepare(sql);

it('requires an int index parameter. If a valid index is provided, returns the field width of the indicated column', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -482,3 +545,3 @@ await dbStmt.prepare(sql);

it('error caused by not providing an index as a param', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -499,3 +562,3 @@ await dbStmt.prepare(sql);

it('requires an int index parameter. If a valid index is provided, returns t/f if the indicated column can be Null', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -516,3 +579,3 @@ await dbStmt.prepare(sql);

it('error caused by not providing an index as a param', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -529,7 +592,7 @@ await dbStmt.prepare(sql);

it('requires an int index parameter. If a valid index is provided,returns name of the indicated column ', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();
await dbStmt.prepare(sql);
await dbStmt.execute();
let col1 = await dbStmt.fieldName(0);
let col1 = await dbStmt.fieldName(1);
let col2 = await dbStmt.fieldName(1);

@@ -545,3 +608,3 @@ console.log('column 1 Name = : ' + col1);

it('error caused by providing an invalid index as a param', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -562,3 +625,3 @@ await dbStmt.prepare(sql);

it('requires an int index parameter. If a valid index is provided, returns the precision of the indicated column', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -578,3 +641,3 @@ await dbStmt.prepare(sql);

it('error caused by not providing an index as a param', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -595,3 +658,3 @@ await dbStmt.prepare(sql);

it('requires an int index parameter. If a valid index is provided, returns the scale of the indicated column', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -611,3 +674,3 @@ await dbStmt.prepare(sql);

it('error caused by providing an invalid index as a param', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -675,3 +738,3 @@ await dbStmt.prepare(sql);

// it('Determines whether there is more information available on the statement', async () => {
// let sql = "SELECT * FROM AMUSSE.TABLE1";
// let sql = "SELECT * FROM QIWS.QCUSTCDT";
// let dbStmt = new dba.Connection().connect().getStatement();

@@ -687,3 +750,3 @@ // await dbStmt.prepare(sql);

it('err', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -700,3 +763,3 @@ await dbStmt.prepare(sql);

it('Rollback all changes to the database that have been made on the connection', async () => {
let sql = 'SELECT * FROM AMUSSE.TABLE1';
let sql = 'SELECT * FROM QIWS.QCUSTCDT';
let dbStmt = new dba.Connection().connect().getStatement();

@@ -714,3 +777,3 @@ await dbStmt.prepare(sql);

// let res = await dbStmt.rollback();
// let sql = "SELECT * FROM AMUSSE.TABLE1";
// let sql = "SELECT * FROM QIWS.QCUSTCDT";
// let dbStmt = new dba.Connection().connect().getStatement();

@@ -741,2 +804,2 @@ // await dbStmt.prepare(sql);

// });
// })
// })
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