Skip to content

Commit

Permalink
Fix - add missing support for passing SQL stmt via msg.topic (#21)
Browse files Browse the repository at this point in the history
* Fix - add missing support for passing SQL stmt via msg.topic

Support for this functionality is documented in alasql.html "<p>The <code>msg.topic</code> can hold several SQL queries separated by <code>"

* Change the order from what source read a SQL query
  • Loading branch information
tmdoit authored and mathiasrw committed Jan 2, 2020
1 parent 2bf9699 commit e7cec71
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion node-red-contrib-alasql.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (RED) {
var node = this;
node.query = config.query;
node.on("input", function (msg) {
var sql = this.query || 'SELECT * FROM ?';
var sql = this.query || msg.topic || 'SELECT * FROM ?';
var bind = Array.isArray(msg.payload) ? msg.payload : [msg.payload];
alasql.promise(sql, bind)
.then(function (res) {
Expand Down

0 comments on commit e7cec71

Please sign in to comment.