Navigation Menu

Skip to content

Commit

Permalink
bq: throw exception for no operator
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 6, 2012
1 parent 4dbf9e5 commit 192b430
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/bq-translator.js
Expand Up @@ -258,7 +258,8 @@ BooleanQueryTranslator.prototype = {
value += character;
} else if (character == "\"") {
if (value.length > 0) {
this.throwTranslateError("TODO");
this.throwTranslateError("operator is missing: " +
"keyword:<" + value + ">");
}
tokens.push(this.translateExpressionValuePhrase(field));
this.offset--;
Expand Down
11 changes: 8 additions & 3 deletions test/bq-translator.test.js
Expand Up @@ -271,8 +271,13 @@ suite('BoolanQueryTranslator', function() {
"f1:|v|alue",
"invalid value: field:<f1>");

testExpressionError("field value: string: missing close quote",
"f1:'k1",
"f1:'k1||",
testExpressionError("value only: string: missing close quote",
"'k1",
"'k1||",
"close single quote for string value is missing");
testExpressionError("value only: stirng: " +
"missing operator between keyword and phrase",
"'keyword1\"keyword2\"' 'other keyword'",
"'keyword1|\"|keyword2\"' 'other keyword'",
"operator is missing: keyword:<keyword1>");
});

0 comments on commit 192b430

Please sign in to comment.