Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replace deprecated util.isDate usage
Deprecated in Node.js 21/22
  • Loading branch information
dxg committed Mar 13, 2025
commit fcbbb60a7f2c8d99edbb09aeebdf1494f9d8394a
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 1 addition & 2 deletions lib/Dialects/mssql.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var util = require("util");
var helpers = require("../Helpers");

exports.DataTypes = {
Expand Down Expand Up @@ -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' }) + "'";
}

Expand Down
3 changes: 1 addition & 2 deletions lib/Dialects/mysql.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var util = require("util");
var helpers = require("../Helpers");

exports.DataTypes = {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions lib/Dialects/postgresql.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var util = require("util");
var helpers = require("../Helpers");

exports.DataTypes = {
Expand Down Expand Up @@ -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' }) + "'";
}

Expand Down
4 changes: 1 addition & 3 deletions lib/Dialects/sqlite.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var util = require("util");
var helpers = require("../Helpers");


exports.DataTypes = {
isSQLITE: true,
id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
Expand Down Expand Up @@ -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' }) + "'";
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down