Comparing version 0.0.9 to 0.0.10
@@ -7,17 +7,22 @@ exports.escapeId = function () { | ||
exports.escapeVal = function (value, timeZone) { | ||
if (Array.isArray(value)) { | ||
if (value.length === 1 && Array.isArray(value[0])) { | ||
return "(" + value[0].map(exports.escapeVal.bind(this)) + ")"; | ||
exports.escapeVal = function (val, timeZone) { | ||
if (val === undefined || val === null) { | ||
return 'NULL'; | ||
} | ||
if (Array.isArray(val)) { | ||
if (val.length === 1 && Array.isArray(val[0])) { | ||
return "(" + val[0].map(exports.escapeVal.bind(this)) + ")"; | ||
} | ||
return "(" + value.map(exports.escapeVal.bind(this)).join(", ") + ")"; | ||
return "(" + val.map(exports.escapeVal.bind(this)).join(", ") + ")"; | ||
} | ||
switch (typeof value) { | ||
switch (typeof val) { | ||
case "number": | ||
return value; | ||
return val; | ||
case "boolean": | ||
return value ? "true" : "false"; | ||
return val ? "true" : "false"; | ||
} | ||
return "'" + value.replace(/\'/g, "''") + "'"; | ||
// No need to escape backslashes with default PostgreSQL 9.1+ config. | ||
// Google 'postgresql standard_conforming_strings' for details. | ||
return "'" + val.replace(/\'/g, "''") + "'"; | ||
}; |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"license": "MIT", | ||
@@ -12,0 +12,0 @@ "repository": { |
@@ -21,2 +21,12 @@ var common = require('../common'); | ||
assert.equal( | ||
dialect.escapeVal(undefined), | ||
'NULL' | ||
); | ||
assert.equal( | ||
dialect.escapeVal(null), | ||
'NULL' | ||
); | ||
assert.equal( | ||
dialect.escapeVal(123), | ||
@@ -23,0 +33,0 @@ "123" |
@@ -7,3 +7,3 @@ var common = require('../common'); | ||
dialect.escapeId('col'), | ||
"\"col\"" | ||
'"col"' | ||
); | ||
@@ -13,3 +13,3 @@ | ||
dialect.escapeId('table', 'col'), | ||
"\"table\".\"col\"" | ||
'"table"."col"' | ||
); | ||
@@ -19,6 +19,16 @@ | ||
dialect.escapeId('table', 'co"l'), | ||
"\"table\".\"co\"\"l\"" | ||
'"table"."co""l"' | ||
); | ||
assert.equal( | ||
dialect.escapeVal(undefined), | ||
'NULL' | ||
); | ||
assert.equal( | ||
dialect.escapeVal(null), | ||
'NULL' | ||
); | ||
assert.equal( | ||
dialect.escapeVal(123), | ||
@@ -25,0 +35,0 @@ "123" |
@@ -21,2 +21,12 @@ var common = require('../common'); | ||
assert.equal( | ||
dialect.escapeVal(undefined), | ||
'NULL' | ||
); | ||
assert.equal( | ||
dialect.escapeVal(null), | ||
'NULL' | ||
); | ||
assert.equal( | ||
dialect.escapeVal(123), | ||
@@ -23,0 +33,0 @@ "123" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27968
967
1000