33// This file is licensed under the Artistic License 2.0.
44// License text available at https://opensource.org/licenses/Artistic-2.0
55
6+ 'use strict' ;
7+
68var g = require ( './globalize' ) ;
79
810/*!
@@ -96,7 +98,6 @@ IBMDB.prototype.setConnectionProperties = function(name, settings) {
9698 }
9799} ;
98100
99-
100101IBMDB . prototype . parseDSN = function ( dsn ) {
101102 // Split dsn into an array of optionStr
102103 var dsnOption = dsn . split ( ';' ) ;
@@ -192,7 +193,7 @@ IBMDB.prototype.connect = function(cb) {
192193 self . dataSource . connecting = false ;
193194 self . dataSource . emit ( 'connected' ) ;
194195 }
195- cb && cb ( err , con ) ;
196+ return cb && cb ( err , con ) ;
196197 } ) ;
197198} ;
198199
@@ -216,7 +217,7 @@ IBMDB.prototype.escapeName = function(name) {
216217 */
217218IBMDB . prototype . executeSQL = function ( sql , params , options , callback ) {
218219 debug ( 'IBMDB.prototype.executeSQL (enter)' ,
219- sql , params , options ) ;
220+ sql , params , options ) ;
220221
221222 var self = this ;
222223
@@ -226,7 +227,7 @@ IBMDB.prototype.executeSQL = function(sql, params, options, callback) {
226227 var stmt = { } ;
227228
228229 stmt . noResults = options && options . noResultSet ?
229- options . noResultSet : false ;
230+ options . noResultSet : false ;
230231
231232 // This is standard DB2 syntax. LIMIT and OFFSET
232233 // are configured off by default. Enable these to
@@ -253,8 +254,8 @@ IBMDB.prototype.executeSQL = function(sql, params, options, callback) {
253254
254255 conn . query ( stmt , function ( err , data , more ) {
255256 debug ( 'IBMDB.prototype.executeSQL (exit)' +
256- ' stmt=%j params=%j err=%j data=%j more=%j' ,
257- stmt , params , err , data , more ) ;
257+ ' stmt=%j params=%j err=%j data=%j more=%j' ,
258+ stmt , params , err , data , more ) ;
258259 // schedule callback as there is more code to
259260 // execute in the db2 driver to cleanup the current query
260261 if ( offset || limit ) {
@@ -269,7 +270,7 @@ IBMDB.prototype.executeSQL = function(sql, params, options, callback) {
269270 }
270271 }
271272
272- cb && cb ( err , data ) ;
273+ return cb && cb ( err , data ) ;
273274 } ) ;
274275 } ;
275276
@@ -290,12 +291,12 @@ IBMDB.prototype.executeSQL = function(sql, params, options, callback) {
290291} ;
291292
292293function dateToIBMDB ( val ) {
293- var dateStr = val . getFullYear ( ) + '-'
294- + fillZeros ( val . getMonth ( ) + 1 ) + '-'
295- + fillZeros ( val . getDate ( ) ) + '-'
296- + fillZeros ( val . getHours ( ) ) + '.'
297- + fillZeros ( val . getMinutes ( ) ) + '.'
298- + fillZeros ( val . getSeconds ( ) ) + '.' ;
294+ var dateStr = val . getFullYear ( ) + '-' +
295+ fillZeros ( val . getMonth ( ) + 1 ) + '-' +
296+ fillZeros ( val . getDate ( ) ) + '-' +
297+ fillZeros ( val . getHours ( ) ) + '.' +
298+ fillZeros ( val . getMinutes ( ) ) + '.' +
299+ fillZeros ( val . getSeconds ( ) ) + '.' ;
299300 var ms = val . getMilliseconds ( ) ;
300301 if ( ms < 10 ) {
301302 ms = '00000' + ms ;
@@ -403,7 +404,6 @@ IBMDB.prototype.getPlaceholderForValue = function(key) {
403404 return '(?)' ;
404405} ;
405406
406-
407407/**
408408 * Build the clause for default values if the fields is empty
409409 *
@@ -453,7 +453,7 @@ IBMDB.prototype.updateOrCreate = IBMDB.prototype.save =
453453
454454 connection . query ( countStmt , function ( err , countData ) {
455455 debug ( 'IBMDB.prototype.updateOrCreate (data): err=%j, countData=%j\n' ,
456- err , countData ) ;
456+ err , countData ) ;
457457
458458 if ( err ) return cb ( err ) ;
459459
@@ -467,7 +467,7 @@ IBMDB.prototype.updateOrCreate = IBMDB.prototype.save =
467467
468468 connection . query ( stmt , function ( err , sData ) {
469469 debug ( 'IBMDB.prototype.updateOrCreate (data): err=%j, sData=%j\n' ,
470- err , sData ) ;
470+ err , sData ) ;
471471
472472 if ( err ) return cb ( err ) ;
473473
@@ -547,7 +547,7 @@ IBMDB.prototype._replace = function(model, where, data, options, callback) {
547547
548548 connection . query ( selectStmt , function ( err , selectData ) {
549549 debug ( 'IBMDB.prototype._replace stmt: %j data: %j err: %j\n' ,
550- selectStmt , selectData , err ) ;
550+ selectStmt , selectData , err ) ;
551551 if ( err ) return cb ( err ) ;
552552
553553 if ( selectData . length > 0 ) {
@@ -556,7 +556,7 @@ IBMDB.prototype._replace = function(model, where, data, options, callback) {
556556 stmt . noResults = true ;
557557 connection . query ( stmt , function ( err , res ) {
558558 debug ( 'IBMDB.prototype._replace stmt: %j data: %j err=%j\n' ,
559- stmt , res , err ) ;
559+ stmt , res , err ) ;
560560
561561 if ( err ) return cb ( err ) ;
562562
@@ -565,7 +565,7 @@ IBMDB.prototype._replace = function(model, where, data, options, callback) {
565565
566566 connection . query ( stmt , function ( err , sData ) {
567567 debug ( 'IBMDB.prototype._replace stmt: %j data: %j err=%j\n' ,
568- stmt , sData , err ) ;
568+ stmt , sData , err ) ;
569569 if ( err ) return cb ( err ) ;
570570
571571 meta . isNewInstance = ( selectData . length > 0 ) ;
@@ -647,7 +647,7 @@ IBMDB.prototype.replaceOrCreate = function(model, data, options, callback) {
647647
648648 connection . query ( selectStmt , function ( err , selectData ) {
649649 debug ( 'IBMDB.prototype.replaceOrCreate stmt: %j data: %j err: %j\n' ,
650- selectStmt , selectData , err ) ;
650+ selectStmt , selectData , err ) ;
651651 if ( err ) return cb ( err ) ;
652652
653653 if ( selectData . length > 0 ) {
@@ -656,15 +656,15 @@ IBMDB.prototype.replaceOrCreate = function(model, data, options, callback) {
656656 stmt . noResults = true ;
657657 connection . query ( stmt , function ( err , res ) {
658658 debug ( 'IBMDB.prototype.replaceOrCreate stmt: %j data: %j err=%j\n' ,
659- stmt , res , err ) ;
659+ stmt , res , err ) ;
660660
661661 if ( err ) return cb ( err ) ;
662662
663663 stmt = self . buildInsert ( model , data ) ;
664664
665665 connection . query ( stmt , function ( err , sData ) {
666666 debug ( 'IBMDB.prototype.replaceOrCreate stmt: %j data: %j err=%j\n' ,
667- stmt , sData , err ) ;
667+ stmt , sData , err ) ;
668668 if ( err ) return cb ( err ) ;
669669
670670 meta . isNewInstance = ( selectData . length === 0 ) ;
@@ -677,7 +677,7 @@ IBMDB.prototype.replaceOrCreate = function(model, data, options, callback) {
677677
678678 connection . query ( stmt , function ( err , sData ) {
679679 debug ( 'IBMDB.prototype.replaceOrCreate stmt: %j data: %j err=%j\n' ,
680- stmt , sData , err ) ;
680+ stmt , sData , err ) ;
681681 if ( err ) return cb ( err ) ;
682682
683683 meta . isNewInstance = ( selectData . length === 0 ) ;
@@ -725,7 +725,7 @@ IBMDB.prototype.replaceOrCreate = function(model, data, options, callback) {
725725
726726IBMDB . prototype . buildReplace = function ( model , where , data , options ) {
727727 debug ( 'IBMDB.prototype.buildReplace: model=$s, where=%j, options=%j' ,
728- model , where , options ) ;
728+ model , where , options ) ;
729729 var self = this ;
730730 var idName = self . idName ( model ) ;
731731 var fields = self . buildFieldsForReplace ( model , data ) ;
@@ -743,7 +743,7 @@ IBMDB.prototype.buildReplace = function(model, where, data, options) {
743743IBMDB . prototype . getCountForAffectedRows = function ( model , info ) {
744744 var affectedRows = info && info [ 0 ] &&
745745 typeof info [ 0 ] . affectedRows === 'number' ?
746- info [ 0 ] . affectedRows : undefined ;
746+ info [ 0 ] . affectedRows : undefined ;
747747 return affectedRows ;
748748} ;
749749
@@ -758,7 +758,6 @@ IBMDB.prototype.createTable = function(model, cb) {
758758 noResultSet : true ,
759759 } ;
760760
761-
762761 tasks . push ( function ( callback ) {
763762 var sql = 'CREATE TABLE ' + tableSchema + '.' + tableName +
764763 ' (' + columnDefinitions + ');' ;
@@ -873,8 +872,8 @@ IBMDB.prototype.buildIndexes = function(model) {
873872 var statement = new ParameterizedSQL ( 'CREATE' ) ;
874873 if ( i . kind ) {
875874 statement . merge ( i . kind ) ;
876- } else if ( ( i . options && i . options . unique && i . options . unique === true )
877- || i . unique ) {
875+ } else if ( ( i . options && i . options . unique && i . options . unique === true ) ||
876+ i . unique ) {
878877 // if index unique indicator is configured
879878 statement . merge ( 'UNIQUE' ) ;
880879 }
@@ -933,7 +932,7 @@ IBMDB.prototype.columnDataType = function(model, property) {
933932
934933IBMDB . prototype . buildColumnType = function buildColumnType ( propertyDefinition ) {
935934 debug ( 'IBMDB.prototype.buildColumnType: propertyDefinition=%j' ,
936- propertyDefinition ) ;
935+ propertyDefinition ) ;
937936 var self = this ;
938937 var dt = '' ;
939938 var p = propertyDefinition ;
@@ -1062,7 +1061,7 @@ IBMDB.prototype.applyPagination = function(model, stmt, filter) {
10621061
10631062function errorIdNotFoundForReplace ( idValue ) {
10641063 var msg = g . f ( 'Could not replace. Object with id %s does not exist!' ,
1065- idValue ) ;
1064+ idValue ) ;
10661065 var error = new Error ( msg ) ;
10671066 error . statusCode = error . status = 404 ;
10681067 return error ;
0 commit comments