Kouhei Sutou
null+****@clear*****
Wed Feb 13 23:40:23 JST 2013
Kouhei Sutou 2013-02-13 23:40:23 +0900 (Wed, 13 Feb 2013) New Revision: 767078b3da27d5f862f1fabe32da631e9d559c76 https://github.com/groonga/groonga/commit/767078b3da27d5f862f1fabe32da631e9d559c76 Log: Support Bool -> ShortText cast Added files: test/command/suite/load/bool/cast/short_text.expected test/command/suite/load/bool/cast/short_text.test Modified files: lib/db.c Modified: lib/db.c (+7 -0) =================================================================== --- lib/db.c 2013-02-13 23:39:08 +0900 (803e748) +++ lib/db.c 2013-02-13 23:40:23 +0900 (e941660) @@ -4242,6 +4242,13 @@ grn_obj_cast_bool(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp) case GRN_DB_TIME : GRN_TIME_SET(ctx, dest, GRN_BOOL_VALUE(src)); break; + case GRN_DB_SHORT_TEXT : + { + const char *bool_text; + bool_text = GRN_BOOL_VALUE(src) ? "true" : "false"; + GRN_TEXT_PUTS(ctx, dest, bool_text); + } + break; default : SRC2RECORD(); } Added: test/command/suite/load/bool/cast/short_text.expected (+49 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/load/bool/cast/short_text.expected 2013-02-13 23:40:23 +0900 (d5124a3) @@ -0,0 +1,49 @@ +table_create Entries TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Entries published COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +load --table Entries +[ +{"_key": "Special news!", "published": true}, +{"_key": "Surprise news!", "published": false} +] +[[0,0.0,0.0],2] +select Entries +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 2 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "_key", + "ShortText" + ], + [ + "published", + "ShortText" + ] + ], + [ + 1, + "Special news!", + "true" + ], + [ + 2, + "Surprise news!", + "false" + ] + ] + ] +] Added: test/command/suite/load/bool/cast/short_text.test (+10 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/load/bool/cast/short_text.test 2013-02-13 23:40:23 +0900 (a59b01b) @@ -0,0 +1,10 @@ +table_create Entries TABLE_HASH_KEY ShortText +column_create Entries published COLUMN_SCALAR ShortText + +load --table Entries +[ +{"_key": "Special news!", "published": true}, +{"_key": "Surprise news!", "published": false} +] + +select Entries -------------- next part -------------- HTML����������������������������...Download