Comparing version 0.1.0 to 0.1.1
@@ -0,2 +1,31 @@ | ||
var util = require("util"); | ||
exports.escapeId = require("./mysql").escapeId; | ||
exports.escapeVal = require("./postgresql").escapeVal; | ||
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 "(" + val.map(exports.escapeVal.bind(this)).join(", ") + ")"; | ||
} | ||
if (util.isDate(val)) { | ||
return "'" + JSON.stringify(val).substr(1, 24) + "'"; | ||
} | ||
if (Buffer.isBuffer(val)) { | ||
return "X'" + val.toString("hex") + "'"; | ||
} | ||
switch (typeof val) { | ||
case "number": | ||
return val; | ||
case "boolean": | ||
return val ? "true" : "false"; | ||
} | ||
// 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.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -12,0 +12,0 @@ "repository": { |
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
39546
1356