@@ -656,16 +656,24 @@ int phongo_execute_command(mongoc_client_t *client, char *db, bson_t *command, m
656
656
/* Detect if its an command cursor */
657
657
if (bson_iter_init_find (& iter , doc , "cursor" ) && BSON_ITER_HOLDS_DOCUMENT (& iter ) && bson_iter_recurse (& iter , & child )) {
658
658
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" )) {
660
667
if (BSON_ITER_HOLDS_ARRAY (& child )) {
661
668
const uint8_t * data = NULL ;
662
669
uint32_t data_len = 0 ;
663
670
bson_t first_batch ;
664
671
665
672
bson_iter_array (& child , & data_len , & data );
666
673
if (bson_init_static (& first_batch , data , data_len )) {
667
- _phongo_debug_bson (& first_batch );
668
674
_mongoc_cursor_cursorid_init (cursor );
675
+ cursor -> limit = 0 ;
676
+ cursor -> is_command = false;
669
677
phongo_result_init (return_value , php_phongo_commandresult_ce , cursor , & first_batch , mongoc_cursor_get_hint (cursor ), 1 TSRMLS_CC );
670
678
return true;
671
679
}
0 commit comments