null+****@clear*****
null+****@clear*****
2010年 7月 16日 (金) 10:12:43 JST
Kouhei Sutou 2010-07-16 01:12:43 +0000 (Fri, 16 Jul 2010) New Revision: fc79bf00e6f06ee3189172fb11889aa99ad33e8b Log: support null and "" as empty vector. Modified files: lib/db.c test/unit/core/test-command-load.c Modified: lib/db.c (+4 -2) =================================================================== --- lib/db.c 2010-07-22 08:43:11 +0000 (40b57b9) +++ lib/db.c 2010-07-16 01:12:43 +0000 (83fea99) @@ -4384,7 +4384,9 @@ grn_obj_set_value(grn_ctx *ctx, grn_obj *obj, grn_id id, } else { switch (value->header.type) { case GRN_BULK : - { + if (!GRN_BULK_VSIZE(value)) { + rc = grn_ja_put(ctx, (grn_ja *)obj, id, NULL, 0, flags); + } else { grn_obj v; GRN_OBJ_INIT(&v, GRN_VECTOR, GRN_OBJ_DO_SHALLOW_COPY, GRN_DB_TEXT); v.u.v.body = value; @@ -7610,7 +7612,7 @@ json_read(grn_ctx *ctx, grn_loader *loader, const char *str, unsigned str_len) case 'n' : if (GRN_TEXT_LEN(loader->last) == 4 && !memcmp(v, "null", 4)) { loader->last->header.domain = GRN_DB_VOID; - GRN_UINT32_SET(ctx, loader->last, GRN_ID_NIL); + GRN_BULK_REWIND(loader->last); } break; case 't' : Modified: test/unit/core/test-command-load.c (+0 -2) =================================================================== --- test/unit/core/test-command-load.c 2010-07-22 08:43:11 +0000 (1a3b21a) +++ test/unit/core/test-command-load.c 2010-07-16 01:12:43 +0000 (e6650ce) @@ -264,8 +264,6 @@ data_null(void) void test_null(gconstpointer data) { - cut_omit("not implemented yet"); - assert_send_command("table_create Students TABLE_HASH_KEY ShortText"); assert_send_command("column_create Students nick COLUMN_SCALAR ShortText"); assert_send_command("column_create Students scores COLUMN_VECTOR Int32");