Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/61date.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ stdfn.COALESCE = function () {
if (typeof arguments[i] == 'number' && isNaN(arguments[i])) continue;
return arguments[i];
}
return undefined;
return null; // Change this line at the bottom of stdfn.COALESCE
};

stdfn.USER = function () {
Expand Down
13 changes: 13 additions & 0 deletions test/test999.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if (typeof module !== 'undefined' && typeof require !== 'undefined') {
var alasql = require('../dist/alasql.js');
}

describe('Test COALESCE bugfix', function () {
it('Should return NULL if all arguments are null', function () {
// Pass a JavaScript undefined variable as a parameter ($1)
var res = alasql('SELECT COALESCE(NULL, $0) AS result', [undefined]);
if (res[0].result !== null) {
throw new Error('COALESCE returned undefined instead of null');
}
});
});