Kouhei Sutou
null+****@clear*****
Mon May 30 18:02:24 JST 2016
Kouhei Sutou 2016-05-30 18:02:24 +0900 (Mon, 30 May 2016) New Revision: aed35debf3a697257fa42cd7e0522e7f137f4c2c https://github.com/ranguba/groonga-client/commit/aed35debf3a697257fa42cd7e0522e7f137f4c2c Message: select: support vector of Time Modified files: lib/groonga/client/response/select.rb test/response/test-select-command-version1.rb test/response/test-select-command-version3.rb Modified: lib/groonga/client/response/select.rb (+11 -4) =================================================================== --- lib/groonga/client/response/select.rb 2016-05-30 12:13:54 +0900 (27d7a65) +++ lib/groonga/client/response/select.rb 2016-05-30 18:02:24 +0900 (e0c8b80) @@ -75,11 +75,18 @@ module Groonga end def convert_value(value, type) - case type - when "Time" - Time.at(value) + case value + when ::Array + value.collect do |element| + convert_value(element, type) + end else - value + case type + when "Time" + Time.at(value) + else + value + end end end Modified: test/response/test-select-command-version1.rb (+24 -0) =================================================================== --- test/response/test-select-command-version1.rb 2016-05-30 12:13:54 +0900 (b08c66c) +++ test/response/test-select-command-version1.rb 2016-05-30 18:02:24 +0900 (a559223) @@ -54,6 +54,30 @@ class TestResponseSelectCommandVersion1 < Test::Unit::TestCase records([[[1], [["updated_at", "Time"]], [updated_at]]])) end + def test_time_vector + update1 = 1379040474 + update2 = 1464598349 + assert_equal([ + { + "updates" => [ + Time.at(update1), + Time.at(update2), + ], + }, + ], + records([ + [ + [1], + [ + ["updates", "Time"], + ], + [ + [update1, update2], + ], + ] + ])) + end + def test_duplicated_column_name assert_equal([ { Modified: test/response/test-select-command-version3.rb (+27 -0) =================================================================== --- test/response/test-select-command-version3.rb 2016-05-30 12:13:54 +0900 (56ab249) +++ test/response/test-select-command-version3.rb 2016-05-30 18:02:24 +0900 (79bb24a) @@ -97,6 +97,33 @@ class TestResponseSelectCommandVersion3 < Test::Unit::TestCase })) end + def test_time_vector + update1 = 1379040474 + update2 = 1464598349 + assert_equal([ + { + "updates" => [ + Time.at(update1), + Time.at(update2), + ], + }, + ], + records({ + "n_hits" => 1, + "columns" => [ + { + "name" => "updates", + "type" => "Time", + }, + ], + "records" => [ + [ + [update1, update2], + ], + ], + })) + end + def test_duplicated_column_name assert_equal([ { -------------- next part -------------- HTML����������������������������...下载