Skip to content

Commit 48815f3

Browse files
committed
Allow passing nulls to select functions.
Closes dresende#32
1 parent 9eaf44c commit 48815f3

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/Select.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ function SelectQuery(Dialect, opts) {
258258

259259
if (Array.isArray(sql.from[i].select[j].c)) {
260260
str += sql.from[i].select[j].c.map(function (el) {
261+
if (!el) {
262+
return Dialect.escapeVal(el);
263+
}
261264
if (typeof el.type == "function") {
262265
switch (el.type()) {
263266
case "text":

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"sql",
77
"query"
88
],
9-
"version": "0.1.18",
9+
"version": "0.1.19",
1010
"license": "MIT",
1111
"repository": {
1212
"url": "http://github.com/dresende/node-sql-query"

test/integration/test-select-type.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ assert.equal(
1111
"SELECT MYFUN(`col1`, `col2`) FROM `table1`"
1212
);
1313

14+
assert.equal(
15+
common.Select().from('table1').fun('dbo.fnBalance', [ 80, null, null], 'balance').build(),
16+
"SELECT DBO.FNBALANCE(80, NULL, NULL) AS `balance` FROM `table1`"
17+
);
18+
1419
assert.equal(
1520
common.Select().from('table1').fun('myfun', [ 'col1', 'col2'], 'alias').build(),
1621
"SELECT MYFUN(`col1`, `col2`) AS `alias` FROM `table1`"

0 commit comments

Comments
 (0)