@@ -851,14 +851,22 @@ _mongoc_write_result_append_upsert (mongoc_write_result_t *result,
851
851
const bson_value_t * value )
852
852
{
853
853
bson_t child ;
854
+ const char * keyptr = NULL ;
855
+ char key [12 ];
856
+ int len ;
854
857
855
858
BSON_ASSERT (result );
856
859
BSON_ASSERT (value );
857
860
858
- bson_append_document_begin (& result -> upserted , "" , -1 , & child );
861
+ len = bson_uint32_to_string (result -> upsert_append_count , & keyptr , key ,
862
+ sizeof key );
863
+
864
+ bson_append_document_begin (& result -> upserted , keyptr , len , & child );
859
865
BSON_APPEND_INT32 (& child , "index" , idx );
860
866
BSON_APPEND_VALUE (& child , "_id" , value );
861
867
bson_append_document_end (& result -> upserted , & child );
868
+
869
+ result -> upsert_append_count ++ ;
862
870
}
863
871
864
872
@@ -992,7 +1000,11 @@ _mongoc_write_result_merge_arrays (mongoc_write_result_t *result, /* IN */
992
1000
bson_iter_t citer ;
993
1001
int32_t idx ;
994
1002
int32_t count = 0 ;
1003
+ int32_t aridx ;
995
1004
bson_t child ;
1005
+ const char * keyptr = NULL ;
1006
+ char key [12 ];
1007
+ int len ;
996
1008
997
1009
ENTRY ;
998
1010
@@ -1001,11 +1013,14 @@ _mongoc_write_result_merge_arrays (mongoc_write_result_t *result, /* IN */
1001
1013
BSON_ASSERT (iter );
1002
1014
BSON_ASSERT (BSON_ITER_HOLDS_ARRAY (iter ));
1003
1015
1016
+ aridx = bson_count_keys (dest );
1017
+
1004
1018
if (bson_iter_recurse (iter , & ar )) {
1005
1019
while (bson_iter_next (& ar )) {
1006
1020
if (BSON_ITER_HOLDS_DOCUMENT (& ar ) &&
1007
1021
bson_iter_recurse (& ar , & citer )) {
1008
- bson_append_document_begin (dest , "" , 0 , & child );
1022
+ len = bson_uint32_to_string (aridx ++ , & keyptr , key , sizeof key );
1023
+ bson_append_document_begin (dest , keyptr , len , & child );
1009
1024
while (bson_iter_next (& citer )) {
1010
1025
if (BSON_ITER_IS_KEY (& citer , "index" )) {
1011
1026
idx = bson_iter_int32 (& citer ) + result -> offset ;
0 commit comments