Overview
本页介绍了升级到新版本的C++驱动程序时必须对应用程序进行的更改。
升级前,请执行以下操作:
Ensure the new C++ driver version is compatible with the MongoDB Server versions your application connects to and the C++ standard version your application compiles with. For version compatibility information, see Compatibility.
Address any breaking changes between the driver version your application is using and your planned upgrade version in the Breaking Changes section.
提示
为了确保在 升级 驱动程序 版本时跨 MongoDB Server 版本的兼容性,请使用 Stable API 。
重大更改
重大更改是对从特定版本的驱动程序开始的约定或行为的更改。 如果在升级驱动程序之前未解决,此类更改可能会导致应用程序无法正常工作。
本部分中的破坏性变更 (breaking change) 按引入它们的驱动程序版本进行分类。升级驱动程序版本时,请解决当前版本和升级版本之间的所有破坏性变更 (breaking change)。
例子
从版本3.0升级
如果您要将C++驱动程序从版本 3.0 升级到版本 3.10,解决为版本 3.1 到 3.10 列出的所有破坏性变更(如有)。
版本 3.11破坏性变更
删除了对MongoDB Server v 3.6的支持。
需要MongoDB C驱动程序v 1.28.0或更高版本。
如果
ENABLE_TESTS配置选项设立为ON,则需要C++14 或更高版本。 您可以在 CMake 配置期间通过ENABLE_TESTS=OFF禁用测试,从而选择退出C++14 要求。删除 bsoncxx ABI 中以下私有成员函数的导出:
bsoncxx::v_noabi::types::bson_value::value::value(const uint8_t*, uint32_t, uint32_t, uint32_t) bsoncxx::v_noabi::types::bson_value::view::_init(void*) bsoncxx::v_noabi::types::bson_value::view::view(const uint8_t*, uint32_t, uint32_t, uint32_t) bsoncxx::v_noabi::types::bson_value::view::view(void*) 删除 mongocxx ABI 中以下私有成员函数的导出:
mongocxx::v_noabi::options::change_stream::as_bson() mongocxx::v_noabi::options::aggregate::append(bsoncxx::v_noabi::builder::basic::document&) mongocxx::v_noabi::options::index::storage_options() 使用 MSVC 编译时,使用
__cdecl声明所有导出函数符号。 如果您在构建项目时使用替代的默认调用约定,则这是一项 ABI破坏性变更 (breaking change)。
版本 3.10破坏性变更
此驱动程序版本引入了以下破坏性变更 (breaking change):
删除了对
find_package(libbsoncxx)和find_package(libmongocxx)的支持。 请改用find_package(bsoncxx)和find_package(mongocxx)。删除支持旧版 CMake包配置文件提供的
LIBBSONCXX_*和LIBMONGOCXX_*CMake 变量的支持。 请改用mongo::bsoncxx_*和mongo::mongocxx_*CMake 目标。删除作为 polyfill 选项的实验性C++标准库 (
BSONCXX_POLY_USE_STD_EXPERIMENTAL)。
版本 3.9破坏性变更
此驱动程序版本引入了以下破坏性变更 (breaking change):
删除了对 CMake项目构建树中导出目标的支持
删除支持macOS 10.14 、macOS 10.15和Ubuntu 14.04的支持
需要MongoDB C驱动程序v 1.25.0或更高版本
需要 CMake v 3.15或更高版本
3.8及更早版本
对于 3.8 及更早版本的驱动程序,请参阅 GitHub 上每个发布的发布说明和关联的 JIRA 工单。