Skip to content

Commit 2282c46

Browse files
author
Derek
authored
https://github.com/mysqljs/mysql/issues/559
SqlString.escape maps both JavaScript null and undefined to MySQL NULL. This change proposes JavaScript undefined be mapped to MySQL DEFAULT, as per feature request mysqljs/mysql#559 and as discussed in mysqljs/mysql#1568.
1 parent 0c89dc1 commit 2282c46

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/SqlString.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ SqlString.escapeId = function escapeId(val, forbidQualified) {
3131
};
3232

3333
SqlString.escape = function escape(val, stringifyObjects, timeZone) {
34-
if (val === undefined || val === null) {
34+
if (val === null) {
3535
return 'NULL';
3636
}
37-
37+
38+
if (val === undefined) {
39+
return 'DEFAULT';
40+
}
41+
3842
switch (typeof val) {
3943
case 'boolean': return (val) ? 'true' : 'false';
4044
case 'number': return val+'';

0 commit comments

Comments
 (0)