diff --git a/src/10start.js b/src/10start.js index 2a7c2eb4a8..f163ceaee4 100644 --- a/src/10start.js +++ b/src/10start.js @@ -31,7 +31,7 @@ /** AlaSQL - Main Alasql class @function - @param {string|function|object} sql - SQL-statement or data object for fuent interface + @param {string|function|object} sql - SQL-statement or data object for fluent interface @param {object} params - SQL parameters @param {function} cb - callback function @param {object} scope - Scope for nested queries @@ -120,6 +120,6 @@ alasql.debug = undefined; // Initial debug variable /*only-for-browser/* -var require = function(){return null}; // as alasqlparser.js is generated, we can not "remove" referenses to +var require = function(){return null}; // as alasqlparser.js is generated, we can not "remove" references to var __dirname = ''; //*/ diff --git a/src/38query.js b/src/38query.js index f08c1b6721..c42ee4910f 100755 --- a/src/38query.js +++ b/src/38query.js @@ -139,7 +139,7 @@ function queryfn3(query) { //console.log(85,query.data[0]); - // If groupping, then filter groups with HAVING function + // If grouping, then filter groups with HAVING function // console.log(query.havingfns); if (query.groupfn) { query.data = []; diff --git a/src/39dojoin.js b/src/39dojoin.js index 36b939f809..46f79dba89 100755 --- a/src/39dojoin.js +++ b/src/39dojoin.js @@ -16,7 +16,7 @@ function doJoin(query, scope, h) { // var res = query.selectfn(scope, query.params, alasql); // console.log("last",res); - // If there is a GROUP BY then pipe to groupping function + // If there is a GROUP BY then pipe to grouping function if (query.groupfn) { query.groupfn(scope, query.params, alasql); } else { diff --git a/src/423groupby.js b/src/423groupby.js index b094d85eac..792842c9cc 100755 --- a/src/423groupby.js +++ b/src/423groupby.js @@ -79,7 +79,7 @@ if(false) { var coljs = col2.split('\t')[1]; // Check, if aggregator exists but GROUP BY is not exists if (columnid === '') { - return '1'; // Create fictive groupping column for fictive GROUP BY + return '1'; // Create fictive grouping column for fictive GROUP BY } // else return "r['"+columnid+"']"; query.ingroup.push(columnid); diff --git a/src/426orderby.js b/src/426orderby.js index 47557b43bc..ae669b1b50 100755 --- a/src/426orderby.js +++ b/src/426orderby.js @@ -35,6 +35,11 @@ yy.Select.prototype.compileOrder = function (query, params) { // console.log(ord.expression instanceof yy.Column); if (ord.expression instanceof yy.NumValue) { + if (ord.expression.value > self.columns.length) { + throw new Error( + `You are trying to order by column number ${ord.expression.value} but you have only selected ${self.columns.length} columns.` + ); + } var v = self.columns[ord.expression.value - 1]; } else { var v = ord.expression; diff --git a/test/test238.json b/test/test238.json index 5bb1abba08..4dca1cc0b0 100644 --- a/test/test238.json +++ b/test/test238.json @@ -1 +1 @@ -[{"100": 100}] +[{"100":100}] \ No newline at end of file