YUKI Hiroshi
null+****@clear*****
Thu Nov 28 15:42:19 JST 2013
YUKI Hiroshi 2013-11-28 15:42:19 +0900 (Thu, 28 Nov 2013) New Revision: 6ad88ea3964fc751b48b5a9ebde322a5f4d93798 https://github.com/droonga/fluent-plugin-droonga/commit/6ad88ea3964fc751b48b5a9ebde322a5f4d93798 Message: Handle nil attributes and sortKeys correctly Modified files: lib/droonga/plugin/distributor/search.rb test/unit/plugin/distributor/test_search.rb Modified: lib/droonga/plugin/distributor/search.rb (+6 -3) =================================================================== --- lib/droonga/plugin/distributor/search.rb 2013-11-28 15:33:39 +0900 (abfc5ac) +++ lib/droonga/plugin/distributor/search.rb 2013-11-28 15:42:19 +0900 (0b1c2eb) @@ -157,7 +157,8 @@ module Droonga [final_offset, final_limit] end - def collect_output_attributes(attributes=[]) + def collect_output_attributes(attributes) + attributes ||= [] if attributes.is_a?(Hash) attributes.keys else @@ -172,7 +173,8 @@ module Droonga end def collect_sort_attributes(attributes, sort_keys) - sort_keys = sort_keys["keys"] if sort_keys.is_a?(Hash) + sort_keys ||= [] + sort_keys = sort_keys["keys"] || [] if sort_keys.is_a?(Hash) if attributes.is_a?(Hash) attributes_hash = attributes @@ -201,7 +203,8 @@ module Droonga end def sort_reducer(attributes, sort_keys) - sort_keys = sort_keys["keys"] if sort_keys.is_a?(Hash) + sort_keys ||= [] + sort_keys = sort_keys["keys"] || [] if sort_keys.is_a?(Hash) order = [] # unless sort_keys Modified: test/unit/plugin/distributor/test_search.rb (+6 -0) =================================================================== --- test/unit/plugin/distributor/test_search.rb 2013-11-28 15:33:39 +0900 (c936479) +++ test/unit/plugin/distributor/test_search.rb 2013-11-28 15:42:19 +0900 (f186ce7) @@ -40,6 +40,7 @@ class SearchDistributorTest < Test::Unit::TestCase "output" => { "format" => "complex", "elements" => ["count", "records"], + "attributes" => [], "offset" => 0, "limit" => 10, }, @@ -49,6 +50,7 @@ class SearchDistributorTest < Test::Unit::TestCase "output" => { "format" => "complex", "elements" => ["count", "records"], + "attributes" => [], "offset" => 0, "limit" => 20, }, @@ -58,6 +60,7 @@ class SearchDistributorTest < Test::Unit::TestCase "output" => { "format" => "complex", "elements" => ["count", "records"], + "attributes" => [], "offset" => 0, "limit" => 30, }, @@ -176,6 +179,7 @@ class SearchDistributorTest < Test::Unit::TestCase "output" => { "format" => "simple", "elements" => ["count", "records"], + "attributes" => [], "offset" => 0, "limit" => 10, }, @@ -185,6 +189,7 @@ class SearchDistributorTest < Test::Unit::TestCase "output" => { "format" => "simple", "elements" => ["count", "records"], + "attributes" => [], "offset" => 0, "limit" => 20, }, @@ -194,6 +199,7 @@ class SearchDistributorTest < Test::Unit::TestCase "output" => { "format" => "simple", "elements" => ["count", "records"], + "attributes" => [], "offset" => 0, "limit" => 30, }, -------------- next part -------------- HTML����������������������������...Download