mongo 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/bin/test.rb +15 -0
- data/lib/mongo/collection/view/builder/find_command.rb +12 -2
- data/lib/mongo/version.rb +1 -1
- data/spec/mongo/collection/view/builder/find_command_spec.rb +43 -2
- data/spec/mongo/cursor_spec.rb +1 -5
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65cf62fc9f77f84668c204be16c29ecf86f6217a
|
4
|
+
data.tar.gz: dfc97cdbd591e0fd9f539dd8bef21fb46af49829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 937f66f51858557875fc829be722fff81d104c1d4c1cc4522335bcaca7937d5026cee53cbe6a682bb9c649a523ddf213c4a5de1dd29005530c74a8a392538fbe
|
7
|
+
data.tar.gz: b38fbd21f331920971e2fd466147d21d0a9fa866079b57c9618c6aca908ebc20123f6bab467116bb18ac76e432703a74e80d256ce90c58a91ea25e0a6e8901b7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/bin/test.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require 'pry'
|
5
|
+
require 'mongo'
|
6
|
+
|
7
|
+
# include the mongo namespace
|
8
|
+
include Mongo
|
9
|
+
|
10
|
+
client = Mongo::Client.new("mongodb://localhost:27017/?ssl=true&sslVerify=false")
|
11
|
+
|
12
|
+
binding.pry
|
13
|
+
|
14
|
+
client
|
15
|
+
|
@@ -43,6 +43,7 @@ module Mongo
|
|
43
43
|
show_disk_loc: 'showRecordId',
|
44
44
|
snapshot: 'snapshot',
|
45
45
|
tailable: 'tailable',
|
46
|
+
tailable_cursor: 'tailable',
|
46
47
|
oplog_replay: 'oplogReplay',
|
47
48
|
no_cursor_timeout: 'noCursorTimeout',
|
48
49
|
await_data: 'awaitData',
|
@@ -93,17 +94,26 @@ module Mongo
|
|
93
94
|
|
94
95
|
def find_command
|
95
96
|
document = BSON::Document.new('find' => collection.name, 'filter' => filter)
|
96
|
-
command = Options::Mapper.transform_documents(options, MAPPINGS, document)
|
97
|
+
command = Options::Mapper.transform_documents(convert_flags(options), MAPPINGS, document)
|
97
98
|
convert_negative_limit(command)
|
98
99
|
end
|
99
100
|
|
100
101
|
def convert_negative_limit(command)
|
101
102
|
if command[:limit] && command[:limit] < 0
|
102
|
-
command
|
103
|
+
command['limit'] = command['limit'].abs
|
103
104
|
command[:singleBatch] = true
|
104
105
|
end
|
105
106
|
command
|
106
107
|
end
|
108
|
+
|
109
|
+
def convert_flags(options)
|
110
|
+
return options if options.empty?
|
111
|
+
opts = options.dup
|
112
|
+
opts.delete(:cursor_type)
|
113
|
+
Flags.map_flags(options).reduce(opts) do |opts, key|
|
114
|
+
opts.merge!(key => true)
|
115
|
+
end
|
116
|
+
end
|
107
117
|
end
|
108
118
|
end
|
109
119
|
end
|
data/lib/mongo/version.rb
CHANGED
@@ -159,8 +159,49 @@ describe Mongo::Collection::View::Builder::FindCommand do
|
|
159
159
|
expect(selector['singleBatch']).to be true
|
160
160
|
end
|
161
161
|
|
162
|
-
it '
|
163
|
-
expect(selector['limit']).to
|
162
|
+
it 'converts the limit to a positive value' do
|
163
|
+
expect(selector['limit']).to be(options[:limit].abs)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
context 'when cursor_type is specified' do
|
168
|
+
|
169
|
+
let(:filter) do
|
170
|
+
{ 'name' => 'test' }
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'when cursor_type is :tailable' do
|
174
|
+
|
175
|
+
let(:options) do
|
176
|
+
{
|
177
|
+
cursor_type: :tailable,
|
178
|
+
}
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'maps to tailable' do
|
182
|
+
expect(selector['tailable']).to be true
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'does not map to awaitData' do
|
186
|
+
expect(selector['awaitData']).to be_nil
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context 'when cursor_type is :tailable_await' do
|
191
|
+
|
192
|
+
let(:options) do
|
193
|
+
{
|
194
|
+
cursor_type: :tailable_await,
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'maps to tailable' do
|
199
|
+
expect(selector['tailable']).to be true
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'maps to awaitData' do
|
203
|
+
expect(selector['awaitData']).to be true
|
204
|
+
end
|
164
205
|
end
|
165
206
|
end
|
166
207
|
end
|
data/spec/mongo/cursor_spec.rb
CHANGED
@@ -136,14 +136,10 @@ describe Mongo::Cursor do
|
|
136
136
|
Mongo::Collection::View.new(authorized_collection, {}, :limit => -2)
|
137
137
|
end
|
138
138
|
|
139
|
-
it 'returns the positive number of documents'
|
139
|
+
it 'returns the positive number of documents' do
|
140
140
|
expect(cursor.to_a.count).to eq(2)
|
141
141
|
end
|
142
142
|
|
143
|
-
it 'returns all documents', if: find_command_enabled? do
|
144
|
-
expect(cursor.to_a.count).to eq(10)
|
145
|
-
end
|
146
|
-
|
147
143
|
it 'iterates the documents' do
|
148
144
|
cursor.each do |doc|
|
149
145
|
expect(doc).to have_key('field')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -32,7 +32,7 @@ cert_chain:
|
|
32
32
|
EhIn2f8suSc9QAqYt7w4T+PMtjxWTVcXs+Uy2PbDtjhtEBz6ZsP6YSsOpJbrCjCV
|
33
33
|
wZtXjpRUvWz86V5vjhHCTE8fqfEb85aeDwUCckPzpio=
|
34
34
|
-----END CERTIFICATE-----
|
35
|
-
date: 2016-
|
35
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
36
36
|
dependencies:
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bson
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- README.md
|
60
60
|
- Rakefile
|
61
61
|
- bin/mongo_console
|
62
|
+
- bin/test.rb
|
62
63
|
- lib/csasl/csasl.bundle
|
63
64
|
- lib/mongo.rb
|
64
65
|
- lib/mongo/address.rb
|
metadata.gz.sig
CHANGED
Binary file
|