[Groonga-commit] groonga/gcs [master] bq: throw exception for missing close parenthesis for and/or

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 6日 (月) 14:02:18 JST


Kouhei Sutou	2012-08-06 14:02:18 +0900 (Mon, 06 Aug 2012)

  New Revision: d596d3741674ffce4b97c95598286d906c121f81
  https://github.com/groonga/gcs/commit/d596d3741674ffce4b97c95598286d906c121f81

  Log:
    bq: throw exception for missing close parenthesis for and/or

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

  Modified: lib/bq-translator.js (+5 -5)
===================================================================
--- lib/bq-translator.js    2012-08-06 13:59:36 +0900 (3e6cf51)
+++ lib/bq-translator.js    2012-08-06 14:02:18 +0900 (3a82c12)
@@ -81,10 +81,10 @@ BooleanQueryTranslator.prototype = {
           expression = this.translateGroupFilter();
           break;
         case "and":
-          expression = this.translateGroupSetOperation("&&");
+          expression = this.translateGroupSetOperation(operator, "&&");
           break;
         case "or":
-          expression = this.translateGroupSetOperation("||");
+          expression = this.translateGroupSetOperation(operator, "||");
           break;
         default:
           this.offset = operatorEndOffset;
@@ -166,7 +166,7 @@ BooleanQueryTranslator.prototype = {
 
     this.throwTranslateError("close parenthesis is missing: operator:<filter>");
   },
-  translateGroupSetOperation: function(setOperator) {
+  translateGroupSetOperation: function(label, setOperator) {
     var expressions = [];
     while (this.offset < this.query.length) {
       this.skipSpaces();
@@ -178,8 +178,8 @@ BooleanQueryTranslator.prototype = {
       }
     }
 
-    // TODO: report error: missing close paren <)>
-    return "";
+    this.throwTranslateError("close parenthesis is missing: " +
+                             "operator:<" + label + ">");
   },
   translateExpression: function() {
     if (this.query[this.offset] == "(") {

  Modified: test/bq-translator.test.js (+4 -4)
===================================================================
--- test/bq-translator.test.js    2012-08-06 13:59:36 +0900 (fbe48d3)
+++ test/bq-translator.test.js    2012-08-06 14:02:18 +0900 (e5335ef)
@@ -185,10 +185,10 @@ suite('BoolanQueryTranslator', function() {
                  "(filter ||",
                  "close parenthesis is missing: operator:<filter>");
 
-  // testGroupError("and: missing close parentheis",
-  //                "(and f1:'k1' f2:'k2'",
-  //                "(and f1:'k1' f2:'k2'||",
-  //                "close parenthesis is missing: operator:<and>");
+  testGroupError("and: missing close parentheis",
+                 "(and f1:'k1' f2:'k2'",
+                 "(and f1:'k1' f2:'k2'||",
+                 "close parenthesis is missing: operator:<and>");
 
   testExpression("value only: stirng: and: space",
                  "'keyword1 keyword2' 'other keyword'",
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



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