idb-pconnector
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -1,29 +0,1 @@ | ||
# Global | ||
### Global.makeBool(data) | ||
helper method to convert 0 or 1 recieved from idb-connector to javascript boolean. | ||
**Parameters** | ||
**data**: `any`, the input data to be checked before returning. | ||
**Returns**: , - false if the input data was 0 , true if the input data is 1 , if the data was something else return the data. | ||
### Global.isInt(data) | ||
helper mthod to determine if the type of data is an integer. | ||
**Parameters** | ||
**data**: `any`, the input data to be tested. | ||
**Returns**: `boolean`, - true if the data is of type number otherwise returns false. | ||
* * * | ||
# Class: Connection | ||
@@ -138,3 +110,3 @@ | ||
- - - | ||
# Class: Statement | ||
@@ -141,0 +113,0 @@ |
@@ -35,3 +35,3 @@ const dba = require('idb-connector'); | ||
getStatement() { | ||
return new Statement(this); | ||
return new Statement(this.dbconn); | ||
} | ||
@@ -38,0 +38,0 @@ |
{ | ||
"name": "idb-pconnector", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Promised-based Db2 Connector for IBM i (pre-alpha, NOT PRODUCTION READY)", | ||
@@ -30,2 +30,2 @@ "main": "lib/idb-pconnector.js", | ||
} | ||
} |
1146
test/test.js
@@ -5,109 +5,109 @@ /* | ||
* You may need to download those modules to run these tests on your machine | ||
* To see results of individual test cases you can run npm test -- --grep name_of_test | ||
* To see results of individual test cases you can run npm test -- --grep name_of_test | ||
* | ||
*/ | ||
var assert = require('chai').assert; | ||
var expect = require('chai').expect; | ||
var dba = require('../idb-pconnector.js'); | ||
const assert = require('chai').assert; | ||
const expect = require('chai').expect; | ||
const dba = require('../lib/idb-pconnector.js'); | ||
// Test Connection Class | ||
//if successful returns String | ||
describe('validStmt', function () { | ||
it('if the SQL is valid, validStmt , should return type String', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.validStmt(sql); | ||
console.log("Valid Stmt output: " + res); | ||
expect(res).to.be.a('string'); | ||
}); | ||
}) | ||
//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 dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.validStmt(sql); | ||
console.log('Valid Stmt output: ' + res); | ||
expect(res).to.be.a('string'); | ||
}); | ||
}); | ||
describe('validStmtFail', function () { | ||
it('error caused by providing invalid SQL as a param', async function () { | ||
var sql = "garbageInput"; | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.validStmt(); | ||
console.log("Valid Stmt output: " + res); | ||
expect(res).to.be.a('string'); | ||
}); | ||
}) | ||
describe('validStmtFail', () => { | ||
it('error caused by providing invalid SQL as a param', async () => { | ||
let sql = 'garbageInput'; | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.validStmt(); | ||
console.log('Valid Stmt output: ' + res); | ||
expect(res).to.be.a('string'); | ||
}); | ||
}); | ||
//if successful returns String or Int depending on attribute | ||
describe('getConnAttr', function () { | ||
it('if connection attribute exsits should return type String or Int depending on the attribute type', async function () { | ||
var attr = 0; | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.getConnAttr(attr); | ||
console.log("Attrubte: " + res) | ||
expect(res).to.satisfy(function(res){ | ||
return res === 'string' || typeof res == 'number' | ||
}); | ||
}); | ||
}) | ||
describe('getConnAttr', () => { | ||
it('if connection attribute exsits should return type String or Int depending on the attribute type', async () => { | ||
let attr = 0; | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.getConnAttr(attr); | ||
console.log('Attrubte: ' + res); | ||
expect(res).to.satisfy(function(res){ | ||
return res === 'string' || typeof res === 'number'; | ||
}); | ||
}); | ||
}); | ||
describe('getConnAttrFail', function () { | ||
it('error caused by providing invalid attr as a param', async function () { | ||
var attr = 50; | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.getConnAttr(attr); | ||
console.log("Attrubte: " + res) | ||
expect(res).to.satisfy(function(res){ | ||
return res === 'string' || typeof res == 'number' | ||
}); | ||
}); | ||
}) | ||
describe('getConnAttrFail', () => { | ||
it('error caused by providing invalid attr as a param', async () => { | ||
let attr = 50; | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.getConnAttr(attr); | ||
console.log('Attrubte: ' + res); | ||
expect(res).to.satisfy(function(res){ | ||
return res === 'string' || typeof res === 'number'; | ||
}); | ||
}); | ||
}); | ||
//if successful returns undefined | ||
describe('setConnAttr', function () { | ||
it('sets the ConnAttr. Attrubte should be INT. Value can String or Int depending on the attribute', async function () { | ||
var attr = 0; | ||
var value = 2; | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.setConnAttr(attr, value); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('setConnAttrFail', function () { | ||
it('error caused by providing invlaid attr and value params', async function () { | ||
var attr = ""; | ||
var value = -5; | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.setConnAttr(attr, value); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('setConnAttr', () => { | ||
it('sets the ConnAttr. Attrubte should be INT. Value can String or Int depending on the attribute', async () => { | ||
let attr = 0; | ||
let value = 2; | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.setConnAttr(attr, value); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
describe('setConnAttrFail', () => { | ||
it('error caused by providing invlaid attr and value params', async () => { | ||
let attr = ''; | ||
let value = -5; | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.setConnAttr(attr, value); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
//if successful returns undefined | ||
describe('debug', function () { | ||
it('prints more detailed info if choice = true. Turned off by setting choice = false.', async function () { | ||
var choice = true; | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.debug(choice); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('debugFail', function () { | ||
it('error caused by using invalid param type instead of a boolean', async function () { | ||
var choice = 1; | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.debug("choice"); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('debug', () => { | ||
it('prints more detailed info if choice = true. Turned off by setting choice = false.', async () => { | ||
let choice = true; | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.debug(choice); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
describe('debugFail', () => { | ||
it('error caused by using invalid param type instead of a boolean', async () => { | ||
let choice = 1; | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.debug('choice'); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
//if successful returns undefined | ||
describe('disconn', function () { | ||
it('disconnects an exsisting connection to the datbase. ', async function () { | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.disconn(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('disconn', () => { | ||
it('disconnects an exsisting connection to the datbase. ', async () => { | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.disconn(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
// need to create a Failure Case for disconn() | ||
// describe('disconnFail' , function() { | ||
// it('error caused by calling disconn before Conn was established ', async function(){ | ||
// var dbConn = new dba.Connection().constructor(); | ||
// var res = await dbConn.disconn(); | ||
// describe('disconnFail' , () => { | ||
// it('error caused by calling disconn before Conn was established ', async () =>{ | ||
// let dbConn = new dba.Connection().constructor(); | ||
// let res = await dbConn.disconn(); | ||
// expect(res).to.be.a('undefined'); | ||
@@ -118,15 +118,15 @@ // }); | ||
//if successful returns undefined | ||
describe('close', function () { | ||
it('frees the connection object. ', async function () { | ||
var dbConn = new dba.Connection().connect(); | ||
var res = await dbConn.close(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('close', () => { | ||
it('frees the connection object. ', async () => { | ||
let dbConn = new dba.Connection().connect(); | ||
let res = await dbConn.close(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
// need to create a Failure Case for close() | ||
// describe('closeFail' , function() { | ||
// it('error caused by calling close before Conn was established. ', async function(){ | ||
// //var dbConn = new dba.Connection().connect(); | ||
// var res = await dbConn.close(); | ||
// describe('closeFail' , () => { | ||
// it('error caused by calling close before Conn was established. ', async () =>{ | ||
// //let dbConn = new dba.Connection().connect(); | ||
// let res = await dbConn.close(); | ||
// expect(res).to.be.a('undefined'); | ||
@@ -141,66 +141,66 @@ // }); | ||
//if successful returns undefined | ||
describe('prepare', function () { | ||
it('Prepares valid SQL and sends it to the DBMS, if the input SQL Statement cannot be prepared error is returned. ', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
var res = await dbStmt.prepare(sql); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('prepare', () => { | ||
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 dbStmt = new dba.Connection().connect().getStatement(); | ||
let res = await dbStmt.prepare(sql); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
describe('prepareFail', function () { | ||
it('error caused by preparing invalid SQL as a param', async function () { | ||
var sql = "SELECT * "; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
var res = await dbStmt.prepare(sql); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('prepareFail', () => { | ||
it('error caused by preparing invalid SQL as a param', async () => { | ||
let sql = 'SELECT * '; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
let res = await dbStmt.prepare(sql); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
//if successful returns undefined. | ||
describe('bindParams', function () { | ||
it('associate parameter markers in an SQL statement to app variables', async function () { | ||
var sql = "INSERT INTO AMUSSE.TABLE1 VALUES (?,?)"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
var res = await dbStmt.bindParam([ | ||
[2099, dba.SQL_PARAM_INPUT, dba.SQL_NUMERIC], | ||
['Node.Js', dba.SQL_PARAM_INPUT, dba.SQL_CHAR] | ||
]); | ||
await dbStmt.execute(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('bindParams', () => { | ||
it('associate parameter markers in an SQL statement to app variables', async () => { | ||
let sql = 'INSERT INTO AMUSSE.TABLE1 VALUES (?,?)'; | ||
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] | ||
]); | ||
await dbStmt.execute(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
describe('bindParamsFail', function () { | ||
it('error caused by not providing correct params within the params[]', async function () { | ||
var sql = "INSERT INTO AMUSSE.TABLE1 VALUES (?,?)"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
var res = await dbStmt.bindParam([ | ||
[2099], | ||
['Node.Js'] | ||
]); | ||
await dbStmt.execute(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('bindParamsFail', () => { | ||
it('error caused by not providing correct params within the params[]', async () => { | ||
let sql = 'INSERT INTO AMUSSE.TABLE1 VALUES (?,?)'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
let res = await dbStmt.bindParam([ | ||
[2099], | ||
['Node.Js'] | ||
]); | ||
await dbStmt.execute(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
//if successful returns undefined | ||
describe('close', function () { | ||
it('frees the statement object. ', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.exec(sql); | ||
var res = await dbStmt.close(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('close', () => { | ||
it('frees the statement object. ', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.exec(sql); | ||
let res = await dbStmt.close(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
// describe('closeFail' , function() { | ||
// it('error caused by calling close before statement was executed. ', async function(){ | ||
// var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
// var dbStmt = new dba.Connection().connect().getStatement(); | ||
// describe('closeFail' , () => { | ||
// it('error caused by calling close before statement was executed. ', async () =>{ | ||
// let sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
// let dbStmt = new dba.Connection().connect().getStatement(); | ||
// //await dbStmt.exec(sql); | ||
// var res = await dbStmt.close(); | ||
// let res = await dbStmt.close(); | ||
// expect(res).to.be.a('undefined'); | ||
@@ -211,18 +211,18 @@ // }); | ||
//if successful returns undefined | ||
describe('closeCursor', function () { | ||
it('closes any cursor associated with the dbstmt object and discards any pending results. ', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.exec(sql); | ||
var res = await dbStmt.closeCursor(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('closeCursor', () => { | ||
it('closes any cursor associated with the dbstmt object and discards any pending results. ', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.exec(sql); | ||
let res = await dbStmt.closeCursor(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
// describe('closeCursorFail' , function() { | ||
// it('error caused by calling closeCursor before statement was executed. ', async function(){ | ||
// var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
// var dbStmt = new dba.Connection().connect().getStatement(); | ||
// describe('closeCursorFail' , () => { | ||
// it('error caused by calling closeCursor before statement was executed. ', async () =>{ | ||
// let sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
// let dbStmt = new dba.Connection().connect().getStatement(); | ||
// //await dbStmt.exec(sql); | ||
// var res = await dbStmt.closeCursor(); | ||
// let res = await dbStmt.closeCursor(); | ||
// expect(res).to.be.a('undefined'); | ||
@@ -233,26 +233,26 @@ // }); | ||
//if successful returns undefined | ||
describe('commit', function () { | ||
it('adds all changes to the database that have been made on the connection since connect time ', async function () { | ||
var sql = "INSERT INTO AMUSSE.TABLE1 VALUES (?,?)"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
var res = await dbStmt.bindParam([ | ||
[4234, dba.PARM_TYPE_INPUT, 2], | ||
['sublime', dba.PARM_TYPE_INPUT, 1] | ||
]); | ||
await dbStmt.execute(); | ||
var res = await dbStmt.commit(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('commit', () => { | ||
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 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] | ||
]); | ||
await dbStmt.execute(); | ||
let res = await dbStmt.commit(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
// need to create a Failure Case for commit() | ||
// describe('commitFail' , function() { | ||
// it('error caused by calling commit before statement was executed. ', async function(){ | ||
// var sql = "INSERT INTO AMUSSE.TABLE1 VALUES (?,?)"; | ||
// var dbStmt = new dba.Connection().connect().getStatement(); | ||
// describe('commitFail' , () => { | ||
// it('error caused by calling commit before statement was executed. ', async () =>{ | ||
// let sql = "INSERT INTO AMUSSE.TABLE1 VALUES (?,?)"; | ||
// let dbStmt = new dba.Connection().connect().getStatement(); | ||
// await dbStmt.prepare(sql); | ||
// var res = await dbStmt.bindParam([ [4234,dba.PARM_TYPE_INPUT,2], ['sublime' ,dba.PARM_TYPE_INPUT, 1] ]); | ||
// let res = await dbStmt.bindParam([ [4234,dba.PARM_TYPE_INPUT,2], ['sublime' ,dba.PARM_TYPE_INPUT, 1] ]); | ||
// //await dbStmt.execute(); | ||
// var res = await dbStmt.commit(); | ||
// let res = await dbStmt.commit(); | ||
// expect(res).to.be.a('undefined'); | ||
@@ -263,392 +263,390 @@ // }); | ||
//if successful returns an array. of Type of objects | ||
describe('exec', function () { | ||
it('performs action of given SQL String', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
var res = await dbStmt.exec(sql); | ||
assert.isNotObject(res, "object was not returned"); | ||
console.log("Type of Res = " + typeof res); | ||
console.log("Select results: " + JSON.stringify(res)) | ||
expect(res).to.be.an('array'); | ||
}); | ||
}) | ||
describe('exec', () => { | ||
it('performs action of given SQL String', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
let res = await dbStmt.exec(sql); | ||
assert.isNotObject(res, 'object was not returned'); | ||
console.log('Type of Res = ' + typeof res); | ||
console.log('Select results: ' + JSON.stringify(res)); | ||
expect(res).to.be.an('array'); | ||
}); | ||
}); | ||
describe('execFail', function () { | ||
it('error caused by calling exec without params', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
var res = await dbStmt.exec(); | ||
assert.isNotObject(res, "object was not returned"); | ||
console.log("Type of Res = " + typeof res); | ||
console.log("Select results: " + JSON.stringify(res)) | ||
expect(res).to.be.an('array'); | ||
}); | ||
}) | ||
describe('execFail', () => { | ||
it('error caused by calling exec without params', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
let res = await dbStmt.exec(); | ||
assert.isNotObject(res, 'object was not returned'); | ||
console.log('Type of Res = ' + typeof res); | ||
console.log('Select results: ' + JSON.stringify(res)); | ||
expect(res).to.be.an('array'); | ||
}); | ||
}); | ||
//if successful returns an array of length 0?. Why,even return it if size == 0? | ||
describe('execute', function () { | ||
it('retrieves results from execute function:', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
var res = await dbStmt.execute(); | ||
console.log("Select results: " + JSON.stringify(res)); | ||
console.log("Size of the returned array:" + res.length) | ||
expect(res).to.be.a('array'); | ||
}); | ||
}) | ||
//if successful returns an array of length 0?. Why,even return it if size === 0? | ||
describe('execute', () => { | ||
it('retrieves results from execute function:', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
let res = await dbStmt.execute(); | ||
console.log('Select results: ' + JSON.stringify(res)); | ||
console.log('Size of the returned array:' + res.length); | ||
expect(res).to.be.a('array'); | ||
}); | ||
}); | ||
describe('executeFail', function () { | ||
it('error caused by calling execute before statement was prepared.', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
//await dbStmt.prepare(sql); | ||
var res = await dbStmt.execute(); | ||
console.log("Select results: " + JSON.stringify(res)); | ||
console.log("Size of the returned array:" + res.length) | ||
expect(res).to.be.a('array'); | ||
}); | ||
}) | ||
describe('executeFail', () => { | ||
it('error caused by calling execute before statement was prepared.', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
//await dbStmt.prepare(sql); | ||
let res = await dbStmt.execute(); | ||
console.log('Select results: ' + JSON.stringify(res)); | ||
console.log('Size of the returned array:' + res.length); | ||
expect(res).to.be.a('array'); | ||
}); | ||
}); | ||
//if successful returns an array. of Type of objects | ||
describe('fetchAll', function () { | ||
it('retrieves results from execute function:', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var res = await dbStmt.fetchAll(); | ||
console.log("Select results: " + JSON.stringify(res)); | ||
expect(res).to.be.a('array'); | ||
}); | ||
}) | ||
describe('fetchAll', () => { | ||
it('retrieves results from execute function:', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let res = await dbStmt.fetchAll(); | ||
console.log('Select results: ' + JSON.stringify(res)); | ||
expect(res).to.be.a('array'); | ||
}); | ||
}); | ||
describe('fetchAllFail', function () { | ||
it('error caused by calling fetchAll before results were available', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
//await dbStmt.execute(); | ||
var res = await dbStmt.fetchAll(); | ||
console.log("Select results: " + JSON.stringify(res)); | ||
expect(res).to.be.a('array'); | ||
}); | ||
}) | ||
describe('fetchAllFail', () => { | ||
it('error caused by calling fetchAll before results were available', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
//await dbStmt.execute(); | ||
let res = await dbStmt.fetchAll(); | ||
console.log('Select results: ' + JSON.stringify(res)); | ||
expect(res).to.be.a('array'); | ||
}); | ||
}); | ||
//if successful returns an Object of Row | ||
//kind of weird because FetchAll returns an Array(of objects? ) | ||
describe('fetch', function () { | ||
it('retrieves results from execute function:', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var res = await dbStmt.fetch(); | ||
console.log("Select results: " + JSON.stringify(res)); | ||
//expect(res).to.be.a('array'); | ||
expect(res).to.be.a('object'); | ||
}); | ||
}) | ||
describe('fetch', () => { | ||
it('retrieves results from execute function:', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let res = await dbStmt.fetch(); | ||
console.log('Select results: ' + JSON.stringify(res)); | ||
expect(res).to.be.a('object'); | ||
}); | ||
}); | ||
describe('fetchFail', function () { | ||
it('error caused by calling fetch before results were available', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
//await dbStmt.execute(); | ||
var res = await dbStmt.fetch(); | ||
console.log("Select results: " + JSON.stringify(res)); | ||
//expect(res).to.be.a('array'); | ||
expect(res).to.be.a('object'); | ||
}); | ||
}) | ||
describe('fetchFail', () => { | ||
it('error caused by calling fetch before results were available', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
//await dbStmt.execute(); | ||
let res = await dbStmt.fetch(); | ||
console.log('Select results: ' + JSON.stringify(res)); | ||
expect(res).to.be.a('object'); | ||
}); | ||
}); | ||
//if successful returns an Int | ||
describe('numFields', function () { | ||
it('retrieves number of fields contained in result', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var fields = await dbStmt.numFields(); | ||
console.log("Number of Fields: " + fields); | ||
expect(fields).to.be.a('number'); | ||
}); | ||
}) | ||
//if successful returns an Int | ||
describe('numFields', () => { | ||
it('retrieves number of fields contained in result', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let fields = await dbStmt.numFields(); | ||
console.log('Number of Fields: ' + fields); | ||
expect(fields).to.be.a('number'); | ||
}); | ||
}); | ||
describe('numFieldsFail', function () { | ||
it('error caused by calling numFields before results were available.', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
//await dbStmt.execute(); | ||
var fields = await dbStmt.numFields(); | ||
console.log("Number of Fields: " + fields); | ||
expect(fields).to.be.a('number'); | ||
}); | ||
}) | ||
describe('numFieldsFail', () => { | ||
it('error caused by calling numFields before results were available.', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
//await dbStmt.execute(); | ||
let fields = await dbStmt.numFields(); | ||
console.log('Number of Fields: ' + fields); | ||
expect(fields).to.be.a('number'); | ||
}); | ||
}); | ||
//if successful returns an Int | ||
describe('numRows', function () { | ||
it('retrieves number of rows that were effected by a Querry', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var rows = await dbStmt.numRows(); | ||
console.log("Number of Rows: " + rows); | ||
expect(rows).to.be.a('number'); | ||
}); | ||
}) | ||
//if successful returns an Int | ||
describe('numRows', () => { | ||
it('retrieves number of rows that were effected by a Querry', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let rows = await dbStmt.numRows(); | ||
console.log('Number of Rows: ' + rows); | ||
expect(rows).to.be.a('number'); | ||
}); | ||
}); | ||
describe('numRowsFail', function () { | ||
it('error caused by calling numRows before results were available.', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
//await dbStmt.execute(); | ||
var rows = await dbStmt.numRows(); | ||
console.log("Number of Rows: " + rows); | ||
expect(rows).to.be.a('number'); | ||
}); | ||
}) | ||
describe('numRowsFail', () => { | ||
it('error caused by calling numRows before results were available.', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
//await dbStmt.execute(); | ||
let rows = await dbStmt.numRows(); | ||
console.log('Number of Rows: ' + rows); | ||
expect(rows).to.be.a('number'); | ||
}); | ||
}); | ||
//if successful returns an Int | ||
describe('fieldType', function () { | ||
it('requires an int index parameter. If a valid index is provided, returns the data type of the indicated column', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldType(0); | ||
var col2 = await dbStmt.fieldType(1); | ||
console.log("column 1 fieldType = : " + col1); | ||
console.log("column 2 fieldType = : " + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}) | ||
//if successful returns an Int | ||
describe('fieldType', () => { | ||
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 dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldType(0); | ||
let col2 = await dbStmt.fieldType(1); | ||
console.log('column 1 fieldType = : ' + col1); | ||
console.log('column 2 fieldType = : ' + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}); | ||
describe('fieldTypeFail', function () { | ||
it('error caused by not providing an index as a param', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldType(); | ||
var col2 = await dbStmt.fieldType(); | ||
console.log("column 1 fieldType = : " + col1); | ||
console.log("column 2 fieldType = : " + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}) | ||
describe('fieldTypeFail', () => { | ||
it('error caused by not providing an index as a param', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldType(); | ||
let col2 = await dbStmt.fieldType(); | ||
console.log('column 1 fieldType = : ' + col1); | ||
console.log('column 2 fieldType = : ' + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}); | ||
//if successful returns an Int | ||
describe('fieldWidth', function () { | ||
it('requires an int index parameter. If a valid index is provided, returns the field width of the indicated column', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldWidth(0); | ||
var col2 = await dbStmt.fieldWidth(1); | ||
console.log("column 1 fieldWidth = : " + col1); | ||
console.log("column 2 fieldWidth = : " + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}) | ||
//if successful returns an Int | ||
describe('fieldWidth', () => { | ||
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 dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldWidth(0); | ||
let col2 = await dbStmt.fieldWidth(1); | ||
console.log('column 1 fieldWidth = : ' + col1); | ||
console.log('column 2 fieldWidth = : ' + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}); | ||
describe('fieldWidthFail', function () { | ||
it('error caused by not providing an index as a param', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldWidth(); | ||
var col2 = await dbStmt.fieldWidth(); | ||
console.log("column 1 fieldWidth = : " + col1); | ||
console.log("column 2 fieldWidth = : " + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}) | ||
describe('fieldWidthFail', () => { | ||
it('error caused by not providing an index as a param', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldWidth(); | ||
let col2 = await dbStmt.fieldWidth(); | ||
console.log('column 1 fieldWidth = : ' + col1); | ||
console.log('column 2 fieldWidth = : ' + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}); | ||
//if successful returns an Int but should return boolean based on doc , UPDATE 3-6-18 added logic to return the boolean. (makeBool method in idb-p) | ||
describe('fieldNullable', function () { | ||
it('requires an int index parameter. If a valid index is provided, returns t/f if the indicated column can be Null', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldNullable(0); | ||
var col2 = await dbStmt.fieldNullable(1); | ||
console.log("column 1 Nullable? = : " + col1); | ||
console.log("column 2 Nullable? = : " + col2); | ||
//****Documnetation says it should return a boolean | ||
expect(col1).to.equal(false); | ||
expect(col2).to.equal(true); | ||
}); | ||
}) | ||
describe('fieldNullable', () => { | ||
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 dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldNullable(0); | ||
let col2 = await dbStmt.fieldNullable(1); | ||
console.log('column 1 Nullable? = : ' + col1); | ||
console.log('column 2 Nullable? = : ' + col2); | ||
//****Documnetation says it should return a boolean | ||
expect(col1).to.equal(false); | ||
expect(col2).to.equal(true); | ||
}); | ||
}); | ||
describe('fieldNullableFail', function () { | ||
it('error caused by not providing an index as a param', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldNullable(); | ||
console.log(col1); | ||
}); | ||
}) | ||
describe('fieldNullableFail', () => { | ||
it('error caused by not providing an index as a param', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldNullable(); | ||
console.log(col1); | ||
}); | ||
}); | ||
//if successful returns an String | ||
describe('fieldName', function () { | ||
it('requires an int index parameter. If a valid index is provided,returns name of the indicated column ', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldName(0); | ||
var col2 = await dbStmt.fieldName(1); | ||
console.log("column 1 Name = : " + col1); | ||
console.log("column 2 Name = : " + col2); | ||
expect(col1).to.be.a('string'); | ||
expect(col2).to.be.a('string'); | ||
}); | ||
}) | ||
describe('fieldName', () => { | ||
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 dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldName(0); | ||
let col2 = await dbStmt.fieldName(1); | ||
console.log('column 1 Name = : ' + col1); | ||
console.log('column 2 Name = : ' + col2); | ||
expect(col1).to.be.a('string'); | ||
expect(col2).to.be.a('string'); | ||
}); | ||
}); | ||
describe('fieldNameFail', function () { | ||
it('error caused by providing an invalid index as a param', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldName("garbageInput"); | ||
var col2 = await dbStmt.fieldName("fake"); | ||
console.log("column 1 Name = : " + col1); | ||
console.log("column 2 Name = : " + col2); | ||
expect(col1).to.be.a('string'); | ||
expect(col2).to.be.a('string'); | ||
}); | ||
}) | ||
describe('fieldNameFail', () => { | ||
it('error caused by providing an invalid index as a param', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldName('garbageInput'); | ||
let col2 = await dbStmt.fieldName('fake'); | ||
console.log('column 1 Name = : ' + col1); | ||
console.log('column 2 Name = : ' + col2); | ||
expect(col1).to.be.a('string'); | ||
expect(col2).to.be.a('string'); | ||
}); | ||
}); | ||
//if successful returns an Int | ||
describe('fieldPrecise', function () { | ||
it('requires an int index parameter. If a valid index is provided, returns the precision of the indicated column', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldPrecise(0); | ||
var col2 = await dbStmt.fieldPrecise(1); | ||
console.log("column 1 fieldPrecision = : " + col1); | ||
console.log("column 2 fieldPrecision = : " + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}) | ||
//if successful returns an Int | ||
describe('fieldPrecise', () => { | ||
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 dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldPrecise(0); | ||
let col2 = await dbStmt.fieldPrecise(1); | ||
console.log('column 1 fieldPrecision = : ' + col1); | ||
console.log('column 2 fieldPrecision = : ' + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}); | ||
describe('fieldPreciseFail', function () { | ||
it('error caused by not providing an index as a param', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldPrecise(); | ||
var col2 = await dbStmt.fieldPrecise(); | ||
console.log("column 1 fieldPrecision = : " + col1); | ||
console.log("column 2 fieldPrecision = : " + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}) | ||
describe('fieldPreciseFail', () => { | ||
it('error caused by not providing an index as a param', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldPrecise(); | ||
let col2 = await dbStmt.fieldPrecise(); | ||
console.log('column 1 fieldPrecision = : ' + col1); | ||
console.log('column 2 fieldPrecision = : ' + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}); | ||
//if successful returns an Int | ||
describe('fieldScale', function () { | ||
it('requires an int index parameter. If a valid index is provided, returns the scale of the indicated column', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldScale(0); | ||
var col2 = await dbStmt.fieldScale(1); | ||
console.log("column 1 fieldScale = : " + col1); | ||
console.log("column 2 fieldScale = : " + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}) | ||
//if successful returns an Int | ||
describe('fieldScale', () => { | ||
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 dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldScale(0); | ||
let col2 = await dbStmt.fieldScale(1); | ||
console.log('column 1 fieldScale = : ' + col1); | ||
console.log('column 2 fieldScale = : ' + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}); | ||
describe('fieldScaleFail', function () { | ||
it('error caused by providing an invalid index as a param', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var col1 = await dbStmt.fieldScale("c"); | ||
var col2 = await dbStmt.fieldScale("a"); | ||
console.log("column 1 fieldScale = : " + col1); | ||
console.log("column 2 fieldScale = : " + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}) | ||
describe('fieldScaleFail', () => { | ||
it('error caused by providing an invalid index as a param', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let col1 = await dbStmt.fieldScale('c'); | ||
let col2 = await dbStmt.fieldScale('a'); | ||
console.log('column 1 fieldScale = : ' + col1); | ||
console.log('column 2 fieldScale = : ' + col2); | ||
expect(col1).to.be.a('number'); | ||
expect(col2).to.be.a('number'); | ||
}); | ||
}); | ||
//if successful returns undefined | ||
describe('setStmtAttr', function () { | ||
it('sets StmtAttr Attrubte should be INT. Value can String or Int depending on the attribute', async function () { | ||
var attr = dba.SQL_ATTR_FOR_FETCH_ONLY; | ||
var value = 1; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
var res = await dbStmt.setStmtAttr(attr, value); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('setStmtAttr', () => { | ||
it('sets StmtAttr Attrubte should be INT. Value can String or Int depending on the attribute', async () => { | ||
let attr = dba.SQL_ATTR_FOR_FETCH_ONLY; | ||
let value = 1; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
let res = await dbStmt.setStmtAttr(attr, value); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
describe('setStmtAttrFail', function () { | ||
it('error caused by providing invalid attr and value as params', async function () { | ||
//invalid attr insert | ||
var attr = -500; | ||
var value = 1; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
var res = await dbStmt.setStmtAttr(attr, value); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('setStmtAttrFail', () => { | ||
it('error caused by providing invalid attr and value as params', async () => { | ||
//invalid attr insert | ||
let attr = -500; | ||
let value = 1; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
let res = await dbStmt.setStmtAttr(attr, value); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
//if successful returns String or Int depending on attribute | ||
describe('getStmtAttr', function () { | ||
it('if statement attribute exsits should return type String or Int depending on the attribute type', async function () { | ||
var attr = dba.SQL_ATTR_FOR_FETCH_ONLY; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
var res = await dbStmt.getStmtAttr(attr); | ||
console.log("Smt Attr: "+res); | ||
expect(res).to.satisfy(function(res){ | ||
return res === 'string' || typeof res == 'number' | ||
}); | ||
}); | ||
}) | ||
describe('getStmtAttr', () => { | ||
it('if statement attribute exsits should return type String or Int depending on the attribute type', async () => { | ||
let attr = dba.SQL_ATTR_FOR_FETCH_ONLY; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
let res = await dbStmt.getStmtAttr(attr); | ||
console.log('Smt Attr: '+res); | ||
expect(res).to.satisfy(function(res){ | ||
return res === 'string' || typeof res === 'number'; | ||
}); | ||
}); | ||
}); | ||
describe('getStmtAttrFail', function () { | ||
it('error caused by providing invalid attr as a param.', async function () { | ||
//insert invalid attr | ||
var attr = 2; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
var res = await dbStmt.getStmtAttr(attr); | ||
expect(res).to.satisfy(function(res){ | ||
return res === 'string' || typeof res == 'number' | ||
}); | ||
}); | ||
}) | ||
describe('getStmtAttrFail', () => { | ||
it('error caused by providing invalid attr as a param.', async () => { | ||
//insert invalid attr | ||
let attr = 2; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
let res = await dbStmt.getStmtAttr(attr); | ||
expect(res).to.satisfy(function(res){ | ||
return res === 'string' || typeof res === 'number'; | ||
}); | ||
}); | ||
}); | ||
// whats the passing use case for next Result? | ||
// describe('nextResult', function () { | ||
// it('Determines whether there is more information available on the statement', async function () { | ||
// var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
// var dbStmt = new dba.Connection().connect().getStatement(); | ||
// describe('nextResult', () => { | ||
// it('Determines whether there is more information available on the statement', async () => { | ||
// let sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
// let dbStmt = new dba.Connection().connect().getStatement(); | ||
// await dbStmt.prepare(sql); | ||
// await dbStmt.execute(); | ||
// var res = await dbStmt.nextResult(); | ||
// let res = await dbStmt.nextResult(); | ||
// expect(res).to.be.a('object'); | ||
@@ -658,31 +656,31 @@ // }); | ||
describe('nextResultFail', function () { | ||
it('err', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var res = await dbStmt.nextResult(); | ||
expect(res).to.be.a('object'); | ||
}); | ||
}) | ||
describe('nextResultFail', () => { | ||
it('err', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let res = await dbStmt.nextResult(); | ||
expect(res).to.be.a('object'); | ||
}); | ||
}); | ||
//if successful returns undefined | ||
describe('rollback', function () { | ||
it('Rollback all changes to the database that have been made on the connection', async function () { | ||
var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
var dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
var res = await dbStmt.rollback(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}) | ||
describe('rollback', () => { | ||
it('Rollback all changes to the database that have been made on the connection', async () => { | ||
let sql = 'SELECT * FROM AMUSSE.TABLE1'; | ||
let dbStmt = new dba.Connection().connect().getStatement(); | ||
await dbStmt.prepare(sql); | ||
await dbStmt.execute(); | ||
let res = await dbStmt.rollback(); | ||
expect(res).to.be.a('undefined'); | ||
}); | ||
}); | ||
// need to create fail case for rollback | ||
// describe('rollbackFail', function () { | ||
// it('error caused by ', async function () { | ||
// var res = await dbStmt.rollback(); | ||
// var sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
// var dbStmt = new dba.Connection().connect().getStatement(); | ||
// describe('rollbackFail', () => { | ||
// it('error caused by ', async () => { | ||
// let res = await dbStmt.rollback(); | ||
// let sql = "SELECT * FROM AMUSSE.TABLE1"; | ||
// let dbStmt = new dba.Connection().connect().getStatement(); | ||
// await dbStmt.prepare(sql); | ||
@@ -695,6 +693,6 @@ // //await dbStmt.execute(); | ||
//how to test this? | ||
// describe('stmtError' , function() { | ||
// describe('stmtError' , () => { | ||
// it('Returns the diagnostic information ', async function(){ | ||
// var dbStmt = new dba.Connection().connect().getStatement(); | ||
// it('Returns the diagnostic information ', async () =>{ | ||
// let dbStmt = new dba.Connection().connect().getStatement(); | ||
// await dbStmt.stmtError(hType, recno); | ||
@@ -706,6 +704,6 @@ | ||
// need to create failure case for stmtErr | ||
// describe('stmtError' , function() { | ||
// describe('stmtError' , () => { | ||
// it('error was caused by: ', async function(){ | ||
// var dbStmt = new dba.Connection().connect().getStatement(); | ||
// it('error was caused by: ', async () =>{ | ||
// let dbStmt = new dba.Connection().connect().getStatement(); | ||
// await dbStmt.stmtError(hType, recno); | ||
@@ -712,0 +710,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
108767
7
0
2010