Kouhei Sutou
null+****@clear*****
Tue Nov 11 13:17:21 JST 2014
Kouhei Sutou 2014-11-11 13:17:21 +0900 (Tue, 11 Nov 2014) New Revision: 0e131e204d9da21d76bdc0cd54a8e854d86f9bd2 https://github.com/groonga/groonga/commit/0e131e204d9da21d76bdc0cd54a8e854d86f9bd2 Message: Fix a bug that not equal operation (!=) with Time and String String value is casted as integer and compared. It should also support "yyyy-mm-dd HH:MM:SS" format. Added files: test/command/suite/select/filter/no_index/time/not_equal_string.expected test/command/suite/select/filter/no_index/time/not_equal_string.test Modified files: lib/expr.c Modified: lib/expr.c (+8 -3) =================================================================== --- lib/expr.c 2014-11-11 13:12:27 +0900 (56ad2af) +++ lib/expr.c 2014-11-11 13:17:21 +0900 (ffcce9e) @@ -1557,9 +1557,14 @@ grn_expr_compile(grn_ctx *ctx, grn_obj *expr) case GRN_DB_TEXT :\ case GRN_DB_LONG_TEXT :\ {\ - const char *p_ = GRN_TEXT_VALUE(y);\ - int i_ = grn_atoi(p_, p_ + GRN_TEXT_LEN(y), NULL);\ - r = (x_ == GRN_TIME_PACK(i_, 0));\ + grn_obj time_value_;\ + GRN_TIME_INIT(&time_value_, 0);\ + if (grn_obj_cast(ctx, y, &time_value_, GRN_FALSE) == GRN_SUCCESS) {\ + r = (x_ == GRN_TIME_VALUE(&time_value_));\ + } else {\ + r = 0;\ + }\ + GRN_OBJ_FIN(ctx, &time_value_);\ }\ break;\ default :\ Added: test/command/suite/select/filter/no_index/time/not_equal_string.expected (+44 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/no_index/time/not_equal_string.expected 2014-11-11 13:17:21 +0900 (ec91300) @@ -0,0 +1,44 @@ +table_create Memos TABLE_PAT_KEY ShortText +[[0,0.0,0.0],true] +column_create Memos timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +load --table Memos +[ +{"_key": "Hello!", "timestamp": "2014-11-11 12:49:00"}, +{"_key": "World!", "timestamp": "2014-11-11 12:50:00"} +] +[[0,0.0,0.0],2] +select Memos --filter 'timestamp != "2014-11-11 12:49:00"' +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 1 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "_key", + "ShortText" + ], + [ + "timestamp", + "Time" + ] + ], + [ + 2, + "World!", + 1415677800.0 + ] + ] + ] +] Added: test/command/suite/select/filter/no_index/time/not_equal_string.test (+10 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/no_index/time/not_equal_string.test 2014-11-11 13:17:21 +0900 (55b6903) @@ -0,0 +1,10 @@ +table_create Memos TABLE_PAT_KEY ShortText +column_create Memos timestamp COLUMN_SCALAR Time + +load --table Memos +[ +{"_key": "Hello!", "timestamp": "2014-11-11 12:49:00"}, +{"_key": "World!", "timestamp": "2014-11-11 12:50:00"} +] + +select Memos --filter 'timestamp != "2014-11-11 12:49:00"' -------------- next part -------------- HTML����������������������������... ダウンロード