Kouhei Sutou
null+****@clear*****
Wed Feb 13 21:44:59 JST 2013
Kouhei Sutou 2013-02-13 21:44:59 +0900 (Wed, 13 Feb 2013) New Revision: 10449cb7f83bf56c20d747e0b4bb5eef0a77819c https://github.com/groonga/groonga/commit/10449cb7f83bf56c20d747e0b4bb5eef0a77819c Log: Support bool -> record cast Added files: test/command/suite/load/bool/scalar/reference.expected test/command/suite/load/bool/scalar/reference.test Modified files: lib/db.c Modified: lib/db.c (+15 -0) =================================================================== --- lib/db.c 2013-02-09 11:57:50 +0900 (79e17fb) +++ lib/db.c 2013-02-13 21:44:59 +0900 (ffa060b) @@ -4203,6 +4203,18 @@ grn_obj_is_persistent(grn_ctx *ctx, grn_obj *obj) }\ } while (0) +inline static grn_rc +grn_obj_cast_bool(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp) +{ + grn_rc rc = GRN_SUCCESS; + + switch (dest->header.domain) { + default : + SRC2RECORD(); + } + return rc; +} + #define NUM2DEST(getvalue,totext,tobool,totime,tofloat)\ switch (dest->header.domain) {\ case GRN_DB_BOOL :\ @@ -4296,6 +4308,9 @@ grn_obj_cast(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp) { grn_rc rc = GRN_SUCCESS; switch (src->header.domain) { + case GRN_DB_BOOL : + rc = grn_obj_cast_bool(ctx, src, dest, addp); + break; case GRN_DB_INT8 : NUM2DEST(GRN_INT8_VALUE, grn_text_itoa, NUM2BOOL, NUM2TIME, NUM2FLOAT); break; Added: test/command/suite/load/bool/scalar/reference.expected (+51 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/load/bool/scalar/reference.expected 2013-02-13 21:44:59 +0900 (929353b) @@ -0,0 +1,51 @@ +table_create Bools TABLE_HASH_KEY Bool +[[0,0.0,0.0],true] +table_create Entries TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Entries published COLUMN_SCALAR Bools +[[0,0.0,0.0],true] +load --table Entries +[ +{"_key": "Special news!", "published": true}, +{"_key": "Supprise news!", "published": false} +] +[[0,0.0,0.0],2] +select Entries +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 2 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "_key", + "ShortText" + ], + [ + "published", + "Bools" + ] + ], + [ + 1, + "Special news!", + true + ], + [ + 2, + "Supprise news!", + false + ] + ] + ] +] Added: test/command/suite/load/bool/scalar/reference.test (+12 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/load/bool/scalar/reference.test 2013-02-13 21:44:59 +0900 (720f4e9) @@ -0,0 +1,12 @@ +table_create Bools TABLE_HASH_KEY Bool + +table_create Entries TABLE_HASH_KEY ShortText +column_create Entries published COLUMN_SCALAR Bools + +load --table Entries +[ +{"_key": "Special news!", "published": true}, +{"_key": "Supprise news!", "published": false} +] + +select Entries -------------- next part -------------- HTML����������������������������...Download