Skip to content

Commit

Permalink
Merge pull request #2 from redgeoff/insert-undefined
Browse files Browse the repository at this point in the history
feat(insert): handle undefined values
  • Loading branch information
redgeoff committed Dec 12, 2015
2 parents c5635c7 + b1304b0 commit 38c5077
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions scripts/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ SQL.prototype._escapeAndJoin = function (obj, raw) {
delim = '',
i = 1;
utils.each(obj, function (val, key) {
// if (typeof val !== 'undefined') { // TODO: remove?
keys += delim + self.escape(key);
if (raw && raw[key]) {
templates += delim + val;
} else {
templates += delim + self._template(i++);
values.push(val);
if (typeof val !== 'undefined') {
keys += delim + self.escape(key);
if (raw && raw[key]) {
templates += delim + val;
} else {
templates += delim + self._template(i++);
values.push(val);
}
delim = ',';
}
delim = ',';
// } // TODO: remove?
});
return {
attrs: keys,
Expand Down
3 changes: 2 additions & 1 deletion test/spec/adapters/common/test-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ Adapter.prototype.test = function () {
doc_id: '1',
name: 'thing',
value: 'write a song',
destroyed_at: 'NOW()'
destroyed_at: 'NOW()',
age: undefined
},
'attrs', 'id', ['destroyed_at'])
.then(function () {
Expand Down

0 comments on commit 38c5077

Please sign in to comment.