[Groonga-commit] groonga/gcs [master] bq: throw exception for garbage after field value

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 6日 (月) 13:29:26 JST


Kouhei Sutou	2012-08-06 13:29:26 +0900 (Mon, 06 Aug 2012)

  New Revision: 8b79209d78439dac2a151ffb69d64fea333f2083
  https://github.com/groonga/gcs/commit/8b79209d78439dac2a151ffb69d64fea333f2083

  Log:
    bq: throw exception for garbage after field value

  Modified files:
    lib/bq-translator.js
    test/bq-translator.test.js

  Modified: lib/bq-translator.js (+4 -3)
===================================================================
--- lib/bq-translator.js    2012-08-06 13:22:03 +0900 (6d57652)
+++ lib/bq-translator.js    2012-08-06 13:29:26 +0900 (3f82590)
@@ -118,9 +118,10 @@ BooleanQueryTranslator.prototype = {
         this.skipSpaces();
         var expression = this.translateExpressionValueString(field);
         this.skipSpaces();
-        if (this.query[this.offset] != ")") {
-          // TODO: report error: have garbage
-          return "";
+        var character = this.query[this.offset];
+        if (character != ")") {
+          this.throwTranslateError("a garbage character after value: " +
+                                   "<" + character + ">");
         }
         return expression;
       } else if (character == ")") {

  Modified: test/bq-translator.test.js (+5 -0)
===================================================================
--- test/bq-translator.test.js    2012-08-06 13:22:03 +0900 (2345a44)
+++ test/bq-translator.test.js    2012-08-06 13:29:26 +0900 (7419b06)
@@ -147,6 +147,11 @@ suite('BoolanQueryTranslator', function() {
                  "(operat|0|r f1:'k1' f2:'k2')",
                  "invalid operator character: <0>");
 
+  testGroupError("field: garbage after value",
+                 "(field f1 'k1' 'garbage')",
+                 "(field f1 'k1' |'|garbage')",
+                 "a garbage character after value: <'>");
+
   testExpression("value only: stirng: and: space",
                  "'keyword1 keyword2' 'other keyword'",
                  "'keyword1 keyword2'".length,
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
下載 



Groonga-commit メーリングリストの案内
Back to archive index