[Groonga-commit] groonga/groonga [master] Fix a bug that _score after "*" is ignored in --output_columns

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Tue Dec 25 16:42:13 JST 2012


Kouhei Sutou	2012-12-25 16:42:13 +0900 (Tue, 25 Dec 2012)

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

  Log:
    Fix a bug that _score after "*" is ignored in --output_columns

  Added files:
    test/command/suite/select/output_columns/score/first.expected
    test/command/suite/select/output_columns/score/first.test
    test/command/suite/select/output_columns/score/last.expected
    test/command/suite/select/output_columns/score/last.test
    test/command/suite/select/output_columns/score/middle.expected
    test/command/suite/select/output_columns/score/middle.test
    test/command/suite/select/output_columns/score/only.expected
    test/command/suite/select/output_columns/score/only.test
  Modified files:
    lib/db.c

  Modified: lib/db.c (+6 -2)
===================================================================
--- lib/db.c    2012-12-25 16:25:45 +0900 (6b38da9)
+++ lib/db.c    2012-12-25 16:42:13 +0900 (6c385de)
@@ -8754,8 +8754,12 @@ grn_obj_columns(grn_ctx *ctx, grn_obj *table,
                   if (cols) {
                     grn_id *key;
                     grn_accessor *a, *ac;
-                    for (a = (grn_accessor *)ai; a; a = a->next) { table = a->obj; }
-                    grn_table_columns(ctx, table, p, r - p - 1, (grn_obj *)cols);
+                    grn_obj *target_table = table;
+                    for (a = (grn_accessor *)ai; a; a = a->next) {
+                      target_table = a->obj;
+                    }
+                    grn_table_columns(ctx, target_table,
+                                      p, r - p - 1, (grn_obj *)cols);
                     GRN_HASH_EACH(ctx, cols, id, &key, NULL, NULL, {
                       if ((col = grn_ctx_at(ctx, *key))) {
                         ac = accessor_new(ctx);

  Added: test/command/suite/select/output_columns/score/first.expected (+44 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/score/first.expected    2012-12-25 16:42:13 +0900 (1440ca0)
@@ -0,0 +1,44 @@
+table_create Sites TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Sites uri COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Sites
+[
+["_key","uri"],
+["groonga","http://groonga.org/"],
+["razil","http://razil.jp/"]
+]
+[[0,0.0,0.0],2]
+select Sites --filter true --output_columns '_score, *'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_score",
+          "Int32"
+        ],
+        [
+          "uri",
+          "ShortText"
+        ]
+      ],
+      [
+        1,
+        "http://groonga.org/"
+      ],
+      [
+        1,
+        "http://razil.jp/"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/output_columns/score/first.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/score/first.test    2012-12-25 16:42:13 +0900 (e62584b)
@@ -0,0 +1,11 @@
+table_create Sites TABLE_HASH_KEY ShortText
+column_create Sites uri COLUMN_SCALAR ShortText
+
+load --table Sites
+[
+["_key","uri"],
+["groonga","http://groonga.org/"],
+["razil","http://razil.jp/"]
+]
+
+select Sites --filter true --output_columns '_score, *'

  Added: test/command/suite/select/output_columns/score/last.expected (+44 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/score/last.expected    2012-12-25 16:42:13 +0900 (6633d5e)
@@ -0,0 +1,44 @@
+table_create Sites TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Sites uri COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Sites
+[
+["_key","uri"],
+["groonga","http://groonga.org/"],
+["razil","http://razil.jp/"]
+]
+[[0,0.0,0.0],2]
+select Sites --filter true --output_columns '*, _score'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "uri",
+          "ShortText"
+        ],
+        [
+          "_score",
+          "Int32"
+        ]
+      ],
+      [
+        "http://groonga.org/",
+        1
+      ],
+      [
+        "http://razil.jp/",
+        1
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/output_columns/score/last.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/score/last.test    2012-12-25 16:42:13 +0900 (351db23)
@@ -0,0 +1,11 @@
+table_create Sites TABLE_HASH_KEY ShortText
+column_create Sites uri COLUMN_SCALAR ShortText
+
+load --table Sites
+[
+["_key","uri"],
+["groonga","http://groonga.org/"],
+["razil","http://razil.jp/"]
+]
+
+select Sites --filter true --output_columns '*, _score'

  Added: test/command/suite/select/output_columns/score/middle.expected (+50 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/score/middle.expected    2012-12-25 16:42:13 +0900 (e0af30b)
@@ -0,0 +1,50 @@
+table_create Sites TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Sites uri COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Sites
+[
+["_key","uri"],
+["groonga","http://groonga.org/"],
+["razil","http://razil.jp/"]
+]
+[[0,0.0,0.0],2]
+select Sites --filter true --output_columns '_id, _score, *'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_score",
+          "Int32"
+        ],
+        [
+          "uri",
+          "ShortText"
+        ]
+      ],
+      [
+        1,
+        1,
+        "http://groonga.org/"
+      ],
+      [
+        2,
+        1,
+        "http://razil.jp/"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/output_columns/score/middle.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/score/middle.test    2012-12-25 16:42:13 +0900 (75b11e1)
@@ -0,0 +1,11 @@
+table_create Sites TABLE_HASH_KEY ShortText
+column_create Sites uri COLUMN_SCALAR ShortText
+
+load --table Sites
+[
+["_key","uri"],
+["groonga","http://groonga.org/"],
+["razil","http://razil.jp/"]
+]
+
+select Sites --filter true --output_columns '_id, _score, *'

  Added: test/command/suite/select/output_columns/score/only.expected (+13 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/score/only.expected    2012-12-25 16:42:13 +0900 (87f3769)
@@ -0,0 +1,13 @@
+table_create Sites TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Sites uri COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Sites
+[
+["_key","uri"],
+["groonga","http://groonga.org/"],
+["razil","http://razil.jp/"]
+]
+[[0,0.0,0.0],2]
+select Sites --filter true --output_columns _score
+[[0,0.0,0.0],[[[2],[["_score","Int32"]],[1],[1]]]]

  Added: test/command/suite/select/output_columns/score/only.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/output_columns/score/only.test    2012-12-25 16:42:13 +0900 (0bd6f3a)
@@ -0,0 +1,11 @@
+table_create Sites TABLE_HASH_KEY ShortText
+column_create Sites uri COLUMN_SCALAR ShortText
+
+load --table Sites
+[
+["_key","uri"],
+["groonga","http://groonga.org/"],
+["razil","http://razil.jp/"]
+]
+
+select Sites --filter true --output_columns _score
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index