Skip to content

Commit a73d031

Browse files
committed
Linted the tests, and made them use assert (before they only failed if the last object tested were not successful, and tracked success with a variable). Renamed the sql class to SqlCall. General cleanup
1 parent 5e7b983 commit a73d031

File tree

6 files changed

+260
-261
lines changed

6 files changed

+260
-261
lines changed

lib/Connection.js

-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ class Connection {
148148
}
149149
// Post the XML document to XML service program.
150150
if (this.conn.I_TRANSPORT === I_TRANSPORT_REST) {
151-
// const iCall = require('./irest'); // TODO: Moved to top level, make sure it doesnt break
152151
iRestHttp(callback,
153152
this.conn.I_TRANSPORT_REST_HOST,
154153
this.conn.I_TRANSPORT_REST_PORT,
@@ -161,7 +160,6 @@ class Connection {
161160
xml,
162161
this.conn.I_TRANSPORT_REST_XML_OUT_SIZE);
163162
} else if (this.conn.I_TRANSPORT === I_TRANSPORT_DB2) {
164-
// const db = require('./istoredp'); // TODO: Moved to top level, make sure it doesnt break
165163
db2Call(callback,
166164
this.conn.iXml_SERVICE_LIB,
167165
this.conn.I_TRANSPORT_DB2_DATABASE,

lib/ProgramCall.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ class ProgramCall {
2626
* @param {object} [options]
2727
*/
2828
constructor(program, options) {
29-
// TODO: what if there are some options but not others? iPgm is all or nothing
30-
if (options && typeof options === 'object' && options.lib && options.func && options.error) {
31-
this.xml = iXml.iXmlNodePgmOpen(program, options.lib, options.func, options.error);
29+
if (options && typeof options === 'object') {
30+
// add options if they exist, or empty string if they don't
31+
this.xml = iXml.iXmlNodePgmOpen(program,
32+
options.lib !== undefined ? options.lib : '',
33+
options.func !== undefined ? options.func : '',
34+
options.error !== undefined ? options.error : '');
3235
} else {
3336
this.xml = iXml.iXmlNodePgmOpen(program, '', '', '');
3437
}

lib/SqlGenerator.js renamed to lib/SqlCall.js

+26-26
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
const iXml = require('./ixml');
2020

21-
class SqlGenerator {
21+
class SqlCall {
2222
/**
23-
* @description Creates a new iSql object
23+
* @description Creates a new SqlCall
2424
* @constructor
2525
*/
2626
constructor() {
@@ -351,23 +351,23 @@ class iSql {
351351
* @constructor
352352
*/
353353
constructor() {
354-
this.sqlGenerator = new SqlGenerator();
354+
this.sqlCall = new SqlCall();
355355
}
356356

357357
/**
358358
* @description adds sql connect XML
359359
* @param {object} [options]
360360
*/
361361
connect(options) {
362-
this.sqlGenerator.connect(options);
362+
this.sqlCall.connect(options);
363363
}
364364

365365
/**
366366
* @description adds sql options XML
367367
* @param {object} options
368368
*/
369369
setOptions(options) {
370-
this.sqlGenerator.setOptions(options);
370+
this.sqlCall.setOptions(options);
371371
}
372372

373373
/**
@@ -376,7 +376,7 @@ class iSql {
376376
* @param {object} [options]
377377
*/
378378
addQuery(stmt, options) {
379-
this.sqlGenerator.addQuery(stmt, options);
379+
this.sqlCall.addQuery(stmt, options);
380380
}
381381

382382
/**
@@ -385,7 +385,7 @@ class iSql {
385385
* @param {object} [options]
386386
*/
387387
prepare(stmt, options) {
388-
this.sqlGenerator.prepare(stmt, options);
388+
this.sqlCall.prepare(stmt, options);
389389
}
390390

391391
/**
@@ -394,7 +394,7 @@ class iSql {
394394
* @param {object} [options]
395395
*/
396396
execute(params, options) {
397-
this.sqlGenerator.execute(params, options);
397+
this.sqlCall.execute(params, options);
398398
}
399399

400400
/**
@@ -403,7 +403,7 @@ class iSql {
403403
* @param {object} [options]
404404
*/
405405
tables(params, options) {
406-
this.sqlGenerator.tables(params, options);
406+
this.sqlCall.tables(params, options);
407407
}
408408

409409
/**
@@ -412,7 +412,7 @@ class iSql {
412412
* @param {object} [options]
413413
*/
414414
tablePriv(params, options) {
415-
this.sqlGenerator.tablePriv(params, options);
415+
this.sqlCall.tablePriv(params, options);
416416
}
417417

418418
/**
@@ -421,7 +421,7 @@ class iSql {
421421
* @param {object} [options]
422422
*/
423423
columns(params, options) {
424-
this.sqlGenerator.columns(params, options);
424+
this.sqlCall.columns(params, options);
425425
}
426426

427427
/**
@@ -430,7 +430,7 @@ class iSql {
430430
* @param {object} [options]
431431
*/
432432
special(params, options) {
433-
this.sqlGenerator.special(params, options);
433+
this.sqlCall.special(params, options);
434434
}
435435

436436
/**
@@ -439,7 +439,7 @@ class iSql {
439439
* @param {object} [options]
440440
*/
441441
columnPriv(params, options) {
442-
this.sqlGenerator.columnPriv(params, options);
442+
this.sqlCall.columnPriv(params, options);
443443
}
444444

445445
/**
@@ -448,7 +448,7 @@ class iSql {
448448
* @param {*} [options]
449449
*/
450450
procedures(params, options) {
451-
this.sqlGenerator.procedures(params, options);
451+
this.sqlCall.procedures(params, options);
452452
}
453453

454454
/**
@@ -457,7 +457,7 @@ class iSql {
457457
* @param {object} [options]
458458
*/
459459
pColumns(params, options) {
460-
this.sqlGenerator.pColumns(params, options);
460+
this.sqlCall.pColumns(params, options);
461461
}
462462

463463
/**
@@ -466,7 +466,7 @@ class iSql {
466466
* @param {object} [options]
467467
*/
468468
primaryKeys(params, options) {
469-
this.sqlGenerator.primaryKeys(params, options);
469+
this.sqlCall.primaryKeys(params, options);
470470
}
471471

472472
/**
@@ -475,7 +475,7 @@ class iSql {
475475
* @param {object} [options]
476476
*/
477477
foreignKeys(params, options) {
478-
this.sqlGenerator.foreignKeys(params, options);
478+
this.sqlCall.foreignKeys(params, options);
479479
}
480480

481481
/**
@@ -484,65 +484,65 @@ class iSql {
484484
* @param {object} [options]
485485
*/
486486
statistics(params, options) {
487-
this.sqlGenerator.statistics(params, options);
487+
this.sqlCall.statistics(params, options);
488488
}
489489

490490
/**
491491
* @description adds sql commit XML
492492
* @param {object} options
493493
*/
494494
commit(options) {
495-
this.sqlGenerator.commit(options);
495+
this.sqlCall.commit(options);
496496
}
497497

498498
/**
499499
* @description adds sql row count XML
500500
* @param {object} options
501501
*/
502502
rowCount(options) {
503-
this.sqlGenerator.rowCount(options);
503+
this.sqlCall.rowCount(options);
504504
}
505505

506506
/**
507507
* @description adds sql row count XML
508508
* @param {object} options
509509
*/
510510
count(options) {
511-
this.sqlGenerator.count(options);
511+
this.sqlCall.count(options);
512512
}
513513

514514
/**
515515
* @description adds sql describe XML
516516
* @param {object} options
517517
*/
518518
describe(options) {
519-
this.sqlGenerator.describe(options);
519+
this.sqlCall.describe(options);
520520
}
521521

522522
/**
523523
* @description adds sql fetch XML
524524
* @param {object} options
525525
*/
526526
fetch(options) {
527-
this.sqlGenerator.fetch(options);
527+
this.sqlCall.fetch(options);
528528
}
529529

530530
/**
531531
* @description adds sql free XML
532532
*/
533533
free() {
534-
this.sqlGenerator.free();
534+
this.sqlCall.free();
535535
}
536536

537537
/**
538538
* @description returns the current sql XML
539539
* @returns {string} - the generted sql XML
540540
*/
541541
toXML() {
542-
return this.sqlGenerator.toXML();
542+
return this.sqlCall.toXML();
543543
}
544544
}
545545

546546
// iSql is the deprecated version of the class. Removed at a later time.
547547
module.exports.iSql = iSql;
548-
module.exports.SqlGenerator = SqlGenerator;
548+
module.exports.SqlCall = SqlCall;

lib/Toolkit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ class Toolkit {
11291129
if (!cb) { // If we do not get the third param,
11301130
if (option) { // If we get two params,
11311131
if (typeof option === 'function') { // If it is a function,
1132-
callback = option; // then it is the callback. // TODO: This just needs work for linting
1132+
callback = option; // then it is the callback.
11331133
}
11341134
} else { // If we have only one param,
11351135
prodOption = '0000'; // then use *BASE as default.

lib/itoolkit.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const {
3333
} = require('./CommandGenerator');
3434

3535
const {
36-
SqlGenerator,
36+
SqlCall,
3737
iSql, // deprecated
38-
} = require('./SqlGenerator');
38+
} = require('./SqlCall');
3939

4040
const {
4141
Connection,
@@ -56,7 +56,7 @@ const {
5656
module.exports = {
5757
CommandGenerator,
5858
ProgramCall,
59-
SqlGenerator,
59+
SqlCall,
6060
Connection,
6161
Toolkit,
6262
xmlToJson,

0 commit comments

Comments
 (0)