diff --git a/Changelog.md b/Changelog.md index 442b57b..b0f649a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +### v0.1.28 - 13 March 2025 + +- Replace deprecated (in Node.js 22) `util.isDate(val)` with `val instanceof Date` + ### v0.1.27 - 27 Jun 2018 - Handle objects & symbols causing crash in driver 'escapeVal' (#54) diff --git a/lib/Dialects/mssql.js b/lib/Dialects/mssql.js index 3a2702f..d5c4246 100644 --- a/lib/Dialects/mssql.js +++ b/lib/Dialects/mssql.js @@ -1,4 +1,3 @@ -var util = require("util"); var helpers = require("../Helpers"); exports.DataTypes = { @@ -41,7 +40,7 @@ exports.escapeVal = function (val, timeZone) { return "(" + val.map(exports.escapeVal.bind(this)).join(", ") + ")"; } - if (util.isDate(val)) { + if (val instanceof Date) { return "'" + helpers.dateToString(val, timeZone || "local", { dialect: 'mssql' }) + "'"; } diff --git a/lib/Dialects/mysql.js b/lib/Dialects/mysql.js index 239727a..7d8ec98 100644 --- a/lib/Dialects/mysql.js +++ b/lib/Dialects/mysql.js @@ -1,4 +1,3 @@ -var util = require("util"); var helpers = require("../Helpers"); exports.DataTypes = { @@ -42,7 +41,7 @@ exports.escapeVal = function (val, timeZone) { return arrayToList(val, timeZone || "local"); } - if (util.isDate(val)) { + if (val instanceof Date) { val = helpers.dateToString(val, timeZone || "local", { dialect: 'mysql' }); } else { switch (typeof val) { diff --git a/lib/Dialects/postgresql.js b/lib/Dialects/postgresql.js index b2a269c..0a42d72 100644 --- a/lib/Dialects/postgresql.js +++ b/lib/Dialects/postgresql.js @@ -1,4 +1,3 @@ -var util = require("util"); var helpers = require("../Helpers"); exports.DataTypes = { @@ -41,7 +40,7 @@ exports.escapeVal = function (val, timeZone) { return "(" + val.map(exports.escapeVal.bind(this)).join(", ") + ")"; } - if (util.isDate(val)) { + if (val instanceof Date) { return "'" + helpers.dateToString(val, timeZone || "local", { dialect: 'postgresql' }) + "'"; } diff --git a/lib/Dialects/sqlite.js b/lib/Dialects/sqlite.js index 547d9f5..4ec0a34 100644 --- a/lib/Dialects/sqlite.js +++ b/lib/Dialects/sqlite.js @@ -1,7 +1,5 @@ -var util = require("util"); var helpers = require("../Helpers"); - exports.DataTypes = { isSQLITE: true, id: 'INTEGER PRIMARY KEY AUTOINCREMENT', @@ -29,7 +27,7 @@ exports.escapeVal = function (val, timeZone) { return "(" + val.map(exports.escapeVal.bind(this)).join(", ") + ")"; } - if (util.isDate(val)) { + if (val instanceof Date) { return "'" + helpers.dateToString(val, timeZone || "local", { dialect: 'sqlite' }) + "'"; } diff --git a/package-lock.json b/package-lock.json index fc9ede4..27767b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sql-query", - "version": "0.1.27", + "version": "0.1.28", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a765828..0d398d5 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "sql", "query" ], - "version": "0.1.27", + "version": "0.1.28", "license": "MIT", "repository": { "url": "http://github.com/dresende/node-sql-query"