Navigation Menu

Skip to content

Commit

Permalink
bq: throw exception for missing field and value for filter
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 6, 2012
1 parent 7407fc1 commit ef6a261
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 @@ -152,8 +152,12 @@ BooleanQueryTranslator.prototype = {
this.offset++;
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 @@ -168,6 +168,14 @@ suite('BoolanQueryTranslator', function() {
"(filter field1 29 'garbage')",
"(filter field1 29 |'|garbage')",
"a garbage character after value: <'>");
testGroupError("filter: no field",
"(filter )",
"(filter |)|",
"field is missing");
testGroupError("filter: no value",
"(filter f1)",
"(filter f1|)|",
"field value is missing: field:<f1>");

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

0 comments on commit ef6a261

Please sign in to comment.