[Groonga-commit] ranguba/groonga-client-model at 6b523fc [master] Support preset create_table

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Mar 3 10:39:54 JST 2017


Kouhei Sutou	2017-03-03 10:39:54 +0900 (Fri, 03 Mar 2017)

  New Revision: 6b523fc4108689bded3e6a846a9c79687861093a
  https://github.com/ranguba/groonga-client-model/commit/6b523fc4108689bded3e6a846a9c79687861093a

  Message:
    Support preset create_table

  Modified files:
    lib/groonga_client_model/migration.rb
    test/unit/test_migration.rb

  Modified: lib/groonga_client_model/migration.rb (+9 -1)
===================================================================
--- lib/groonga_client_model/migration.rb    2017-03-03 10:28:30 +0900 (be762da)
+++ lib/groonga_client_model/migration.rb    2017-03-03 10:39:54 +0900 (3b5aa4c)
@@ -62,12 +62,20 @@ module GroongaClientModel
                      key_type: nil,
                      tokenizer: nil,
                      default_tokenizer: nil,
-                     normalizer: nil)
+                     normalizer: nil,
+                     propose: nil)
       if @reverting
         @pending_actions << [:remove_table, name]
         return
       end
 
+      case propose
+      when :full_text_search
+        type ||= :patricia_trie
+        tokenizer ||= :bigram
+        normalizer ||= :auto
+      end
+
       type = normalize_table_type(type || :array)
       if type != "TABLE_NO_KEY" and key_type.nil?
         key_type ||= "ShortText"

  Modified: test/unit/test_migration.rb (+23 -0)
===================================================================
--- test/unit/test_migration.rb    2017-03-03 10:28:30 +0900 (0ca6003)
+++ test/unit/test_migration.rb    2017-03-03 10:39:54 +0900 (2e512f6)
@@ -156,6 +156,29 @@ table_create terms TABLE_PAT_KEY ShortText --normalizer NormalizerAuto
       end
     end
 
+    sub_test_case("propose") do
+      test("full_text_search") do
+        expected_up_report = <<-REPORT
+-- create_table(:terms, {:type=>"TABLE_PAT_KEY", :key_type=>"ShortText", :tokenizer=>"TokenBigram", :normalizer=>"NormalizerAuto"})
+   -> 0.0s
+        REPORT
+        expected_down_report = <<-REPORT
+-- remove_table(:terms)
+   -> 0.0s
+        REPORT
+        expected_dump = <<-DUMP.chomp
+table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
+      DUMP
+        assert_migrate(expected_up_report,
+                       expected_down_report,
+                       expected_dump) do |migration|
+          migration.instance_eval do
+            create_table(:terms, :propose => :full_text_search)
+          end
+        end
+      end
+    end
+
     sub_test_case("columns") do
       sub_test_case("#short_text") do
         test("default") do
-------------- next part --------------
HTML����������������������������...
다운로드 



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