[Groonga-commit] ranguba/rroonga at 5dd24a2 [master] Enable with_section flag for multiple column index

Back to archive index

Kouhei Sutou null+****@clear*****
Fri May 30 17:52:09 JST 2014


Kouhei Sutou	2014-05-30 17:52:09 +0900 (Fri, 30 May 2014)

  New Revision: 5dd24a2421b05f2bb6fd92e103e5a1dbd180244e
  https://github.com/ranguba/rroonga/commit/5dd24a2421b05f2bb6fd92e103e5a1dbd180244e

  Message:
    Enable with_section flag for multiple column index

  Modified files:
    lib/groonga/schema.rb
    test/test-schema.rb

  Modified: lib/groonga/schema.rb (+6 -2)
===================================================================
--- lib/groonga/schema.rb    2014-05-30 17:40:56 +0900 (46fe075)
+++ lib/groonga/schema.rb    2014-05-30 17:52:09 +0900 (9397220)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2009-2013  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2009-2014  Kouhei Sutou <kou �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -1305,6 +1305,7 @@ module Groonga
       def parse_index_argument(target_table_or_target_column_full_name, *args)
         options = nil
         options = args.pop if args.last.is_a?(::Hash)
+        options ||= {}
         if args.empty?
           target_column_full_name = target_table_or_target_column_full_name
           if target_column_full_name.is_a?(Groonga::Column)
@@ -1321,7 +1322,10 @@ module Groonga
           target_columns = args
           key = [target_table_name, target_columns]
         end
-        [key, target_table, target_columns, options || {}]
+        if target_columns.size > 1 and options[:with_section].nil?
+          options[:with_section] = true
+        end
+        [key, target_table, target_columns, options]
       end
 
       def same_table?(table, options)

  Modified: test/test-schema.rb (+28 -1)
===================================================================
--- test/test-schema.rb    2014-05-30 17:40:56 +0900 (4940e66)
+++ test/test-schema.rb    2014-05-30 17:52:09 +0900 (da81ec3)
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2011  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2009-2014  Kouhei Sutou <kou �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -714,6 +714,33 @@ class SchemaTest < Test::Unit::TestCase
       assert_equal("Terms.posts_content_index", index.name)
       assert_equal([context["Posts.content"]], renamed_index.sources)
     end
+
+    class MultipleColumnTest < self
+      setup
+      def setup_index
+        Groonga::Schema.create_table("Posts") do |table|
+          table.short_text :title
+          table.long_text :content
+        end
+        Groonga::Schema.create_table("Terms") do |table|
+          table.index "Posts", "title", "content"
+        end
+
+        @index = context["Terms.Posts_title_content"]
+      end
+
+      def test_source
+        assert_equal([
+                       "Posts.title",
+                       "Posts.content",
+                     ],
+                     @index.sources.collect(&:name))
+      end
+
+      def test_with_section
+        assert_true(@index.with_section?)
+      end
+    end
   end
 
   def test_reference_guess
-------------- next part --------------
HTML����������������������������...
Descargar 



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