diff --git a/extend/lbson/src/bson.h b/extend/lbson/src/bson.h index 08c00910..d27e48e3 100644 --- a/extend/lbson/src/bson.h +++ b/extend/lbson/src/bson.h @@ -345,7 +345,8 @@ namespace lbson { size_t sz; const char* buf = lua_tolstring(L, -1, &sz); if (buf[0] == 0 && sz >= 2) { - m_buffer.push_data((uint8_t*)buf + 1, sz - 1); + write_key((bson_type)buf[1], key, len); + if (sz > 2) m_buffer.push_data((uint8_t*)(buf + 2), sz - 2); } else { write_key(bson_type::BSON_STRING, key, len); write_string(buf, sz); diff --git a/server/test/mongo_test.lua b/server/test/mongo_test.lua index 1b1e4f1b..343d9219 100644 --- a/server/test/mongo_test.lua +++ b/server/test/mongo_test.lua @@ -35,9 +35,9 @@ timer_mgr:once(2000, function() icode, ierr = mongo_mgr:drop_indexes("test_mongo_2", "test_uid") log_debug("db drop_indexes code: {}, err = {}", icode, ierr) - icode, ierr = mongo_mgr:insert(primary_id, "test_mongo_1", {pid = 123457, uid = 3, time = quanta.now_ms, ttl = bdate(quanta.now + 30)}) + icode, ierr = mongo_mgr:insert(primary_id, "test_mongo_1", {pid = 123457, uid = 3, time = quanta.now, ts = quanta.now_ms, tm = os.time() ttl = bdate(quanta.now + 30)}) log_debug("db insert code: {}, err = {}", icode, ierr) - icode, ierr = mongo_mgr:create_indexes("test_mongo_1", {{key={pid,1,uid,1},name="test_uid", unique = true}}) + icode, ierr = mongo_mgr:create_indexes("test_mongo_1", {{key={"pid",1,"uid",1},name="test_uid", unique = true}}) log_debug("db create_indexes code: {}, err = {}", icode, ierr) --[[