Kosuke Asami
null+****@clear*****
Tue Jul 16 14:12:26 JST 2013
Kosuke Asami 2013-07-16 14:12:26 +0900 (Tue, 16 Jul 2013) New Revision: 3d591acb38d45f3f761be208fc4a7ec092969193 https://github.com/groonga/fluent-plugin-droonga/commit/3d591acb38d45f3f761be208fc4a7ec092969193 Message: column_create: enable "flags" parameter TODO: Support index-type column Modified files: lib/droonga/plugin/groonga/column_create.rb test/plugin/groonga/test_column_create.rb Modified: lib/droonga/plugin/groonga/column_create.rb (+20 -1) =================================================================== --- lib/droonga/plugin/groonga/column_create.rb 2013-07-16 14:04:31 +0900 (0bde8ed) +++ lib/droonga/plugin/groonga/column_create.rb 2013-07-16 14:12:26 +0900 (882db19) @@ -32,13 +32,32 @@ module Droonga table_name = @command["table"] column_name = @command["name"] column_type = @command["type"] + + options = parse_command Groonga::Schema.define(:context => @context) do |schema| schema.change_table(table_name) do |table| - table.column(column_name, column_type) + table.column(column_name, column_type, options) end end [true] end + + private + def parse_command + options = {} + parse_flags(options) + options + end + + def parse_flags(options) + options[:type] = :scalar + if****@comma*****_scalar? + options[:type] = :scalar + elsif****@comma*****_vector? + options[:type] = :vector + end + options + end end end end Modified: test/plugin/groonga/test_column_create.rb (+28 -0) =================================================================== --- test/plugin/groonga/test_column_create.rb 2013-07-16 14:04:31 +0900 (3a63bbb) +++ test/plugin/groonga/test_column_create.rb 2013-07-16 14:12:26 +0900 (6d318f4) @@ -37,4 +37,32 @@ table_create Books TABLE_HASH_KEY --key_type ShortText column_create Books main_text COLUMN_SCALAR LongText SCHEMA end + + class FlagsTest < self + data({ + "COLUMN_SCALAR" => { + :flags => "COLUMN_SCALAR", + :schema => <<-SCHEMA, +column_create Books title COLUMN_SCALAR ShortText + SCHEMA + }, + "COLUMN_VECTOR" => { + :flags => "COLUMN_VECTOR", + :schema => <<-SCHEMA, +column_create Books title COLUMN_VECTOR ShortText + SCHEMA + }, + }) + def test_flags(data) + request = { + "table" => "Books", + "name" => "title", + "type" => "ShortText", + "flags" => data[:flags], + } + @handler.table_create({"name" => "Books"}) + @handler.column_create(request) + assert_equal("table_create Books TABLE_HASH_KEY --key_type ShortText\n#{data[:schema]}", dump) + end + end end -------------- next part -------------- HTML����������������������������...Download