Navigation Menu

Skip to content

Commit

Permalink
bq: throw exception for no field and value
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 6, 2012
1 parent 8b79209 commit 6f0047f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/bq-translator.js
Expand Up @@ -125,8 +125,12 @@ BooleanQueryTranslator.prototype = {
}
return expression;
} else if (character == ")") {
// TODO: report error: field and value is missing
return "";
if (field.length == 0) {
this.throwTranslateError("field is missing");
} else {
this.throwTranslateError("field value is missing: " +
"field:<" + field + ">");
}
} else {
// TODO: report error: invalid field character
return "";
Expand Down
8 changes: 8 additions & 0 deletions test/bq-translator.test.js
Expand Up @@ -151,6 +151,14 @@ suite('BoolanQueryTranslator', function() {
"(field f1 'k1' 'garbage')",
"(field f1 'k1' |'|garbage')",
"a garbage character after value: <'>");
testGroupError("field: no field",
"(field )",
"(field |)|",
"field is missing");
testGroupError("field: no value",
"(field f1)",
"(field f1|)|",
"field value is missing: field:<f1>");

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

0 comments on commit 6f0047f

Please sign in to comment.