[Groonga-commit] groonga/fluent-plugin-droonga at b2e91f5 [master] add: support Groonga::Array (that has no key)

Back to archive index

Kosuke Asami null+****@clear*****
Thu Jul 18 16:34:38 JST 2013


Kosuke Asami	2013-07-18 16:34:38 +0900 (Thu, 18 Jul 2013)

  New Revision: b2e91f5a30c6ee24f843da7bb9c3c20c9d7a4323
  https://github.com/groonga/fluent-plugin-droonga/commit/b2e91f5a30c6ee24f843da7bb9c3c20c9d7a4323

  Message:
    add: support Groonga::Array (that has no key)

  Modified files:
    lib/droonga/plugin/handler_add.rb
    test/plugin/test_handler_add.rb

  Modified: lib/droonga/plugin/handler_add.rb (+5 -1)
===================================================================
--- lib/droonga/plugin/handler_add.rb    2013-07-18 10:15:01 +0900 (83271cf)
+++ lib/droonga/plugin/handler_add.rb    2013-07-18 16:34:38 +0900 (3f07de7)
@@ -31,7 +31,11 @@ module Droonga
 
     def process_add(request)
       table = @context[request["table"]]
-      table.add(request["key"], request["values"])
+      if table.class == Groonga::Array
+        table.add(request["values"])
+      else
+        table.add(request["key"], request["values"])
+      end
       outputs = [true]
     end
   end

  Modified: test/plugin/test_handler_add.rb (+25 -0)
===================================================================
--- test/plugin/test_handler_add.rb    2013-07-18 10:15:01 +0900 (4db4e10)
+++ test/plugin/test_handler_add.rb    2013-07-18 16:34:38 +0900 (636ee26)
@@ -41,6 +41,11 @@ class AddHandlerTest < Test::Unit::TestCase
                           :key_type => :short_text) do |table|
         table.short_text("country")
       end
+
+      schema.create_table("Books",
+                          :type => :array) do |table|
+        table.short_text("title")
+      end
     end
   end
 
@@ -81,4 +86,24 @@ class AddHandlerTest < Test::Unit::TestCase
     table =****@worke*****["Users"]
     assert_equal(["japan"], table.collect(&:country))
   end
+
+  def test_add_no_key_empty_values
+    request = {
+      "table"  => "Books",
+      "values" => {},
+    }
+    @handler.add(request)
+    table =****@worke*****["Books"]
+    assert_equal([nil], table.collect(&:title))
+  end
+
+  def test_add_no_key_with_values
+    request = {
+      "table"  => "Books",
+      "values" => { "title" => "CSS" },
+    }
+    @handler.add(request)
+    table =****@worke*****["Books"]
+    assert_equal(["CSS"], table.collect(&:title))
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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