mongo 2.18.1 → 2.18.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/mongo/bulk_write.rb +6 -4
  4. data/lib/mongo/client.rb +1 -1
  5. data/lib/mongo/collection/view/writable.rb +0 -2
  6. data/lib/mongo/collection.rb +150 -45
  7. data/lib/mongo/crypt/kms.rb +0 -1
  8. data/lib/mongo/error/invalid_read_option.rb +1 -1
  9. data/lib/mongo/operation/aggregate.rb +1 -2
  10. data/lib/mongo/operation/collections_info.rb +3 -15
  11. data/lib/mongo/operation/command.rb +1 -2
  12. data/lib/mongo/operation/count.rb +1 -2
  13. data/lib/mongo/operation/create.rb +1 -2
  14. data/lib/mongo/operation/create_index.rb +1 -2
  15. data/lib/mongo/operation/create_user.rb +1 -2
  16. data/lib/mongo/operation/delete.rb +0 -1
  17. data/lib/mongo/operation/distinct.rb +1 -2
  18. data/lib/mongo/operation/drop.rb +1 -2
  19. data/lib/mongo/operation/drop_database.rb +1 -2
  20. data/lib/mongo/operation/drop_index.rb +1 -2
  21. data/lib/mongo/operation/explain.rb +1 -3
  22. data/lib/mongo/operation/find/builder.rb +0 -1
  23. data/lib/mongo/operation/find.rb +1 -3
  24. data/lib/mongo/operation/get_more.rb +1 -3
  25. data/lib/mongo/operation/indexes.rb +1 -17
  26. data/lib/mongo/operation/insert.rb +0 -1
  27. data/lib/mongo/operation/kill_cursors.rb +1 -2
  28. data/lib/mongo/operation/list_collections.rb +1 -2
  29. data/lib/mongo/operation/map_reduce.rb +1 -2
  30. data/lib/mongo/operation/parallel_scan.rb +1 -2
  31. data/lib/mongo/operation/remove_user.rb +1 -2
  32. data/lib/mongo/operation/shared/{polymorphic_operation.rb → op_msg_executable.rb} +11 -6
  33. data/lib/mongo/operation/update.rb +0 -1
  34. data/lib/mongo/operation/update_user.rb +1 -2
  35. data/lib/mongo/operation/users_info.rb +1 -2
  36. data/lib/mongo/operation/write_command.rb +1 -2
  37. data/lib/mongo/operation.rb +1 -3
  38. data/lib/mongo/protocol.rb +0 -3
  39. data/lib/mongo/query_cache.rb +20 -20
  40. data/lib/mongo/session.rb +1 -1
  41. data/lib/mongo/version.rb +1 -1
  42. data/spec/integration/command_spec.rb +1 -23
  43. data/spec/mongo/client_construction_spec.rb +4 -4
  44. data/spec/mongo/collection_crud_spec.rb +56 -0
  45. data/spec/mongo/collection_spec.rb +11 -1
  46. data/spec/mongo/crypt/kms_spec.rb +12 -9
  47. data.tar.gz.sig +0 -0
  48. metadata +1133 -1186
  49. metadata.gz.sig +0 -0
  50. data/lib/mongo/operation/aggregate/command.rb +0 -55
  51. data/lib/mongo/operation/collections_info/command.rb +0 -48
  52. data/lib/mongo/operation/command/command.rb +0 -41
  53. data/lib/mongo/operation/count/command.rb +0 -47
  54. data/lib/mongo/operation/create/command.rb +0 -47
  55. data/lib/mongo/operation/create_index/command.rb +0 -61
  56. data/lib/mongo/operation/create_user/command.rb +0 -46
  57. data/lib/mongo/operation/delete/command.rb +0 -52
  58. data/lib/mongo/operation/distinct/command.rb +0 -47
  59. data/lib/mongo/operation/drop/command.rb +0 -41
  60. data/lib/mongo/operation/drop_database/command.rb +0 -41
  61. data/lib/mongo/operation/drop_index/command.rb +0 -45
  62. data/lib/mongo/operation/explain/command.rb +0 -58
  63. data/lib/mongo/operation/explain/legacy.rb +0 -52
  64. data/lib/mongo/operation/find/builder/legacy.rb +0 -123
  65. data/lib/mongo/operation/find/command.rb +0 -51
  66. data/lib/mongo/operation/find/legacy/result.rb +0 -46
  67. data/lib/mongo/operation/find/legacy.rb +0 -52
  68. data/lib/mongo/operation/get_more/command.rb +0 -43
  69. data/lib/mongo/operation/get_more/legacy.rb +0 -39
  70. data/lib/mongo/operation/indexes/command.rb +0 -42
  71. data/lib/mongo/operation/indexes/legacy.rb +0 -48
  72. data/lib/mongo/operation/insert/command.rb +0 -55
  73. data/lib/mongo/operation/kill_cursors/command.rb +0 -48
  74. data/lib/mongo/operation/list_collections/command.rb +0 -46
  75. data/lib/mongo/operation/map_reduce/command.rb +0 -51
  76. data/lib/mongo/operation/parallel_scan/command.rb +0 -57
  77. data/lib/mongo/operation/remove_user/command.rb +0 -46
  78. data/lib/mongo/operation/shared/op_msg_or_command.rb +0 -41
  79. data/lib/mongo/operation/shared/op_msg_or_find_command.rb +0 -44
  80. data/lib/mongo/operation/update/command.rb +0 -53
  81. data/lib/mongo/operation/update_user/command.rb +0 -45
  82. data/lib/mongo/operation/users_info/command.rb +0 -46
  83. data/lib/mongo/operation/write_command/command.rb +0 -51
  84. data/lib/mongo/protocol/delete.rb +0 -172
  85. data/lib/mongo/protocol/insert.rb +0 -181
  86. data/lib/mongo/protocol/update.rb +0 -214
  87. data/spec/mongo/operation/delete/command_spec.rb +0 -115
  88. data/spec/mongo/operation/find/legacy_spec.rb +0 -131
  89. data/spec/mongo/operation/get_more_spec.rb +0 -63
  90. data/spec/mongo/operation/insert/command_spec.rb +0 -118
  91. data/spec/mongo/operation/update/command_spec.rb +0 -122
  92. data/spec/mongo/protocol/delete_spec.rb +0 -185
  93. data/spec/mongo/protocol/insert_spec.rb +0 -179
  94. data/spec/mongo/protocol/update_spec.rb +0 -204
