C++ code using getIntField() returns INT_MIN when running on MongoDB 7.0

Hi. After a MongoDB server update from version 4.2 to 7.0, the function int BSONObj::getIntField(const char *name) const does not return the correct integer value for the respective field anymore, but INT_MIN (-2147483647 ). The correct data does exist in the MongoDB database. Wondering if there is an updated version of this function that the legacy code can use instead perhaps?
Snippet of the code:
auto_ptr cursor;
if ( scheme == “id1” || scheme == “id2” )
cursor = cCDSConn.query(“database.table”, BSON(“identifier” << mID ));
if (cursor->more()) {
BSONObj p = cursor->next();
mData = p.getIntField(“data”);//here mData is being set/returned as INT_MIN
}
Any help would be much appreciated!
Kind regards,
C.

What version of the C++ driver are you using? That sounds like the legacy V1 driver.

1 Like

Thank you. It must be fairly old since I can see the copyright year as 2009 in all the bson.h , etc, including bson-inl.h where the getIntField() function is defined. I will look into upgrading the C++ driver.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.