null+****@clear*****
null+****@clear*****
2010年 12月 8日 (水) 14:43:01 JST
Kouhei Sutou 2010-12-08 05:43:01 +0000 (Wed, 08 Dec 2010)
New Revision: df44e568de0316112901637ad50c4f5a6fb22400
Log:
fix that can't load no key table data with [[...]] form. #750
Reported by Masahiro Tomita. Thanks!!!
Modified files:
lib/db.c
test/unit/core/test-command-load.c
Modified: lib/db.c (+1 -2)
===================================================================
--- lib/db.c 2010-12-08 02:36:41 +0000 (f0da3df)
+++ lib/db.c 2010-12-08 05:43:01 +0000 (f3c922c)
@@ -7597,7 +7597,7 @@ bracket_close(grn_ctx *ctx, grn_loader *loader)
break;
case GRN_TABLE_NO_KEY :
if ((GRN_BULK_VSIZE(&loader->level)) > 0 &&
- loader->key_offset != -1 && (ndata == 0 || ndata == ncols)) {
+ (ndata == 0 || ndata == ncols)) {
id = grn_table_add(ctx, loader->table, NULL, 0, NULL);
} else if (!ncols) {
while (ndata--) {
@@ -7606,7 +7606,6 @@ bracket_close(grn_ctx *ctx, grn_loader *loader)
GRN_PTR_PUT(ctx, &loader->columns, col);
value++;
}
- loader->key_offset = 0;
}
break;
default :
Modified: test/unit/core/test-command-load.c (+16 -0)
===================================================================
--- test/unit/core/test-command-load.c 2010-12-08 02:36:41 +0000 (1438244)
+++ test/unit/core/test-command-load.c 2010-12-08 05:43:01 +0000 (718c9cf)
@@ -32,6 +32,7 @@ void data_null(void);
void test_null(gconstpointer data);
void test_index_geo_point(void);
void test_nonexistent_columns(void);
+void test_no_key_table(void);
static gchar *tmp_directory;
@@ -339,3 +340,18 @@ test_nonexistent_columns(void)
"--values "
"'[[\"nonexistent column value\"]]'");
}
+
+void
+test_no_key_table(void)
+{
+ assert_send_command("table_create Users TABLE_NO_KEY");
+ assert_send_command("column_create Users name COLUMN_SCALAR ShortText");
+ assert_send_command("column_create Users desc COLUMN_SCALAR ShortText");
+ cut_assert_equal_string("2",
+ send_command("load "
+ "--table Users "
+ "--columns 'name, desc' "
+ "--values "
+ "'[[\"mori\", \"the author of groonga\"],"
+ "[\"gunyara-kun\", \"co-author\"]]'"));
+}