Skip to content

Commit 60ca972

Browse files
committed
remove lookup_double
Use `lookup_as_int64` for `ok` field. Server's `BulkWriteReplyItem` appends as double. Support other numerics for future proofing.
1 parent a75a4eb commit 60ca972

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

src/libmongoc/src/mongoc/mongoc-bulkwrite.c

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,39 +1179,6 @@ lookup_as_int64 (
11791179
return false;
11801180
}
11811181

1182-
static bool
1183-
lookup_double (const bson_t *bson, const char *key, double *out, const char *source, mongoc_bulkwriteexception_t *exc)
1184-
{
1185-
BSON_ASSERT_PARAM (bson);
1186-
BSON_ASSERT_PARAM (key);
1187-
BSON_ASSERT_PARAM (out);
1188-
BSON_ASSERT (source || true);
1189-
BSON_ASSERT_PARAM (exc);
1190-
1191-
bson_iter_t iter;
1192-
if (bson_iter_init_find (&iter, bson, key) && BSON_ITER_HOLDS_DOUBLE (&iter)) {
1193-
*out = bson_iter_double (&iter);
1194-
return true;
1195-
}
1196-
bson_error_t error;
1197-
if (source) {
1198-
bson_set_error (&error,
1199-
MONGOC_ERROR_COMMAND,
1200-
MONGOC_ERROR_COMMAND_INVALID_ARG,
1201-
"expected to find double `%s` in %s, but did not",
1202-
key,
1203-
source);
1204-
} else {
1205-
bson_set_error (&error,
1206-
MONGOC_ERROR_COMMAND,
1207-
MONGOC_ERROR_COMMAND_INVALID_ARG,
1208-
"expected to find double `%s`, but did not",
1209-
key);
1210-
}
1211-
_bulkwriteexception_set_error (exc, &error);
1212-
return false;
1213-
}
1214-
12151182
static bool
12161183
lookup_string (
12171184
const bson_t *bson, const char *key, const char **out, const char *source, mongoc_bulkwriteexception_t *exc)
@@ -1688,8 +1655,8 @@ mongoc_bulkwrite_execute (mongoc_bulkwrite_t *self, const mongoc_bulkwriteopts_t
16881655
const bson_t *result;
16891656
while (mongoc_cursor_next (reply_cursor, &result)) {
16901657
// Parse for `ok`.
1691-
double ok;
1692-
if (!lookup_double (result, "ok", &ok, "result", ret.exc)) {
1658+
int64_t ok;
1659+
if (!lookup_as_int64 (result, "ok", &ok, "result", ret.exc)) {
16931660
goto batch_fail;
16941661
}
16951662

0 commit comments

Comments
 (0)