null+****@clear*****
null+****@clear*****
2012年 8月 6日 (月) 13:37:15 JST
Kouhei Sutou 2012-08-06 13:37:15 +0900 (Mon, 06 Aug 2012) New Revision: 6f0047f0a7ff48e8fc175fecb53cbfcd6ad17f3d https://github.com/groonga/gcs/commit/6f0047f0a7ff48e8fc175fecb53cbfcd6ad17f3d Log: bq: throw exception for no field and value 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:29:26 +0900 (3f82590) +++ lib/bq-translator.js 2012-08-06 13:37:15 +0900 (82109ac) @@ -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 ""; Modified: test/bq-translator.test.js (+8 -0) =================================================================== --- test/bq-translator.test.js 2012-08-06 13:29:26 +0900 (7419b06) +++ test/bq-translator.test.js 2012-08-06 13:37:15 +0900 (1aa3396) @@ -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'", -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...Descargar