[Groonga-commit] groonga/groonga [master] Support correct type output for nonexistent reference

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Nov 10 00:13:52 JST 2012


Kouhei Sutou	2012-11-10 00:13:52 +0900 (Sat, 10 Nov 2012)

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

  Log:
    Support correct type output for nonexistent reference

  Added files:
    test/command/suite/select/output/reference/uint32/scalar/default.actual
    test/command/suite/select/output/reference/uint32/scalar/default.test
  Modified files:
    lib/output.c

  Modified: lib/output.c (+5 -1)
===================================================================
--- lib/output.c    2012-11-10 00:10:45 +0900 (35212cf)
+++ lib/output.c    2012-11-10 00:13:52 +0900 (04ac474)
@@ -765,7 +765,11 @@ grn_output_bulk(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type,
       if (table && table->header.type != GRN_TABLE_NO_KEY) {
         grn_obj *accessor = grn_obj_column(ctx, table, "_key", 4);
         if (accessor) {
-          grn_obj_get_value(ctx, accessor, id, &buf);
+          if (id == GRN_ID_NIL) {
+            grn_obj_reinit_for(ctx, &buf, accessor);
+          } else {
+            grn_obj_get_value(ctx, accessor, id, &buf);
+          }
           grn_obj_unlink(ctx, accessor);
         }
         grn_output_obj(ctx, outbuf, output_type, &buf, format);

  Added: test/command/suite/select/output/reference/uint32/scalar/default.actual (+52 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output/reference/uint32/scalar/default.actual    2012-11-10 00:13:52 +0900 (6c0209f)
@@ -0,0 +1,52 @@
+table_create Ages TABLE_PAT_KEY UInt32
+[[0,0.0,0.0],true]
+table_create Users TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users age COLUMN_SCALAR Ages
+[[0,0.0,0.0],true]
+load --table Users
+[
+["_key"],
+["alice"],
+["bob"]
+]
+[[0,0.0,0.0],2]
+select Users
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "age",
+          "Ages"
+        ]
+      ],
+      [
+        1,
+        "alice",
+        ""
+      ],
+      [
+        2,
+        "bob",
+        ""
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/output/reference/uint32/scalar/default.test (+13 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output/reference/uint32/scalar/default.test    2012-11-10 00:13:52 +0900 (0cf362f)
@@ -0,0 +1,13 @@
+table_create Ages TABLE_PAT_KEY UInt32
+
+table_create Users TABLE_PAT_KEY ShortText
+column_create Users age COLUMN_SCALAR Ages
+
+load --table Users
+[
+["_key"],
+["alice"],
+["bob"]
+]
+
+select Users
-------------- next part --------------
HTML����������������������������...
Download 



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