Kouhei Sutou
null+****@clear*****
Tue Aug 9 11:57:33 JST 2016
Kouhei Sutou 2016-08-09 11:57:33 +0900 (Tue, 09 Aug 2016) New Revision: 1a658b77c9cdda82b871374ffba3cb6d4fa694aa https://github.com/groonga/groonga-schema/commit/1a658b77c9cdda82b871374ffba3cb6d4fa694aa Message: Set reference type information Modified files: lib/groonga-schema/column.rb lib/groonga-schema/schema.rb lib/groonga-schema/table.rb test/test-schema.rb Modified: lib/groonga-schema/column.rb (+6 -0) =================================================================== --- lib/groonga-schema/column.rb 2016-08-09 11:50:54 +0900 (d20566f) +++ lib/groonga-schema/column.rb 2016-08-09 11:57:33 +0900 (8ccff13) @@ -22,6 +22,7 @@ module GroongaSchema attr_accessor :flags attr_accessor :value_type attr_accessor :sources + attr_writer :reference_value_type def initialize(table_name, name) @table_name = table_name @name = name @@ -29,6 +30,11 @@ module GroongaSchema @flags = [] @value_type = "ShortText" @sources = [] + @reference_value_type = false + end + + def reference_value_type? + @reference_value_type end def apply_command(command) Modified: lib/groonga-schema/schema.rb (+6 -0) =================================================================== --- lib/groonga-schema/schema.rb 2016-08-09 11:50:54 +0900 (a3e31b4) +++ lib/groonga-schema/schema.rb 2016-08-09 11:57:33 +0900 (32364c1) @@ -40,11 +40,17 @@ module GroongaSchema when "table_create" table = Table.new(command.name) table.apply_command(command) + if****@table*****?(table.key_type) + table.reference_key_type = true + end @tables[table.name] = table @columns[table.name] ||= {} when "column_create" column = Column.new(command.table, command.name) column.apply_command(command) + if****@table*****?(column.value_type) + column.reference_value_type = true + end @columns[column.table_name] ||= {} @columns[column.table_name][column.name] = column end Modified: lib/groonga-schema/table.rb (+6 -0) =================================================================== --- lib/groonga-schema/table.rb 2016-08-09 11:50:54 +0900 (0a8fa98) +++ lib/groonga-schema/table.rb 2016-08-09 11:57:33 +0900 (f6fe2ab) @@ -24,6 +24,7 @@ module GroongaSchema attr_accessor :default_tokenizer attr_accessor :normalizer attr_accessor :token_filters + attr_writer :reference_key_type def initialize(name) @name = name @type = :no_key @@ -33,6 +34,11 @@ module GroongaSchema @default_tokenizer = nil @normalizer = nil @token_filters = [] + @reference_key_type = false + end + + def reference_key_type? + @reference_key_type end def apply_command(command) Modified: test/test-schema.rb (+6 -0) =================================================================== --- test/test-schema.rb 2016-08-09 11:50:54 +0900 (13067e3) +++ test/test-schema.rb 2016-08-09 11:57:33 +0900 (a9e05a4) @@ -74,6 +74,7 @@ class SchemaTest < Test::Unit::TestCase :default_tokenizer => table.default_tokenizer, :normalizer => table.normalizer, :token_filters => table.token_filters, + :reference_key_type? => table.reference_key_type?, } end assert_equal([ @@ -86,12 +87,15 @@ class SchemaTest < Test::Unit::TestCase :default_tokenizer => "TokenBigram", :normalizer => "NormalizerAuto", :token_filters => ["TokenStem", "TokenStopWord"], + :reference_key_type? => false, }, ], table_data) end test "index column" do + @schema.apply_command(table_create("name" => "Entries", + "flags" => "TABLE_NO_KEY")) arguments = { "table" => "Words", "name" => "entries_text", @@ -112,6 +116,7 @@ class SchemaTest < Test::Unit::TestCase :flags => column.flags, :value_type => column.value_type, :sources => column.sources, + :reference_value_type? => column.reference_value_type?, } end end @@ -123,6 +128,7 @@ class SchemaTest < Test::Unit::TestCase :flags => ["WITH_POSITION", "WITH_SECTION", "INDEX_TINY"], :value_type => "Entries", :sources => ["title", "content"], + :reference_value_type? => true, }, ], column_data) -------------- next part -------------- HTML����������������������������... 下载