Skip to content
Closed
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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
}
},
"files": [
"src/"
"examples/",
"src/",
"LICENSE",
"README.md"
],
"directories": {
"example": "examples"
Expand Down
6 changes: 3 additions & 3 deletions src/mssql.html
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@ <h3>Shameless request for beta testers...</h3>
return this.name ? 'node_label_italic' : '';
},
oneditprepare: function () {
if (this.parseMustache === undefined) {
this.parseMustache = true;
const node = this;
if (typeof node.parseMustache === 'undefined') {
node.parseMustache = true;
$('#node-input-parseMustache').prop('checked', true);
}
const node = this;
//ensure node.query is a string otherwise editor wont initialise
if (typeof node.query !== 'string') node.query = '';
//create the query editor
Expand Down
14 changes: 8 additions & 6 deletions src/mssql.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ module.exports = function (RED) {
// node-mssql 5.x to 6.x changes
// ConnectionPool.close() now returns a promise / callbacks will be executed once closing of the
if (node.pool && node.pool.close) {
node.pool.close().catch(() => {})
node.pool.close().catch(() => {});
}
if (updateStatusAndLog) node.status({ fill: 'grey', shape: 'dot', text: 'disconnected' });
node.poolConnect = null;
Expand Down Expand Up @@ -496,7 +496,7 @@ module.exports = function (RED) {
node.paramsOptType = config.paramsOptType || 'none';
node.rows = config.rows || 'rows';
node.rowsType = config.rowsType || 'msg';
node.parseMustache = config.parseMustache || true;
node.parseMustache = !(config.parseMustache === false || config.parseMustache === 'false'); // if not explicitly set to false, then enable mustache parsing

const setResult = function (msg, field, value, returnType = 0) {
// eslint-disable-next-line eqeqeq
Expand Down Expand Up @@ -752,10 +752,11 @@ module.exports = function (RED) {
}
}

const promises = [];
const resolvedTokens = {};
let tokens;
if (node.parseMustache) {
const promises = [];
const tokens = extractTokens(mustache.parse(msg.query));
const resolvedTokens = {};
tokens = extractTokens(mustache.parse(msg.query));
tokens.forEach(function (name) {
const envName = parseEnv(name);
if (envName) {
Expand Down Expand Up @@ -789,7 +790,8 @@ module.exports = function (RED) {
}
}
});

}
if (tokens && tokens.size > 0) {
Promise.all(promises).then(function () {
const value = mustache.render(msg.query, new NodeContext(msg, node.context(), null, false, resolvedTokens));
msg.query = value;
Expand Down
Loading