@@ -1,204 +0,0 @@
1
- # frozen_string_literal: true
2
- # encoding: utf-8
3
-
4
- require 'lite_spec_helper'
5
- require 'support/shared/protocol'
6
-
7
- describe Mongo::Protocol::Update do
8
-
9
- let(:opcode) { 2001 }
10
- let(:db) { SpecConfig.instance.test_db }
11
- let(:collection_name) { 'protocol-test' }
12
- let(:ns) { "#{db}.#{collection_name}" }
13
- let(:selector) { { :name => 'Tyler' } }
14
- let(:update_doc) { { :name => 'Bob' } }
15
- let(:options) { Hash.new }
16
-
17
- let(:message) do
18
- described_class.new(db, collection_name, selector, update_doc, options)
19
- end
20
-
21
- describe '#initialize' do
22
-
23
- it 'sets the namespace' do
24
- expect(message.namespace).to eq(ns)
25
- end
26
-
27
- it 'sets the selector' do
28
- expect(message.selector).to eq(selector)
29
- end
30
-
31
- it 'sets the update document' do
32
- expect(message.update).to eq(update_doc)
33
- end
34
- end
35
-
36
- describe '#==' do
37
-
38
- context 'when the other is an update' do
39
-
40
- context 'when the fields are equal' do
41
- let(:other) do
42
- described_class.new(db, collection_name, selector, update_doc, options)
43
- end
44
-
45
- it 'returns true' do
46
- expect(message).to eq(other)
47
- end
48
- end
49
-
50
- context 'when the database is not equal' do
51
- let(:other) do
52
- described_class.new('tyler', collection_name, selector, update_doc, options)
53
- end
54
-
55
- it 'returns false' do
56
- expect(message).not_to eq(other)
57
- end
58
- end
59
-
60
- context 'when the collection is not equal' do
61
- let(:other) do
62
- described_class.new(db, 'tyler', selector, update_doc, options)
63
- end
64
-
65
- it 'returns false' do
66
- expect(message).not_to eq(other)
67
- end
68
- end
69
-
70
- context 'when the selector is not equal' do
71
- let(:other) do
72
- described_class.new(db, collection_name, { :a => 1 }, update_doc, options)
73
- end
74
-
75
- it 'returns false' do
76
- expect(message).not_to eq(other)
77
- end
78
- end
79
-
80
- context 'when the update document is not equal' do
81
- let(:other) do
82
- described_class.new(db, collection_name, selector, { :a => 1 }, options)
83
- end
84
-
85
- it 'returns false' do
86
- expect(message).not_to eq(other)
87
- end
88
- end
89
-
90
- context 'when the options are not equal' do
91
- let(:other) do
92
- described_class.new(db, collection_name, selector, update_doc,
93
- :flags => :upsert)
94
- end
95
-
96
- it 'returns false' do
97
- expect(message).not_to eq(other)
98
- end
99
- end
100
- end
101
-
102
- context 'when the other is not a query' do
103
- let(:other) do
104
- expect(message).not_to eq('test')
105
- end
106
- end
107
- end
108
-
109
- describe '#hash' do
110
- let(:values) do
111
- message.send(:fields).map do |field|
112
- message.instance_variable_get(field[:name])
113
- end
114
- end
115
-
116
- it 'returns a hash of the field values' do
117
- expect(message.hash).to eq(values.hash)
118
- end
119
- end
120
-
121
- describe '#replyable?' do
122
-
123
- it 'returns false' do
124
- expect(message).to_not be_replyable
125
- end
126
- end
127
-
128
- describe '#serialize' do
129
- let(:bytes) { message.serialize }
130
-
131
- include_examples 'message with a header'
132
-
133
- describe 'zero' do
134
- let(:field) { bytes.to_s[16..19] }
135
-
136
- it 'serializes a zero' do
137
- expect(field).to be_int32(0)
138
- end
139
- end
140
-
141
- describe 'namespace' do
142
- let(:field) { bytes.to_s[20..36] }
143
- it 'serializes the namespace' do
144
- expect(field).to be_cstring(ns)
145
- end
146
- end
147
-
148
- describe 'flags' do
149
- let(:field) { bytes.to_s[37..40] }
150
-
151
- context 'when no flags are provided' do
152
- it 'does not set any bits' do
153
- expect(field).to be_int32(0)
154
- end
155
- end
156
-
157
- context 'when flags are provided' do
158
- let(:options) { { :flags => flags } }
159
-
160
- context 'upsert flag' do
161
- let(:flags) { [:upsert] }
162
- it 'sets the first bit' do
163
- expect(field).to be_int32(1)
164
- end
165
- end
166
-
167
- context 'multi update' do
168
- let(:flags) { [:multi_update] }
169
- it 'sets the second bit' do
170
- expect(field).to be_int32(2)
171
- end
172
- end
173
- end
174
- end
175
-
176
- describe 'selector' do
177
- let(:field) { bytes.to_s[41..61] }
178
- it 'serializes the selector' do
179
- expect(field).to be_bson(selector)
180
- end
181
- end
182
-
183
- describe 'update' do
184
- let(:field) { bytes.to_s[62..80] }
185
- it 'serializes the update' do
186
- expect(field).to be_bson(update_doc)
187
- end
188
- end
189
- end
190
-
191
- describe '#registry' do
192
-
193
- context 'when the class is loaded' do
194
-
195
- it 'registers the op code in the Protocol Registry' do
196
- expect(Mongo::Protocol::Registry.get(described_class::OP_CODE)).to be(described_class)
197
- end
198
-
199
- it 'creates an #op_code instance method' do
200
- expect(message.op_code).to eq(described_class::OP_CODE)
201
- end
202
- end
203
- end
204
- end