-
Notifications
You must be signed in to change notification settings - Fork 534
RUBY-843 the listCollections and listIndexes commands can return a cursor #556
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -289,7 +289,23 @@ def collections_info(coll_name=nil) | |
| if @client.wire_version_feature?(Mongo::MongoClient::MONGODB_2_8) | ||
| cmd = BSON::OrderedHash[:listCollections, 1] | ||
| cmd.merge!(:filter => { :name => coll_name }) if coll_name | ||
| self.command(cmd)['collections'] | ||
| result = self.command(cmd, :cursor => {}) | ||
| if result.key?('cursor') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make it easier to rip out later, I'd look for "collections" instead.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for now, it works better this way because otherwise it'd be ugly: (currently, the block of code in the else statement is what I return) |
||
| cursor_info = result['cursor'] | ||
| pinned_pool = @connection.pinned_pool | ||
| pinned_pool = pinned_pool[:pool] if pinned_pool.respond_to?(:keys) | ||
|
|
||
| seed = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need to use the 'ns' field for OP_GET_MORE. |
||
| :cursor_id => cursor_info['id'], | ||
| :first_batch => cursor_info['firstBatch'], | ||
| :pool => pinned_pool, | ||
| :ns => cursor_info['ns'] | ||
| } | ||
|
|
||
| Cursor.new(self, seed.merge!(opts)).collect { |doc| doc['collections'] } | ||
| else | ||
| result['collections'] | ||
| end | ||
| else | ||
| legacy_collections_info(coll_name).to_a | ||
| end | ||
|
|
@@ -493,11 +509,27 @@ def drop_index(collection_name, index_name) | |
| # defining the index. | ||
| def index_information(collection_name) | ||
| if @client.wire_version_feature?(Mongo::MongoClient::MONGODB_2_8) | ||
| result = self.command(:listIndexes => collection_name)['indexes'] | ||
| result = self.command({ :listIndexes => collection_name }, :cursor => {}) | ||
| if result.key?('cursor') | ||
| cursor_info = result['cursor'] | ||
| pinned_pool = @connection.pinned_pool | ||
| pinned_pool = pinned_pool[:pool] if pinned_pool.respond_to?(:keys) | ||
|
|
||
| seed = { | ||
| :cursor_id => cursor_info['id'], | ||
| :first_batch => cursor_info['firstBatch'], | ||
| :pool => pinned_pool, | ||
| :ns => cursor_info['ns'] | ||
| } | ||
|
|
||
| indexes = Cursor.new(self, seed.merge!(opts)).collect { |doc| doc['indexes'] } | ||
| else | ||
| indexes = result['indexes'] | ||
| end | ||
| else | ||
| result = legacy_list_indexes(collection_name) | ||
| indexes = legacy_list_indexes(collection_name) | ||
| end | ||
| result.reduce({}) do |info, index| | ||
| indexes.reduce({}) do |info, index| | ||
| info.merge!(index['name'] => index) | ||
| end | ||
| end | ||
|
|
||
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.
You have to pass :cursor => {} as well.