[Groonga-commit] ranguba/rroonga at 040716a [master] Accept String as option key

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Mar 26 00:01:13 JST 2014


Kouhei Sutou	2014-03-26 00:01:13 +0900 (Wed, 26 Mar 2014)

  New Revision: 040716a18b5639a31e887823a07f22da31bd3d8a
  https://github.com/ranguba/rroonga/commit/040716a18b5639a31e887823a07f22da31bd3d8a

  Message:
    Accept String as option key

  Modified files:
    ext/groonga/rb-grn-utils.c
    test/test-variable-size-column.rb

  Modified: ext/groonga/rb-grn-utils.c (+4 -0)
===================================================================
--- ext/groonga/rb-grn-utils.c    2014-03-25 23:41:12 +0900 (6f05293)
+++ ext/groonga/rb-grn-utils.c    2014-03-26 00:01:13 +0900 (4f8526e)
@@ -123,6 +123,10 @@ rb_grn_scan_options (VALUE options, ...)
         rb_key = RB_GRN_INTERN(key);
         rb_ary_push(available_keys, rb_key);
         *value = rb_funcall(options, rb_intern("delete"), 1, rb_key);
+        if (NIL_P(*value)) {
+            rb_key = rb_str_new_cstr(key);
+            *value = rb_funcall(options, rb_intern("delete"), 1, rb_key);
+        }
 
         key = va_arg(args, const char *);
     }

  Modified: test/test-variable-size-column.rb (+18 -0)
===================================================================
--- test/test-variable-size-column.rb    2014-03-25 23:41:12 +0900 (6e7ee40)
+++ test/test-variable-size-column.rb    2014-03-26 00:01:13 +0900 (3340cca)
@@ -252,6 +252,24 @@ class VariableSizeColumnTest < Test::Unit::TestCase
         @products = Groonga["Products"]
       end
 
+      def test_string_key
+        groonga =****@produ*****("Groonga")
+        groonga.tags = [
+          {
+            "value"  => "groonga",
+            "weight" => 100,
+          },
+        ]
+
+        assert_equal([
+                       {
+                         :value  => "groonga",
+                         :weight => 100,
+                       },
+                     ],
+                     groonga.tags)
+      end
+
       def test_array
         groonga =****@produ*****("Groonga")
         groonga.tags = [
-------------- next part --------------
HTML����������������������������...
Download 



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