Skip to content

Commit 9e199e4

Browse files
authored
Merge pull request #52 from strongloop/fix-undefined-value
fix fromColumnValue when val is undefined
2 parents a9060c6 + 9963bb5 commit 9e199e4

5 files changed

Lines changed: 29 additions & 4 deletions

File tree

lib/ibmdb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ IBMDB.prototype.toColumnValue = function(prop, val) {
372372
*/
373373
IBMDB.prototype.fromColumnValue = function(prop, val) {
374374
debug('IBMDB.prototype.fromColumnValue %j %j', prop, val);
375-
if (val === null || !prop) {
375+
if (val === undefined || val === null || !prop) {
376376
return val;
377377
}
378378
switch (prop.type.name) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"scripts": {
1818
"pretest": "eslint ./ && jscs ./",
1919
"lint": "eslint ./ && jscs ./",
20-
"test": "mocha --timeout 10000"
20+
"test": "mocha --timeout 10000 --require test/init.js test/*.js"
2121
},
2222
"dependencies": {
2323
"async": "^1.5.0",

test/connect.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/* eslint-env node, mocha */
77
var EventEmitter = require('events').EventEmitter;
88
var IBMDB = require('../').IBMDB;
9-
require('./init.js');
109

1110
describe('basic connector', function() {
1211
var ds = new EventEmitter;

test/functional.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright IBM Corp. 2016. All Rights Reserved.
2+
// Node module: loopback-connector-db2
3+
// This file is licensed under the Artistic License 2.0.
4+
// License text available at https://opensource.org/licenses/Artistic-2.0
5+
6+
'use strict';
7+
8+
/* eslint-env node, mocha */
9+
process.env.NODE_ENV = 'test';
10+
var assert = require('assert');
11+
var EventEmitter = require('events').EventEmitter;
12+
var IBMDB = require('../').IBMDB;
13+
14+
var db = new EventEmitter;
15+
16+
describe('functional test', function() {
17+
before(function(done) {
18+
db.connector = new IBMDB('db2', global.config);
19+
db.connector.dataSource = db;
20+
done();
21+
});
22+
it('`fromColumnValue` function', function(done) {
23+
var result = db.connector.fromColumnValue({}, undefined);
24+
assert.equal(result, undefined);
25+
done();
26+
});
27+
});

test/ibmdb.config.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
/* eslint-env node, mocha */
77
process.env.NODE_ENV = 'test';
8-
require('./init.js');
98
var assert = require('assert');
109

1110
var config;

0 commit comments

Comments
 (0)