Skip to content

Commit

Permalink
Improve error message on invalid query to fix #1871 (#1903)
Browse files Browse the repository at this point in the history
Co-authored-by: vishal diyora <vishaldiyora@vishals-MacBook-Pro-2.local>
  • Loading branch information
vishal6557 and vishal diyora committed Mar 18, 2024
1 parent ce63775 commit 35aa279
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/alasqlparser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -2960,12 +2960,11 @@ TermsList
;

Term
: Literal
{ $$ = new yy.Term({termid:$1}); }
| Literal LPAR TermsList RPAR
{ $$ = new yy.Term({termid:$1,args:$3}); }
;

: Literal
{ $$ = {termid: $1}; }
| Literal LPAR TermsList RPAR
{ $$ = {termid:$1, args:$3}; }
;
Query
: QUESTIONDASH FuncValue
;
Expand Down
4 changes: 2 additions & 2 deletions src/alasqlparser.js

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

15 changes: 15 additions & 0 deletions test/test1871.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
}

describe('Test 1871 - n.Term is not a constructor', function () {
it('Sending xxx random data should give valid error', function () {
assert.throws(
() => alasql('xxx'),
{
message: "Parse error on line 1:\nxxx\n---^\nExpecting 'COLONDASH', got 'EOF'",
}
);
});
});

0 comments on commit 35aa279

Please sign in to comment.