@@ -656,16 +656,24 @@ int phongo_execute_command(mongoc_client_t *client, char *db, bson_t *command, m
656656 /* Detect if its an command cursor */
657657 if (bson_iter_init_find (& iter , doc , "cursor" ) && BSON_ITER_HOLDS_DOCUMENT (& iter ) && bson_iter_recurse (& iter , & child )) {
658658 while (bson_iter_next (& child )) {
659- if (BSON_ITER_IS_KEY (& child , "firstBatch" )) {
659+ if (BSON_ITER_IS_KEY (& child , "id" )) {
660+ cursor -> rpc .reply .cursor_id = bson_iter_as_int64 (& child );
661+ } else if (BSON_ITER_IS_KEY (& child , "ns" )) {
662+ const char * ns ;
663+
664+ ns = bson_iter_utf8 (& child , & cursor -> nslen );
665+ strncpy (cursor -> ns , ns , sizeof cursor -> ns );
666+ } else if (BSON_ITER_IS_KEY (& child , "firstBatch" )) {
660667 if (BSON_ITER_HOLDS_ARRAY (& child )) {
661668 const uint8_t * data = NULL ;
662669 uint32_t data_len = 0 ;
663670 bson_t first_batch ;
664671
665672 bson_iter_array (& child , & data_len , & data );
666673 if (bson_init_static (& first_batch , data , data_len )) {
667- _phongo_debug_bson (& first_batch );
668674 _mongoc_cursor_cursorid_init (cursor );
675+ cursor -> limit = 0 ;
676+ cursor -> is_command = false;
669677 phongo_result_init (return_value , php_phongo_commandresult_ce , cursor , & first_batch , mongoc_cursor_get_hint (cursor ), 1 TSRMLS_CC );
670678 return true;
671679 }
0 commit comments