[Groonga-commit] groonga/groonga at 4c1520e [master] string_substring: use grn_type_id_is_text_family()

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jul 5 19:28:19 JST 2016


Kouhei Sutou	2016-07-05 19:28:19 +0900 (Tue, 05 Jul 2016)

  New Revision: 4c1520ec898d465da4a4160daabfd096fd6e8eb2
  https://github.com/groonga/groonga/commit/4c1520ec898d465da4a4160daabfd096fd6e8eb2

  Message:
    string_substring: use grn_type_id_is_text_family()

  Added files:
    test/command/suite/select/function/string/string_substring/wrong_target_type.expected
    test/command/suite/select/function/string/string_substring/wrong_target_type.test
  Modified files:
    plugins/functions/string.c

  Modified: plugins/functions/string.c (+1 -3)
===================================================================
--- plugins/functions/string.c    2016-07-05 19:24:35 +0900 (8b50d0a)
+++ plugins/functions/string.c    2016-07-05 19:28:19 +0900 (2a17680)
@@ -107,9 +107,7 @@ func_string_substring(grn_ctx *ctx, int n_args, grn_obj **args,
   }
 
   if (!(target->header.type == GRN_BULK &&
-        ((target->header.domain == GRN_DB_SHORT_TEXT) ||
-         (target->header.domain == GRN_DB_TEXT) ||
-         (target->header.domain == GRN_DB_LONG_TEXT)))) {
+        grn_type_id_is_text_family(ctx, target->header.domain))) {
     grn_obj inspected;
 
     GRN_TEXT_INIT(&inspected, 0);

  Added: test/command/suite/select/function/string/string_substring/wrong_target_type.expected (+42 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/string/string_substring/wrong_target_type.expected    2016-07-05 19:28:19 +0900 (ac4b223)
@@ -0,0 +1,42 @@
+plugin_register functions/string
+[[0,0.0,0.0],true]
+table_create Memos TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"_key": "Groonga"}
+]
+[[0,0.0,0.0],1]
+select Memos   --output_columns '_key, string_substring(_id, 5)'
+[
+  [
+    [
+      -22,
+      0.0,
+      0.0
+    ],
+    "string_substring(): target object must be a text bulk: <1>"
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "string_substring",
+          null
+        ]
+      ],
+      [
+        "Groonga",
+        "string_substring(): target object must be a text bulk: <1>"
+      ]
+    ]
+  ]
+]
+#|e| string_substring(): target object must be a text bulk: <1>

  Added: test/command/suite/select/function/string/string_substring/wrong_target_type.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/function/string/string_substring/wrong_target_type.test    2016-07-05 19:28:19 +0900 (4d01f2d)
@@ -0,0 +1,11 @@
+plugin_register functions/string
+
+table_create Memos TABLE_HASH_KEY ShortText
+
+load --table Memos
+[
+{"_key": "Groonga"}
+]
+
+select Memos \
+  --output_columns '_key, string_substring(_id, 5)'
-------------- next part --------------
HTML����������������������������...
下載 



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