Kouhei Sutou
null+****@clear*****
Fri Feb 3 17:11:17 JST 2017
Kouhei Sutou 2017-02-03 17:11:17 +0900 (Fri, 03 Feb 2017) New Revision: 736b25adf60873f18efd741b40d5da874c96d352 https://github.com/groonga/groonga/commit/736b25adf60873f18efd741b40d5da874c96d352 Message: Improve error message on table key cast failure Modified files: lib/db.c test/command/suite/load/command_version/3/output_errors/array.expected test/command/suite/load/command_version/3/output_errors/object.expected test/command/suite/load/invalid/key.expected Modified: lib/db.c (+4 -2) =================================================================== --- lib/db.c 2017-02-03 17:06:32 +0900 (55773d7) +++ lib/db.c 2017-02-03 17:11:17 +0900 (d518c37) @@ -1551,7 +1551,8 @@ grn_table_get_by_key(grn_ctx *ctx, grn_obj *table, grn_obj *key) grn_obj buf; GRN_OBJ_INIT(&buf, GRN_BULK, 0, table->header.domain); if ((rc = grn_obj_cast(ctx, key, &buf, GRN_TRUE))) { - ERR(rc, "cast failed"); + grn_obj *domain = grn_ctx_at(ctx, table->header.domain); + ERR_CAST(table, domain, key); } else { id = grn_table_get(ctx, table, GRN_TEXT_VALUE(&buf), GRN_TEXT_LEN(&buf)); } @@ -1571,7 +1572,8 @@ grn_table_add_by_key(grn_ctx *ctx, grn_obj *table, grn_obj *key, int *added) grn_obj buf; GRN_OBJ_INIT(&buf, GRN_BULK, 0, table->header.domain); if ((rc = grn_obj_cast(ctx, key, &buf, GRN_TRUE))) { - ERR(rc, "cast failed"); + grn_obj *domain = grn_ctx_at(ctx, table->header.domain); + ERR_CAST(table, domain, key); } else { id = grn_table_add(ctx, table, GRN_TEXT_VALUE(&buf), GRN_TEXT_LEN(&buf), added); } Modified: test/command/suite/load/command_version/3/output_errors/array.expected (+4 -4) =================================================================== --- test/command/suite/load/command_version/3/output_errors/array.expected 2017-02-03 17:06:32 +0900 (68355ba) +++ test/command/suite/load/command_version/3/output_errors/array.expected 2017-02-03 17:11:17 +0900 (a8607a9) @@ -13,10 +13,10 @@ load --table Numbers --command_version 3 --output_ids yes --output_errors yes "start_time": 0.0, "elapsed_time": 0.0, "error": { - "message": "cast failed", + "message": "<Numbers>: failed to cast to <UInt32>: <\"String\">", "function": "grn_table_add_by_key", "file": "db.c", - "line": 1574 + "line": 1576 } }, "body": { @@ -33,7 +33,7 @@ load --table Numbers --command_version 3 --output_ids yes --output_errors yes }, { "return_code": -22, - "message": "cast failed" + "message": "<Numbers>: failed to cast to <UInt32>: <\"String\">" }, { "return_code": 0, @@ -42,4 +42,4 @@ load --table Numbers --command_version 3 --output_ids yes --output_errors yes ] } } -#|e| cast failed +#|e| <Numbers>: failed to cast to <UInt32>: <"String"> Modified: test/command/suite/load/command_version/3/output_errors/object.expected (+4 -4) =================================================================== --- test/command/suite/load/command_version/3/output_errors/object.expected 2017-02-03 17:06:32 +0900 (2322133) +++ test/command/suite/load/command_version/3/output_errors/object.expected 2017-02-03 17:11:17 +0900 (a0e1298) @@ -12,10 +12,10 @@ load --table Numbers --command_version 3 --output_ids yes --output_errors yes "start_time": 0.0, "elapsed_time": 0.0, "error": { - "message": "cast failed", + "message": "<Numbers>: failed to cast to <UInt32>: <\"String\">", "function": "grn_table_add_by_key", "file": "db.c", - "line": 1574 + "line": 1576 } }, "body": { @@ -32,7 +32,7 @@ load --table Numbers --command_version 3 --output_ids yes --output_errors yes }, { "return_code": -22, - "message": "cast failed" + "message": "<Numbers>: failed to cast to <UInt32>: <\"String\">" }, { "return_code": 0, @@ -41,4 +41,4 @@ load --table Numbers --command_version 3 --output_ids yes --output_errors yes ] } } -#|e| cast failed +#|e| <Numbers>: failed to cast to <UInt32>: <"String"> Modified: test/command/suite/load/invalid/key.expected (+12 -2) =================================================================== --- test/command/suite/load/invalid/key.expected 2017-02-03 17:06:32 +0900 (2313596) +++ test/command/suite/load/invalid/key.expected 2017-02-03 17:11:17 +0900 (8210ae6) @@ -4,7 +4,17 @@ load --table Numbers [ {"_key": "invalid number!"} ] -[[[-22,0.0,0.0],"cast failed"],0] -#|e| cast failed +[ + [ + [ + -22, + 0.0, + 0.0 + ], + "<Numbers>: failed to cast to <Int32>: <\"invalid number!\">" + ], + 0 +] +#|e| <Numbers>: failed to cast to <Int32>: <"invalid number!"> select Numbers [[0,0.0,0.0],[[[0],[["_id","UInt32"],["_key","Int32"]]]]] -------------- next part -------------- HTML����������������������������... Descargar