[Groonga-commit] groonga/groonga [master] show error message when delete filter is used with id and/or key

Back to archive index

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


Ryo Onodera	2011-12-26 13:22:10 +0900 (Mon, 26 Dec 2011)

  New Revision: c7872c98d4cd378e526ccbc17cd538b1c2dc09e0

  Log:
    show error message when delete filter is used with id and/or key

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

  Modified: lib/proc.c (+3 -0)
===================================================================
--- lib/proc.c    2011-12-26 13:20:24 +0900 (709a742)
+++ lib/proc.c    2011-12-26 13:22:10 +0900 (796bedf)
@@ -1604,6 +1604,9 @@ proc_delete(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
     if (GRN_TEXT_LEN(VAR(1)) && GRN_TEXT_LEN(VAR(2))) {
       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)))) {
+      ERR(GRN_INVALID_ARGUMENT, "filter is used with id and/or key");
+      rc = ctx->rc;
     } else if (GRN_TEXT_LEN(VAR(1))) {
       grn_obj *p_key = VAR(1);
       grn_obj key;

  Modified: test/unit/core/test-command-delete.c (+11 -0)
===================================================================
--- test/unit/core/test-command-delete.c    2011-12-26 13:20:24 +0900 (6e271bc)
+++ test/unit/core/test-command-delete.c    2011-12-26 13:22:10 +0900 (ec1a61b)
@@ -26,6 +26,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_key(void);
 void test_referenced_record(void);
 void test_uint64(void);
@@ -150,6 +151,16 @@ test_by_invalid_filter(void)
 }
 
 void
+test_by_id_and_filter(void)
+{
+  grn_test_assert_send_command_error(
+    context,
+    GRN_INVALID_ARGUMENT,
+    "filter is used with id and/or key",
+    "delete Users --id 1 --filter \"true\"");
+}
+
+void
 test_by_delete(void)
 {
   assert_send_command("delete Users tapo");




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