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
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '0.8'
- '0.10'
- '0.12'
- 'iojs'
- '4'
- '6'
- '8'
- '10'
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v0.1.27 - 27 Jun 2018

- Handle objects & symbols causing crash in driver 'escapeVal' (#54)

### v0.1.26 - 16 May 2015

- Add support for SELECT TOP construct for mssql dialect for limit (#41)
Expand Down
6 changes: 5 additions & 1 deletion lib/Dialects/mssql.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.escapeId = function () {
};

exports.escapeVal = function (val, timeZone) {
if (val === undefined || val === null) {
if (val === undefined || val === null || typeof val === "symbol") {
return 'NULL';
}

Expand Down Expand Up @@ -60,6 +60,10 @@ exports.escapeVal = function (val, timeZone) {
return val ? 1 : 0;
case "function":
return val(exports);
case "string":
break;
default:
val = JSON.stringify(val);
}

return "'" + val.replace(/\'/g, "''") + "'";
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialects/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.escapeId = function () {
};

exports.escapeVal = function (val, timeZone) {
if (val === undefined || val === null) {
if (val === undefined || val === null || typeof val === "symbol") {
return 'NULL';
}

Expand Down
6 changes: 5 additions & 1 deletion lib/Dialects/postgresql.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.escapeId = function () {
};

exports.escapeVal = function (val, timeZone) {
if (val === undefined || val === null) {
if (val === undefined || val === null || typeof val === "symbol") {
return 'NULL';
}

Expand Down Expand Up @@ -60,6 +60,10 @@ exports.escapeVal = function (val, timeZone) {
return val ? "true" : "false";
case "function":
return val(exports);
case "string":
break;
default:
val = JSON.stringify(val);
}
// No need to escape backslashes with default PostgreSQL 9.1+ config.
// Google 'postgresql standard_conforming_strings' for details.
Expand Down
6 changes: 5 additions & 1 deletion lib/Dialects/sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.escape = function (query, args) {
exports.escapeId = require("./mysql").escapeId;

exports.escapeVal = function (val, timeZone) {
if (val === undefined || val === null) {
if (val === undefined || val === null || typeof val === "symbol") {
return 'NULL';
}

Expand Down Expand Up @@ -48,6 +48,10 @@ exports.escapeVal = function (val, timeZone) {
return val ? 1 : 0;
case "function":
return val(exports);
case "string":
break;
default:
val = JSON.stringify(val);
}

// No need to escape backslashes with default PostgreSQL 9.1+ config.
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

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

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
"keywords": [
"sql",
"query"
],
"version": "0.1.26",
],
"version": "0.1.27",
"license": "MIT",
"repository": {
"url": "http://github.com/dresende/node-sql-query"
},
"contributors": [
{ "name" : "Benjamin Pannell", "email" : "admin@sierrasoftworks.com" },
{ "name" : "Arek W" }
{
"name": "Benjamin Pannell",
"email": "admin@sierrasoftworks.com"
},
{
"name": "Arek W"
}
],
"scripts": {
"test": "make"
Expand Down
10 changes: 10 additions & 0 deletions test/integration/test-dialect-mssql.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ assert.equal(
"0"
);

assert.equal(
dialect.escapeVal({ key: 'value' }),
"'{\"key\":\"value\"}'"
);

assert.equal(
dialect.escapeVal(Symbol("why does this exist")),
"NULL"
)

assert.equal(
dialect.escapeVal(new Date(d.getTime() + tzOffsetMillis)),
"'2013-09-04 19:15:11.133'"
Expand Down
10 changes: 10 additions & 0 deletions test/integration/test-dialect-mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ assert.equal(
"false"
);

assert.equal(
dialect.escapeVal({ key: 'value' }),
"`key` = 'value'"
);

assert.equal(
dialect.escapeVal(Symbol("why does this exist")),
"NULL"
)

assert.equal(
dialect.escapeVal(new Date(d.getTime() + tzOffsetMillis)),
"'2013-09-04 19:15:11.133'"
Expand Down
10 changes: 10 additions & 0 deletions test/integration/test-dialect-postgresql.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ assert.equal(
"false"
);

assert.equal(
dialect.escapeVal({ key: 'value' }),
"'{\"key\":\"value\"}'"
);

assert.equal(
dialect.escapeVal(Symbol("why does this exist")),
"NULL"
)

assert.equal(
dialect.escapeVal(new Date(d.getTime() + tzOffsetMillis)),
"'2013-09-04 19:15:11.133'"
Expand Down
10 changes: 10 additions & 0 deletions test/integration/test-dialect-sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ assert.equal(
"0"
);

assert.equal(
dialect.escapeVal({ key: 'value' }),
"'{\"key\":\"value\"}'"
);

assert.equal(
dialect.escapeVal(Symbol("why does this exist")),
"NULL"
)

assert.equal(
dialect.escapeVal(new Date(d.getTime() + tzOffsetMillis)),
"'2013-09-04 19:15:11.133'"
Expand Down