-
Notifications
You must be signed in to change notification settings - Fork 209
PHPC-240: Cannot iterate beyond command cursor's first batch #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested removing this because, after simplifying our iteration handlers, it would only be used in the Cursor's debug handler.
lgtm |
After reading the It is really confusing if calling
And since cannot do that without re-executing the query, which we clearly don't want to do -- I think we must throw an exception. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are adding tests for this -- maybe add one test where the results fit nicely within the batchSize?
I think calling rewind more than once (even when no next() is called), should throw that exception. |
85a4dab
to
deee649
Compare
libmongoc already provides a mechanism to upgrade a cursor with a single command result document into a command cursor, which will seamlessly iterate through the first batch and documents returned by successive getmore ops. This allows us to remove our own "first batch" handling and simplify the move_forward and rewind iteration handlers.
php_phongo_cursor_iterator_dtor() should not need to free the current element, which is stored on our cursor struct. If the cursor is only used by one iterator, zval_ptr_dtor() on the iterator's intern.data property (i.e. our Cursor zval) will implicitly call the free_object handler, which will invoke php_phongo_cursor_free() and clear the current element.
deee649
to
70b7110
Compare
lgtm -- see also https://jira.mongodb.org/browse/PHPC-255 |
https://jira.mongodb.org/browse/PHPC-240