Skip to content
Closed
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 lib/protocol/SqlString.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ SqlString.arrayToList = function(array, timeZone) {

SqlString.format = function(sql, values, stringifyObjects, timeZone) {
values = values == null ? [] : [].concat(values);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for array copying, as you're not modifying it anymore. More win :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronkorving feel free to make a PR :) And remember that the values argument may not always be an array.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, I missed that it can be an object too. Then there's nothing to gain here. My bad.


var index = 0;
return sql.replace(/\?\??/g, function(match) {
if (!values.length) {
if (index>=values.length) {
return match;
}

if (match == "??") {
return SqlString.escapeId(values.shift());
return SqlString.escapeId(values[index++]);
}
return SqlString.escape(values.shift(), stringifyObjects, timeZone);
return SqlString.escape(values[index++], stringifyObjects, timeZone);
});
};

Expand Down