null+****@clear*****
null+****@clear*****
2012年 8月 6日 (月) 13:57:23 JST
Kouhei Sutou 2012-08-06 13:57:23 +0900 (Mon, 06 Aug 2012) New Revision: ef6a2612914591937e4e0ff9796e3e8e5f805dcf https://github.com/groonga/gcs/commit/ef6a2612914591937e4e0ff9796e3e8e5f805dcf Log: bq: throw exception for missing field and value for filter Modified files: lib/bq-translator.js test/bq-translator.test.js Modified: lib/bq-translator.js (+6 -2) =================================================================== --- lib/bq-translator.js 2012-08-06 13:53:36 +0900 (00eb8f8) +++ lib/bq-translator.js 2012-08-06 13:57:23 +0900 (1987abd) @@ -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 ""; Modified: test/bq-translator.test.js (+8 -0) =================================================================== --- test/bq-translator.test.js 2012-08-06 13:53:36 +0900 (24c9518) +++ test/bq-translator.test.js 2012-08-06 13:57:23 +0900 (428edc5) @@ -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'", -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...ダウンロード