[Groonga-commit] groonga/groonga [master] mention filter in error message when delete is used with id, key and filter

Back to archive index

null+****@clear***** null+****@clear*****
2011年 12月 26日 (月) 13:31:34 JST


Ryo Onodera	2011-12-26 13:31:34 +0900 (Mon, 26 Dec 2011)

  New Revision: cf0235bb204263793c51c95ee229a9ad0db8bb12

  Log:
    mention filter in error message when delete is used with id, key and filter

  Modified files:
    lib/proc.c
    test/unit/core/test-command-delete.c

  Modified: lib/proc.c (+1 -1)
===================================================================
--- lib/proc.c    2011-12-26 13:22:10 +0900 (796bedf)
+++ lib/proc.c    2011-12-26 13:31:34 +0900 (2510ec8)
@@ -1601,7 +1601,7 @@ proc_delete(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
                                GRN_TEXT_VALUE(VAR(0)),
                                GRN_TEXT_LEN(VAR(0)));
   if (table) {
-    if (GRN_TEXT_LEN(VAR(1)) && GRN_TEXT_LEN(VAR(2))) {
+    if (GRN_TEXT_LEN(VAR(1)) && GRN_TEXT_LEN(VAR(2)) && !GRN_TEXT_LEN(VAR(3))) {
       ERR(GRN_INVALID_ARGUMENT, "both id and key are specified");
       rc = ctx->rc;
     } else if (GRN_TEXT_LEN(VAR(3)) && (GRN_TEXT_LEN(VAR(1)) || GRN_TEXT_LEN(VAR(2)))) {

  Modified: test/unit/core/test-command-delete.c (+11 -0)
===================================================================
--- test/unit/core/test-command-delete.c    2011-12-26 13:22:10 +0900 (ec1a61b)
+++ test/unit/core/test-command-delete.c    2011-12-26 13:31:34 +0900 (588decb)
@@ -27,6 +27,7 @@ void test_by_id(void);
 void test_by_filter(void);
 void test_by_invalid_filter(void);
 void test_by_id_and_filter(void);
+void test_by_all_options(void);
 void test_by_key(void);
 void test_referenced_record(void);
 void test_uint64(void);
@@ -161,6 +162,16 @@ test_by_id_and_filter(void)
 }
 
 void
+test_by_all_options(void)
+{
+  grn_test_assert_send_command_error(
+    context,
+    GRN_INVALID_ARGUMENT,
+    "filter is used with id and/or key",
+    "delete Users --id 1 --key mori --filter \"true\"");
+}
+
+void
 test_by_delete(void)
 {
   assert_send_command("delete Users tapo");




Groonga-commit メーリングリストの案内
Back to archive index