Navigation Menu

Skip to content

Commit

Permalink
bq: throw exception for garbage after filter value
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 6, 2012
1 parent 1199141 commit 7407fc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/bq-translator.js
Expand Up @@ -144,9 +144,10 @@ BooleanQueryTranslator.prototype = {
this.skipSpaces();
var expression = this.translateExpressionValueUnsignedInteger(field);
this.skipSpaces();
if (this.query[this.offset] != ")") {
// TODO: report error: have garbage
return "";
var character = this.query[this.offset];
if (character != ")") {
this.throwTranslateError("a garbage character after value: " +
"<" + character + ">");
}
this.offset++;
return expression;
Expand Down
5 changes: 5 additions & 0 deletions test/bq-translator.test.js
Expand Up @@ -164,6 +164,11 @@ suite('BoolanQueryTranslator', function() {
"(field ||",
"close parenthesis is missing: operator:<field>");

testGroupError("filter: garbage after value",
"(filter field1 29 'garbage')",
"(filter field1 29 |'|garbage')",
"a garbage character after value: <'>");

// testGroupError("and: missing close parentheis",
// "(and f1:'k1' f2:'k2'",
// "(and f1:'k1' f2:'k2'||",
Expand Down

0 comments on commit 7407fc1

Please sign in to comment.