[Groonga-commit] ranguba/rroonga at a1300c2 [master] dump: fix a bug that most index options are missed in Ruby syntax dump

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Fri Feb 21 16:40:46 JST 2014


Kouhei Sutou	2014-02-21 16:40:46 +0900 (Fri, 21 Feb 2014)

  New Revision: a1300c2af16cf4465def477dd3f6cbfc6259fcdc
  https://github.com/ranguba/rroonga/commit/a1300c2af16cf4465def477dd3f6cbfc6259fcdc

  Message:
    dump: fix a bug that most index options are missed in Ruby syntax dump
    
    Here are missed index options:
    
      * :with_section
      * :with_weight
      * :with_position

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

  Modified: lib/groonga/dumper.rb (+14 -5)
===================================================================
--- lib/groonga/dumper.rb    2014-02-09 14:09:23 +0900 (4854eba)
+++ lib/groonga/dumper.rb    2014-02-21 16:40:46 +0900 (c1dc5f1)
@@ -477,9 +477,15 @@ module Groonga
           end
           dump_object(name)
         end.join(", ")
+        options = {
+          :name => column.local_name,
+        }
+        options[:with_section]  = true if column.with_section?
+        options[:with_weight]   = true if column.with_weight?
+        options[:with_position] = true if column.with_position?
         arguments = [dump_object(target_table_name),
                      sources.size == 1 ? source_names : "[#{source_names}]",
-                     ":name => #{dump_object(column.local_name)}"]
+                     dump_options(options)]
         write("  table.index(#{arguments.join(', ')})\n")
       end
 
@@ -516,13 +522,16 @@ module Groonga
         options[:type] = :vector if column.vector?
         return nil if options.empty?
 
-        dumped_options = ""
-        options.each do |key, value|
+        dump_options(options)
+      end
+
+      def dump_options(options)
+        dumped_options = options.collect do |key, value|
           dumped_key = dump_object(key)
           dumped_value = dump_object(value)
-          dumped_options << "#{dumped_key} => #{dumped_value}"
+          "#{dumped_key} => #{dumped_value}"
         end
-        dumped_options
+        dumped_options.join(", ")
       end
 
       def dump_object(object)

  Modified: test/test-schema-dumper.rb (+2 -2)
===================================================================
--- test/test-schema-dumper.rb    2014-02-09 14:09:23 +0900 (b779be8)
+++ test/test-schema-dumper.rb    2014-02-21 16:40:46 +0900 (38e9d04)
@@ -214,8 +214,8 @@ create_table("Terms",
 end
 
 change_table("Terms") do |table|
-  table.index("Items", "_key", :name => "Items__key")
-  table.index("Items", "title", :name => "Items_title")
+  table.index("Items", "_key", :name => "Items__key", :with_position => true)
+  table.index("Items", "title", :name => "Items_title", :with_position => true)
 end
       SCHEMA
     end
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る