[Groonga-commit] groonga/gcs [master] bq: unsigned integer value only expression is invalid

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Aug 14 16:49:07 JST 2012


Kouhei Sutou	2012-08-14 16:49:07 +0900 (Tue, 14 Aug 2012)

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

  Log:
    bq: unsigned integer value only expression is invalid

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

  Modified: lib/bq-translator.js (+3 -10)
===================================================================
--- lib/bq-translator.js    2012-08-14 16:24:45 +0900 (a2ef02b)
+++ lib/bq-translator.js    2012-08-14 16:49:07 +0900 (8d0b761)
@@ -194,17 +194,10 @@ BooleanQueryTranslator.prototype = {
         }
         field += character;
       }
-      if (this.query[this.offset] == ":") {
-        this.offset++;
-      } else {
-        var is_unsigned_integer_value = /^[0-9]+$/.test(field);
-        if (is_unsigned_integer_value) {
-          field = this.defaultField;
-          this.offset = startOffset;
-        } else {
-          this.throwTranslateError("field value separator is missing");
-        }
+      if (this.query[this.offset] != ":") {
+        this.throwTranslateError("field value separator is missing");
       }
+      this.offset++;
     } else {
       field = this.defaultField;
     }

  Modified: test/bq-translator.test.js (+6 -17)
===================================================================
--- test/bq-translator.test.js    2012-08-14 16:24:45 +0900 (3dc0886)
+++ test/bq-translator.test.js    2012-08-14 16:49:07 +0900 (2391453)
@@ -236,22 +236,6 @@ suite('BoolanQueryTranslator', function() {
                  "'\"keyword1 keyword2\"|\"keyword3\"' 'other keyword'",
                  "'\"keyword1 keyword2\"|\"keyword3\"'".length,
                  "field @ \"keyword1 keyword2\" || field @ \"keyword3\"");
-  testExpression("value only: unsigned integer",
-                 "29 75",
-                 "29".length,
-                 "field == 29");
-  testExpression("value only: unsigned integer range: min only",
-                 "29.. 75",
-                 "29..".length,
-                 "field >= 29");
-  testExpression("value only: unsigned integer range: max only",
-                 "..29 75",
-                 "..29".length,
-                 "field <= 29");
-  testExpression("value only: unsigned integer range: min and max",
-                 "14..29 75",
-                 "14..29".length,
-                 "(field >= 14 && field <= 29)");
 
   testExpression("field value: string",
                  "field1:'keyword1 keyword2' field2:'other keyword'",
@@ -262,10 +246,15 @@ suite('BoolanQueryTranslator', function() {
                  "field1:29".length,
                  "field1 == 29");
 
-  testExpressionError("missing field value separator",
+  testExpressionError("missing field value separator: normal field name",
                       "f1 'k1'",
                       "f1| |'k1'",
                       "field value separator is missing");
+  testExpressionError("missing field value separator: " +
+                        "unsigned integer like field name",
+                      "29 75",
+                      "29| |75",
+                      "field value separator is missing");
   testExpressionError("invalid value",
                       "f1:value",
                       "f1:|v|alue",
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index