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

Back to archive index

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


Kouhei Sutou	2012-08-06 14:07:20 +0900 (Mon, 06 Aug 2012)

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

  Log:
    bq: throw exception for missing field value separator

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

  Modified: lib/bq-translator.js (+1 -2)
===================================================================
--- lib/bq-translator.js    2012-08-06 14:02:18 +0900 (3a82c12)
+++ lib/bq-translator.js    2012-08-06 14:07:20 +0900 (785b932)
@@ -205,8 +205,7 @@ BooleanQueryTranslator.prototype = {
           field = this.defaultField;
           this.offset = startOffset;
         } else {
-          // TODO: report error: field and value separator ":" is missing
-          return "";
+          this.throwTranslateError("field value separator is missing");
         }
       }
     } else {

  Modified: test/bq-translator.test.js (+23 -0)
===================================================================
--- test/bq-translator.test.js    2012-08-06 14:02:18 +0900 (e5335ef)
+++ test/bq-translator.test.js    2012-08-06 14:07:20 +0900 (4deb948)
@@ -85,6 +85,24 @@ function testExpression(label, expression,
   });
 }
 
+function testExpressionError(label, expression, context, detail) {
+  test('error: expression: ' + label + ': ' + '<' + expression + '>',
+       function() {
+    var translator = new BooleanQueryTranslator(expression);
+    translator.defaultField = "field";
+    var actualError;
+    assert.throw(function() {
+      try {
+        translator.translateExpression();
+      } catch (error) {
+        actualError = error;
+        throw error;
+      }
+    });
+    assert.equal(actualError.message, "<" + context + ">" + ": " + detail);
+  });
+}
+
 suite('BoolanQueryTranslator', function() {
   testQuery("expression",
             "type:'ModelName'",
@@ -235,4 +253,9 @@ suite('BoolanQueryTranslator', function() {
                  "field1:29 field2:75",
                  "field1:29".length,
                  "field1 == 29");
+
+  testExpressionError("missing field value separator",
+                      "f1 'k1'",
+                      "f1| |'k1'",
+                      "field value separator is missing");
 });
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



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