Kouhei Sutou
null+****@clear*****
Wed May 13 18:01:43 JST 2015
Kouhei Sutou 2015-05-13 18:01:43 +0900 (Wed, 13 May 2015) New Revision: f80bc0930796e14fef151bcad701e5140edeee62 https://github.com/ranguba/rroonga/commit/f80bc0930796e14fef151bcad701e5140edeee62 Message: schema: use :hash as the default table type when :key_type is specified :array was the default table type. If :key_type is specified, user must want to define a have key table. So :array wasn't the good default for the case. If user doesn't specify :key_type, :array is the default table type. It's not changed. It's a backward incompatible change. But nobody will not be stumped. Because :key_type is specified but :type isn't specified case is a bug of user's program. Modified files: lib/groonga/schema.rb test/test-schema.rb Modified: lib/groonga/schema.rb (+9 -1) =================================================================== --- lib/groonga/schema.rb 2015-05-13 17:56:38 +0900 (cba7b06) +++ lib/groonga/schema.rb 2015-05-13 18:01:43 +0900 (c77bdfd) @@ -1209,8 +1209,16 @@ module Groonga # @private def table_type type = @options[:type] + if type.nil? + if @options[:key_type] + type = :hash + else + type = :array + end + end + case type - when :array, nil + when :array Groonga::Array when :hash Groonga::Hash Modified: test/test-schema.rb (+19 -0) =================================================================== --- test/test-schema.rb 2015-05-13 17:56:38 +0900 (de9d40c) +++ test/test-schema.rb 2015-05-13 18:01:43 +0900 (294c675) @@ -71,6 +71,25 @@ class SchemaTest < Test::Unit::TestCase end end + sub_test_case "define table" do + sub_test_case ":key_type" do + test "exist" do + Groonga::Schema.create_table("Posts", + :key_type => :short_text) do |table| + end + posts = context["Posts"] + assert_kind_of(Groonga::Hash, posts) + end + + test "not exist" do + Groonga::Schema.create_table("Posts") do |table| + end + posts = context["Posts"] + assert_kind_of(Groonga::Array, posts) + end + end + end + class DefineHashTest < self def test_default Groonga::Schema.create_table("Posts", :type => :hash) do |table| -------------- next part -------------- HTML����������������������������...Download