Navigation Menu

Skip to content

Commit

Permalink
bq: throw exception for unknown group operator
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 6, 2012
1 parent ec2cebb commit d688218
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/bq-translator.js
Expand Up @@ -65,6 +65,7 @@ BooleanQueryTranslator.prototype = {
if (/^[a-z]$/.test(character)) {
operator += character;
} else if (character == " ") {
var operatorEndOffset = this.offset;
this.skipSpaces();
var expression;
switch (operator) {
Expand All @@ -81,8 +82,8 @@ BooleanQueryTranslator.prototype = {
expression = this.translateGroupSetOperation("||");
break;
default:
// TODO: report error: unknown operator
return "";
this.offset = operatorEndOffset;
this.throwTranslateError("unknown operator: <" + operator + ">");
break;
}
this.skipSpaces();
Expand Down
4 changes: 4 additions & 0 deletions test/bq-translator.test.js
Expand Up @@ -126,6 +126,10 @@ suite('BoolanQueryTranslator', function() {
"and f1:'k1' f2:'k2')",
"|a|nd f1:'k1' f2:'k2')",
"not started with <(>");
testGroupError("unknown operator",
"(nonexistent f1:'k1' f2:'k2')",
"(nonexistent| |f1:'k1' f2:'k2')",
"unknown operator: <nonexistent>");

testExpression("value only: stirng: and: space",
"'keyword1 keyword2' 'other keyword'",
Expand Down

0 comments on commit d688218

Please sign in to comment.