[Groonga-commit] groonga/groonga-schema at 64c34ec [master] Remove needless column_copy

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Aug 15 18:28:16 JST 2016


Kouhei Sutou	2016-08-15 18:28:16 +0900 (Mon, 15 Aug 2016)

  New Revision: 64c34ec4b1026ece864aea6d034f282da454e302
  https://github.com/groonga/groonga-schema/commit/64c34ec4b1026ece864aea6d034f282da454e302

  Message:
    Remove needless column_copy

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

  Modified: lib/groonga-schema/table.rb (+3 -2)
===================================================================
--- lib/groonga-schema/table.rb    2016-08-15 18:19:42 +0900 (566a271)
+++ lib/groonga-schema/table.rb    2016-08-15 18:28:16 +0900 (9f76aab)
@@ -84,8 +84,9 @@ module GroongaSchema
           new_column = Column.new(new_name, column.name)
           new_column.apply_column(column)
           commands << new_column.to_create_groonga_command
-          commands << column.to_copy_groonga_command(new_name,
-                                                     column.name)
+          unless column.type == :index
+            commands << column.to_copy_groonga_command(new_name, column.name)
+          end
         end
       end
       commands << table_rename_command(@name, old_name)

  Modified: test/test-diff.rb (+54 -0)
===================================================================
--- test/test-diff.rb    2016-08-15 18:19:42 +0900 (4b15df4)
+++ test/test-diff.rb    2016-08-15 18:28:16 +0900 (d24ffbd)
@@ -311,6 +311,27 @@ table_remove \\
     end
 
     test "changed tables - with columns" do
+      token_filters = [
+        "TokenFilterStopWord",
+        "TokenFilterStem",
+      ]
+      words_columns = [
+        column("Words", "weight",
+               :value_type => "Float"),
+        column("Words", "commands_description",
+               :type => :index,
+               :flags => ["WITH_POSITION"],
+               :value_type => "Commands",
+               :sources => ["description"],
+               :reference_value_type => true),
+      ]
+      @diff.changed_tables["Words"] = table("Words",
+                                            :type => :pat_key,
+                                            :key_type => "ShortText",
+                                            :default_tokenizer => "TokenBigram",
+                                            :normalizer => "NormalizerAuto",
+                                            :token_filters => token_filters,
+                                            :columns => words_columns)
       @diff.changed_tables["Names"] = table("Names",
                                             :type => :hash_key,
                                             :flags => "KEY_LARGE",
@@ -345,6 +366,36 @@ table_rename \\
   --new_name "Names"
 
 table_create \\
+  --default_tokenizer "TokenBigram" \\
+  --flags "TABLE_PAT_KEY" \\
+  --key_type "ShortText" \\
+  --name "Words_new" \\
+  --normalizer "NormalizerAuto" \\
+  --token_filters "TokenFilterStopWord|TokenFilterStem"
+column_create \\
+  --flags "COLUMN_INDEX|WITH_POSITION" \\
+  --name "commands_description" \\
+  --source "description" \\
+  --table "Words_new" \\
+  --type "Commands"
+column_create \\
+  --flags "COLUMN_SCALAR" \\
+  --name "weight" \\
+  --table "Words_new" \\
+  --type "Float"
+column_copy \\
+  --from_name "weight" \\
+  --from_table "Words" \\
+  --to_name "weight" \\
+  --to_table "Words_new"
+table_rename \\
+  --name "Words" \\
+   --new_name "Words_old"
+table_rename \\
+  --name "Words_new" \\
+  --new_name "Words"
+
+table_create \\
   --flags "TABLE_HASH_KEY" \\
   --key_type "Names" \\
   --name "Commands_new"
@@ -379,6 +430,9 @@ table_remove \\
   --name "Names_old"
 
 table_remove \\
+  --name "Words_old"
+
+table_remove \\
   --name "Commands_old"
       LIST
     end
-------------- next part --------------
HTML����������������������������...
Download 



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