Kouhei Sutou
null+****@clear*****
Wed Jul 8 21:16:06 JST 2015
Kouhei Sutou 2015-07-08 21:16:06 +0900 (Wed, 08 Jul 2015) New Revision: d69065c90f2de7ce93c0277b5d4224ae31f3a61f https://github.com/ranguba/groonga-client/commit/d69065c90f2de7ce93c0277b5d4224ae31f3a61f Message: select: avoid response key duplication [groonga-dev,03348] Reported by Hiroyuki Sato. Thanks!!! Modified files: lib/groonga/client/response/select.rb test/response/test-select.rb Modified: lib/groonga/client/response/select.rb (+12 -2) =================================================================== --- lib/groonga/client/response/select.rb 2015-06-10 16:40:03 +0900 (eedb3e0) +++ lib/groonga/client/response/select.rb 2015-07-08 21:16:06 +0900 (61ae899) @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2015 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2013 Kosuke Asami # # This library is free software; you can redistribute it and/or @@ -43,7 +43,17 @@ module Groonga def parse_result(raw_result) n_hits = raw_result.first.first - properties = raw_result[1] + column_names = {} + properties = raw_result[1].collect do |column_name, column_type| + base_column_name = column_name + suffix = 2 + while column_names.key?(column_name) + column_name = "#{base_column_name}#{suffix}" + suffix += 1 + end + column_names[column_name] = true + [column_name, column_type] + end infos = raw_result[2..-1] || [] items = infos.collect do |info| item = {} Modified: test/response/test-select.rb (+20 -1) =================================================================== --- test/response/test-select.rb 2015-06-10 16:40:03 +0900 (3b82b88) +++ test/response/test-select.rb 2015-07-08 21:16:06 +0900 (8eb7f70) @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2013-2015 Kouhei Sutou <kou �� clear-code.com> # Copyright (C) 2013 Kosuke Asami # # This library is free software; you can redistribute it and/or @@ -54,6 +54,25 @@ class TestResponseSelect < Test::Unit::TestCase records([[[1], [["updated_at", "Time"]], [updated_at]]])) end + def test_duplicated_column_name + assert_equal([ + { + "html_escape" => "content1", + "html_escape2" => "content2", + } + ], + records([ + [ + [1], + [ + ["html_escape", nil], + ["html_escape", nil], + ], + ["content1", "content2"], + ] + ])) + end + private def records(body) create_response(body).records -------------- next part -------------- HTML����������������������������...Download