null+****@clear*****
null+****@clear*****
2011年 12月 19日 (月) 13:53:01 JST
Kouhei Sutou 2011-12-19 04:53:01 +0000 (Mon, 19 Dec 2011) New Revision: 019447ef0028eff3e895c3e88d298b771ad7fe30 Log: [shcema][table-create] add value type check for view. refs #915 refs #1210 Modified files: lib/db.c test/unit/http/test-http-schema.rb Modified: lib/db.c (+9 -0) =================================================================== --- lib/db.c 2011-12-19 04:49:43 +0000 (7a7d399) +++ lib/db.c 2011-12-19 04:53:01 +0000 (a7c6535) @@ -657,6 +657,15 @@ grn_table_create_validate(grn_ctx *ctx, const char *name, unsigned name_size, "[table][create] " "key isn't available for view table: <%.*s> (%.*s)", name_size, name, key_name_size, key_name); + } else if (value_type) { + int value_name_size; + char value_name[GRN_TABLE_MAX_KEY_SIZE]; + value_name_size = grn_obj_name(ctx, value_type, value_name, + GRN_TABLE_MAX_KEY_SIZE); + ERR(GRN_INVALID_ARGUMENT, + "[table][create] " + "value isn't available for view table: <%.*s> (%.*s)", + name_size, name, value_name_size, value_name); } else if (flags & GRN_OBJ_KEY_WITH_SIS) { ERR(GRN_INVALID_ARGUMENT, "[table][create] " Modified: test/unit/http/test-http-schema.rb (+4 -2) =================================================================== --- test/unit/http/test-http-schema.rb 2011-12-19 04:49:43 +0000 (3e66a99) +++ test/unit/http/test-http-schema.rb 2011-12-19 04:53:01 +0000 (c60d901) @@ -679,8 +679,10 @@ class HTTPSchemaTest < Test::Unit::TestCase :name => "users", :flags => Table::VIEW, :value_type => "Int32")) - assert_error_response(Result::UNKNOWN_ERROR, - "value isn't available", + assert_error_response(Result::INVALID_ARGUMENT, + "[table][create] " + + "value isn't available for view table: " + + "<users> (Int32)", response, :content_type => "application/json")