[Groonga-commit] groonga/groonga [master] Support complex string concatenation in --output_columns

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Sun Mar 3 23:56:53 JST 2013


Kouhei Sutou	2013-03-03 23:56:53 +0900 (Sun, 03 Mar 2013)

  New Revision: db4f57566f43ed7015442ed56e985877573baf25
  https://github.com/groonga/groonga/commit/db4f57566f43ed7015442ed56e985877573baf25

  Log:
    Support complex string concatenation in --output_columns
    
    For example:
    
    --output_columns:
    
      '..., "<" + COLUMN + ">"'
    
    Before: "<<>"
    After:  "<#{COLUMN value}>"

  Added files:
    test/command/suite/select/output_columns/expression/string_plus.expected
    test/command/suite/select/output_columns/expression/string_plus.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+8 -0)
===================================================================
--- lib/expr.c    2013-03-03 23:17:04 +0900 (be3c12f)
+++ lib/expr.c    2013-03-03 23:56:53 +0900 (7f39813)
@@ -3326,6 +3326,14 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs)
           {
             if (x == res) {
               grn_obj_cast(ctx, y, res, GRN_FALSE);
+            } else if (y == res) {
+              grn_obj buffer;
+              GRN_TEXT_INIT(&buffer, 0);
+              grn_obj_cast(ctx, x, &buffer, GRN_FALSE);
+              grn_obj_cast(ctx, y, &buffer, GRN_FALSE);
+              GRN_BULK_REWIND(res);
+              grn_obj_cast(ctx, &buffer, res, GRN_FALSE);
+              GRN_OBJ_FIN(ctx, &buffer);
             } else {
               GRN_BULK_REWIND(res);
               grn_obj_cast(ctx, x, res, GRN_FALSE);

  Added: test/command/suite/select/output_columns/expression/string_plus.expected (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/expression/string_plus.expected    2013-03-03 23:56:53 +0900 (0615dc0)
@@ -0,0 +1,11 @@
+table_create Entries TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Entries title COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"title": "groonga and MySQL"}
+]
+[[0,0.0,0.0],1]
+select Entries   --output_columns '_id, "<" + title + ">"'   --command_version 2
+[[0,0.0,0.0],[[[1],[["_id","UInt32"],["","null"]],[1,"<groonga and MySQL>"]]]]

  Added: test/command/suite/select/output_columns/expression/string_plus.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/expression/string_plus.test    2013-03-03 23:56:53 +0900 (a64c714)
@@ -0,0 +1,11 @@
+table_create Entries TABLE_NO_KEY
+column_create Entries title COLUMN_SCALAR ShortText
+
+load --table Entries
+[
+{"title": "groonga and MySQL"}
+]
+
+select Entries \
+  --output_columns '_id, "<" + title + ">"' \
+  --command_version 2
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る