mongo 2.0.6 → 2.1.0
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 +5 -2
- data/lib/mongo/address/ipv4.rb +6 -1
- data/lib/mongo/address/unix.rb +2 -2
- data/lib/mongo/address.rb +18 -10
- data/lib/mongo/auth/cr/conversation.rb +1 -1
- data/lib/mongo/auth/ldap/conversation.rb +7 -3
- data/lib/mongo/auth/scram/conversation.rb +9 -3
- data/lib/mongo/auth/user/view.rb +23 -2
- data/lib/mongo/auth/x509/conversation.rb +1 -1
- data/lib/mongo/bulk_write/combineable.rb +51 -0
- data/lib/mongo/bulk_write/ordered_combiner.rb +55 -0
- data/lib/mongo/bulk_write/result.rb +191 -0
- data/lib/mongo/bulk_write/result_combiner.rb +117 -0
- data/lib/mongo/bulk_write/transformable.rb +132 -0
- data/lib/mongo/bulk_write/unordered_combiner.rb +52 -0
- data/lib/mongo/bulk_write/validatable.rb +62 -0
- data/lib/mongo/bulk_write.rb +159 -23
- data/lib/mongo/client.rb +52 -16
- data/lib/mongo/cluster/topology/replica_set.rb +27 -9
- data/lib/mongo/cluster/topology/sharded.rb +1 -1
- data/lib/mongo/cluster/topology/unknown.rb +5 -2
- data/lib/mongo/cluster.rb +42 -7
- data/lib/mongo/collection/view/aggregation.rb +48 -9
- data/lib/mongo/collection/view/immutable.rb +6 -6
- data/lib/mongo/collection/view/iterable.rb +18 -4
- data/lib/mongo/collection/view/map_reduce.rb +58 -17
- data/lib/mongo/collection/view/readable.rb +173 -42
- data/lib/mongo/collection/view/writable.rb +37 -23
- data/lib/mongo/collection/view.rb +2 -2
- data/lib/mongo/collection.rb +370 -33
- data/lib/mongo/cursor.rb +15 -3
- data/lib/mongo/database/view.rb +5 -4
- data/lib/mongo/database.rb +14 -4
- data/lib/mongo/dbref.rb +113 -0
- data/lib/mongo/error/closed_stream.rb +34 -0
- data/lib/mongo/error/extra_file_chunk.rb +34 -0
- data/lib/mongo/error/{invalid_uri_option.rb → file_not_found.rb} +11 -12
- data/lib/mongo/error/invalid_file.rb +2 -2
- data/lib/mongo/error/invalid_file_revision.rb +37 -0
- data/lib/mongo/error/invalid_uri.rb +5 -4
- data/lib/mongo/error/missing_file_chunk.rb +38 -0
- data/lib/mongo/error/operation_failure.rb +1 -1
- data/lib/mongo/error/parser.rb +1 -1
- data/lib/mongo/error/unchangeable_collection_option.rb +38 -0
- data/lib/mongo/error/unexpected_chunk_length.rb +39 -0
- data/lib/mongo/error.rb +13 -2
- data/lib/mongo/event/description_changed.rb +1 -1
- data/lib/mongo/grid/file/chunk.rb +6 -6
- data/lib/mongo/grid/file/{metadata.rb → info.rb} +41 -39
- data/lib/mongo/grid/file.rb +13 -10
- data/lib/mongo/grid/fs_bucket.rb +448 -0
- data/lib/mongo/grid/stream/read.rb +208 -0
- data/lib/mongo/grid/stream/write.rb +187 -0
- data/lib/mongo/grid/stream.rb +64 -0
- data/lib/mongo/grid.rb +2 -1
- data/lib/mongo/index/view.rb +3 -3
- data/lib/mongo/index.rb +5 -0
- data/lib/mongo/loggable.rb +34 -57
- data/lib/mongo/logger.rb +16 -78
- data/lib/mongo/monitoring/command_log_subscriber.rb +112 -0
- data/lib/mongo/monitoring/event/command_failed.rb +96 -0
- data/lib/mongo/monitoring/event/command_started.rb +89 -0
- data/lib/mongo/monitoring/event/command_succeeded.rb +118 -0
- data/lib/mongo/monitoring/event/secure.rb +58 -0
- data/lib/mongo/monitoring/event.rb +18 -0
- data/lib/mongo/monitoring/publishable.rb +106 -0
- data/lib/mongo/monitoring.rb +195 -0
- data/lib/mongo/operation/{aggregate.rb → commands/aggregate.rb} +3 -41
- data/lib/mongo/operation/commands/collections_info/result.rb +39 -0
- data/lib/mongo/operation/commands/collections_info.rb +68 -0
- data/lib/mongo/operation/{command.rb → commands/command.rb} +2 -18
- data/lib/mongo/operation/commands/indexes.rb +70 -0
- data/lib/mongo/operation/commands/list_collections/result.rb +112 -0
- data/lib/mongo/operation/commands/list_collections.rb +54 -0
- data/lib/mongo/operation/commands/list_indexes/result.rb +116 -0
- data/lib/mongo/operation/commands/list_indexes.rb +56 -0
- data/lib/mongo/operation/{map_reduce → commands/map_reduce}/result.rb +1 -1
- data/lib/mongo/operation/{map_reduce.rb → commands/map_reduce.rb} +3 -41
- data/lib/mongo/operation/commands/parallel_scan/result.rb +72 -0
- data/lib/mongo/operation/commands/parallel_scan.rb +56 -0
- data/lib/mongo/operation/commands/user_query.rb +69 -0
- data/lib/mongo/{bulk_write/ordered_bulk_write.rb → operation/commands/users_info/result.rb} +18 -30
- data/lib/mongo/operation/commands/users_info.rb +53 -0
- data/lib/mongo/operation/commands.rb +24 -0
- data/lib/mongo/operation/executable.rb +4 -68
- data/lib/mongo/operation/kill_cursors.rb +3 -3
- data/lib/mongo/operation/read/get_more.rb +2 -22
- data/lib/mongo/{bulk_write/unordered_bulk_write.rb → operation/read/query/result.rb} +20 -26
- data/lib/mongo/operation/read/query.rb +4 -21
- data/lib/mongo/operation/read.rb +0 -4
- data/lib/mongo/operation/{read_preferrable.rb → read_preference.rb} +3 -2
- data/lib/mongo/operation/result.rb +13 -1
- data/lib/mongo/operation/specifiable.rb +42 -0
- data/lib/mongo/operation/write/bulk/bulkable.rb +82 -0
- data/lib/mongo/operation/write/bulk/delete/result.rb +74 -0
- data/lib/mongo/operation/write/bulk/delete.rb +71 -0
- data/lib/mongo/operation/write/bulk/insert/result.rb +129 -0
- data/lib/mongo/operation/write/bulk/insert.rb +96 -0
- data/lib/mongo/operation/write/bulk/legacy_mergable.rb +87 -0
- data/lib/mongo/operation/write/bulk/mergable.rb +71 -0
- data/lib/mongo/operation/write/bulk/update/result.rb +174 -0
- data/lib/mongo/operation/write/bulk/update.rb +81 -0
- data/lib/mongo/operation/write/bulk.rb +6 -3
- data/lib/mongo/operation/write/command/create_index.rb +0 -1
- data/lib/mongo/operation/write/command/create_user.rb +0 -1
- data/lib/mongo/operation/write/command/delete.rb +0 -1
- data/lib/mongo/operation/write/command/drop_index.rb +0 -1
- data/lib/mongo/operation/write/command/insert.rb +0 -1
- data/lib/mongo/operation/write/command/remove_user.rb +0 -1
- data/lib/mongo/operation/write/command/update.rb +0 -1
- data/lib/mongo/operation/write/command/update_user.rb +0 -1
- data/lib/mongo/operation/write/command/writable.rb +13 -18
- data/lib/mongo/operation/write/create_index.rb +4 -27
- data/lib/mongo/operation/write/create_user.rb +4 -30
- data/lib/mongo/operation/write/delete.rb +6 -29
- data/lib/mongo/operation/write/drop_index.rb +3 -3
- data/lib/mongo/operation/write/gle.rb +48 -0
- data/lib/mongo/operation/write/idable.rb +5 -0
- data/lib/mongo/operation/write/insert.rb +2 -24
- data/lib/mongo/operation/write/remove_user.rb +4 -27
- data/lib/mongo/operation/write/update.rb +13 -36
- data/lib/mongo/operation/write/update_user.rb +4 -30
- data/lib/mongo/operation/write/write_command_enabled.rb +53 -0
- data/lib/mongo/operation/write.rb +2 -0
- data/lib/mongo/operation.rb +32 -4
- data/lib/mongo/options/mapper.rb +4 -2
- data/lib/mongo/options/redacted.rb +156 -0
- data/lib/mongo/options.rb +1 -0
- data/lib/mongo/protocol/delete.rb +75 -15
- data/lib/mongo/protocol/get_more.rb +65 -13
- data/lib/mongo/protocol/insert.rb +85 -13
- data/lib/mongo/protocol/kill_cursors.rb +59 -14
- data/lib/mongo/protocol/message.rb +12 -12
- data/lib/mongo/protocol/query.rb +163 -37
- data/lib/mongo/protocol/reply.rb +103 -0
- data/lib/mongo/protocol/serializers.rb +1 -1
- data/lib/mongo/protocol/update.rb +82 -14
- data/lib/mongo/retryable.rb +83 -0
- data/lib/mongo/server/connectable.rb +21 -25
- data/lib/mongo/server/connection.rb +75 -4
- data/lib/mongo/server/connection_pool/queue.rb +15 -0
- data/lib/mongo/server/connection_pool.rb +12 -0
- data/lib/mongo/server/description/features.rb +2 -1
- data/lib/mongo/server/description.rb +52 -1
- data/lib/mongo/server/monitor/connection.rb +26 -2
- data/lib/mongo/server/monitor.rb +19 -3
- data/lib/mongo/server.rb +39 -5
- data/lib/mongo/server_selector/selectable.rb +40 -31
- data/lib/mongo/server_selector.rb +19 -10
- data/lib/mongo/socket/ssl.rb +28 -16
- data/lib/mongo/socket/tcp.rb +3 -3
- data/lib/mongo/socket/unix.rb +5 -8
- data/lib/mongo/socket.rb +11 -4
- data/lib/mongo/uri.rb +248 -137
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo.rb +5 -3
- data/spec/mongo/address/unix_spec.rb +1 -1
- data/spec/mongo/address_spec.rb +25 -0
- data/spec/mongo/auth/cr_spec.rb +9 -1
- data/spec/mongo/auth/ldap/conversation_spec.rb +43 -0
- data/spec/mongo/auth/ldap_spec.rb +9 -1
- data/spec/mongo/auth/scram_spec.rb +9 -1
- data/spec/mongo/auth/user/view_spec.rb +26 -1
- data/spec/mongo/auth/x509_spec.rb +9 -1
- data/spec/mongo/bulk_write/ordered_combiner_spec.rb +271 -0
- data/spec/mongo/bulk_write/unordered_combiner_spec.rb +239 -0
- data/spec/mongo/bulk_write_spec.rb +428 -0
- data/spec/mongo/client_spec.rb +167 -17
- data/spec/mongo/cluster/topology/replica_set_spec.rb +18 -9
- data/spec/mongo/cluster/topology/sharded_spec.rb +11 -3
- data/spec/mongo/cluster/topology/single_spec.rb +12 -4
- data/spec/mongo/cluster_spec.rb +55 -10
- data/spec/mongo/collection/view/aggregation_spec.rb +188 -1
- data/spec/mongo/collection/view/explainable_spec.rb +1 -1
- data/spec/mongo/collection/view/immutable_spec.rb +103 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +99 -4
- data/spec/mongo/collection/view/readable_spec.rb +238 -6
- data/spec/mongo/collection/view/writable_spec.rb +4 -4
- data/spec/mongo/collection/view_spec.rb +459 -71
- data/spec/mongo/collection_spec.rb +1291 -9
- data/spec/mongo/command_monitoring_spec.rb +51 -0
- data/spec/mongo/connection_string_spec.rb +115 -0
- data/spec/mongo/crud_spec.rb +2 -2
- data/spec/mongo/cursor_spec.rb +3 -3
- data/spec/mongo/database_spec.rb +47 -11
- data/spec/mongo/dbref_spec.rb +149 -0
- data/spec/mongo/grid/file/chunk_spec.rb +5 -5
- data/spec/mongo/grid/file/{metadata_spec.rb → info_spec.rb} +29 -17
- data/spec/mongo/grid/file_spec.rb +8 -8
- data/spec/mongo/grid/fs_bucket_spec.rb +1020 -0
- data/spec/mongo/grid/stream/read_spec.rb +275 -0
- data/spec/mongo/grid/stream/write_spec.rb +440 -0
- data/spec/mongo/grid/stream_spec.rb +48 -0
- data/spec/mongo/gridfs_spec.rb +50 -0
- data/spec/mongo/logger_spec.rb +0 -40
- data/spec/mongo/monitoring/command_log_subscriber_spec.rb +76 -0
- data/spec/mongo/monitoring/event/command_started_spec.rb +26 -0
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +26 -0
- data/spec/mongo/monitoring/event/secure_spec.rb +57 -0
- data/spec/mongo/monitoring_spec.rb +168 -0
- data/spec/mongo/operation/commands/aggregate_spec.rb +69 -0
- data/spec/mongo/operation/{read → commands}/collections_info_spec.rb +1 -1
- data/spec/mongo/operation/{command_spec.rb → commands/command_spec.rb} +0 -18
- data/spec/mongo/operation/{read → commands}/indexes_spec.rb +1 -1
- data/spec/mongo/operation/{map_reduce_spec.rb → commands/map_reduce_spec.rb} +1 -19
- data/spec/mongo/operation/kill_cursors_spec.rb +1 -17
- data/spec/mongo/operation/read/get_more_spec.rb +0 -16
- data/spec/mongo/operation/read/query_spec.rb +19 -16
- data/spec/mongo/operation/{read_preferrable_spec.rb → read_preference_spec.rb} +11 -11
- data/spec/mongo/operation/write/bulk/{bulk_delete_spec.rb → delete_spec.rb} +18 -29
- data/spec/mongo/operation/write/bulk/{bulk_insert_spec.rb → insert_spec.rb} +3 -14
- data/spec/mongo/operation/write/bulk/{bulk_update_spec.rb → update_spec.rb} +8 -19
- data/spec/mongo/operation/write/command/delete_spec.rb +0 -16
- data/spec/mongo/operation/write/command/insert_spec.rb +0 -16
- data/spec/mongo/operation/write/command/update_spec.rb +0 -16
- data/spec/mongo/operation/write/delete_spec.rb +4 -4
- data/spec/mongo/operation/write/insert_spec.rb +2 -13
- data/spec/mongo/operation/write/update_spec.rb +7 -7
- data/spec/mongo/options/redacted_spec.rb +350 -0
- data/spec/mongo/protocol/kill_cursors_spec.rb +5 -3
- data/spec/mongo/protocol/query_spec.rb +15 -30
- data/spec/mongo/retryable_spec.rb +147 -0
- data/spec/mongo/server/connection_pool/queue_spec.rb +16 -0
- data/spec/mongo/server/connection_pool_spec.rb +50 -6
- data/spec/mongo/server/connection_spec.rb +49 -4
- data/spec/mongo/server/description_spec.rb +49 -3
- data/spec/mongo/server/monitor_spec.rb +51 -0
- data/spec/mongo/server_discovery_and_monitoring_spec.rb +32 -59
- data/spec/mongo/server_selection_rtt_spec.rb +37 -57
- data/spec/mongo/server_selection_spec.rb +19 -9
- data/spec/mongo/server_selector/nearest_spec.rb +35 -27
- data/spec/mongo/server_selector/primary_preferred_spec.rb +32 -30
- data/spec/mongo/server_selector/primary_spec.rb +21 -14
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +28 -26
- data/spec/mongo/server_selector/secondary_spec.rb +24 -22
- data/spec/mongo/server_selector_spec.rb +87 -24
- data/spec/mongo/server_spec.rb +94 -8
- data/spec/mongo/socket/ssl_spec.rb +123 -13
- data/spec/mongo/socket/unix_spec.rb +52 -0
- data/spec/mongo/uri_spec.rb +295 -67
- data/spec/spec_helper.rb +40 -24
- data/spec/support/authorization.rb +23 -9
- data/spec/support/certificates/client.pem +4 -4
- data/spec/support/command_monitoring/bulkWrite.yml +73 -0
- data/spec/support/command_monitoring/command.yml +42 -0
- data/spec/support/command_monitoring/deleteMany.yml +55 -0
- data/spec/support/command_monitoring/deleteOne.yml +55 -0
- data/spec/support/command_monitoring/find.yml +219 -0
- data/spec/support/command_monitoring/insertMany.yml +81 -0
- data/spec/support/command_monitoring/insertOne.yml +51 -0
- data/spec/support/command_monitoring/updateMany.yml +67 -0
- data/spec/support/command_monitoring/updateOne.yml +95 -0
- data/spec/support/command_monitoring.rb +365 -0
- data/spec/support/connection_string.rb +228 -0
- data/spec/support/connection_string_tests/invalid-uris.yml +193 -0
- data/spec/support/connection_string_tests/valid-auth.yml +256 -0
- data/spec/support/connection_string_tests/valid-host_identifiers.yml +121 -0
- data/spec/support/connection_string_tests/valid-options.yml +30 -0
- data/spec/support/connection_string_tests/valid-unix_socket-absolute.yml +197 -0
- data/spec/support/connection_string_tests/valid-unix_socket-relative.yml +213 -0
- data/spec/support/connection_string_tests/valid-warnings.yml +55 -0
- data/spec/support/crud/read.rb +22 -19
- data/spec/support/crud/write.rb +58 -27
- data/spec/support/crud.rb +10 -2
- data/spec/support/gridfs.rb +637 -0
- data/spec/support/gridfs_tests/delete.yml +157 -0
- data/spec/support/gridfs_tests/download.yml +210 -0
- data/spec/support/gridfs_tests/download_by_name.yml +113 -0
- data/spec/support/gridfs_tests/upload.yml +158 -0
- data/spec/support/matchers.rb +1 -1
- data/spec/support/sdam/rs/equal_electionids.yml +44 -0
- data/spec/support/sdam/rs/new_primary_new_electionid.yml +95 -0
- data/spec/support/sdam/rs/null_election_id.yml +144 -0
- data/spec/support/sdam/rs/primary_disconnect_electionid.yml +124 -0
- data/spec/support/sdam/rs/primary_mismatched_me.yml +37 -0
- data/spec/support/sdam/rs/primary_to_no_primary_mismatched_me.yml +75 -0
- data/spec/support/sdam/rs/secondary_mismatched_me.yml +37 -0
- data/spec/support/sdam/sharded/mongos_disconnect.yml +104 -0
- data/spec/support/sdam/single/direct_connection_rsarbiter.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rsprimary.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rssecondary.yml +1 -1
- data/spec/support/sdam/single/direct_connection_slave.yml +1 -1
- data/spec/support/sdam/single/direct_connection_standalone.yml +1 -1
- data/spec/support/sdam/single/not_ok_response.yml +0 -1
- data/spec/support/server_discovery_and_monitoring.rb +22 -3
- data/spec/support/server_selection.rb +3 -1
- data/spec/support/shared/bulk_write.rb +218 -22
- data/spec/support/shared/server_selector.rb +80 -14
- data.tar.gz.sig +0 -0
- metadata +188 -59
- metadata.gz.sig +0 -0
- data/lib/mongo/bulk_write/bulk_writable.rb +0 -196
- data/lib/mongo/bulk_write/deletable.rb +0 -56
- data/lib/mongo/bulk_write/insertable.rb +0 -48
- data/lib/mongo/bulk_write/replacable.rb +0 -57
- data/lib/mongo/bulk_write/updatable.rb +0 -68
- data/lib/mongo/grid/fs.rb +0 -149
- data/lib/mongo/operation/list_collections/result.rb +0 -114
- data/lib/mongo/operation/list_indexes/result.rb +0 -118
- data/lib/mongo/operation/read/collections_info.rb +0 -68
- data/lib/mongo/operation/read/indexes.rb +0 -69
- data/lib/mongo/operation/read/list_collections.rb +0 -76
- data/lib/mongo/operation/read/list_indexes.rb +0 -78
- data/lib/mongo/operation/write/bulk/bulk_delete/result.rb +0 -75
- data/lib/mongo/operation/write/bulk/bulk_delete.rb +0 -145
- data/lib/mongo/operation/write/bulk/bulk_insert/result.rb +0 -130
- data/lib/mongo/operation/write/bulk/bulk_insert.rb +0 -132
- data/lib/mongo/operation/write/bulk/bulk_mergable.rb +0 -67
- data/lib/mongo/operation/write/bulk/bulk_update/result.rb +0 -162
- data/lib/mongo/operation/write/bulk/bulk_update.rb +0 -154
- data/lib/mongo/operation/write/bulk/legacy_bulk_mergable.rb +0 -83
- data/spec/mongo/bulk/bulk_write_spec.rb +0 -262
- data/spec/mongo/grid/fs_spec.rb +0 -160
- data/spec/mongo/loggable_spec.rb +0 -63
- data/spec/mongo/operation/aggregate_spec.rb +0 -127
- /data/lib/mongo/operation/{aggregate → commands/aggregate}/result.rb +0 -0
data/spec/support/crud/write.rb
CHANGED
@@ -21,7 +21,7 @@ module Mongo
|
|
21
21
|
#
|
22
22
|
# @since 2.0.0
|
23
23
|
class Write
|
24
|
-
|
24
|
+
|
25
25
|
# Map of CRUD operation names to method names.
|
26
26
|
#
|
27
27
|
# @since 2.0.0
|
@@ -34,7 +34,8 @@ module Mongo
|
|
34
34
|
'updateOne' => :update_one,
|
35
35
|
'findOneAndDelete' => :find_one_and_delete,
|
36
36
|
'findOneAndReplace' => :find_one_and_replace,
|
37
|
-
'findOneAndUpdate' => :find_one_and_update
|
37
|
+
'findOneAndUpdate' => :find_one_and_update,
|
38
|
+
'bulkWrite' => :bulk_write
|
38
39
|
}
|
39
40
|
|
40
41
|
# Map of operation options to method names.
|
@@ -42,7 +43,11 @@ module Mongo
|
|
42
43
|
# @since 2.0.0
|
43
44
|
ARGUMENT_MAP = {
|
44
45
|
:sort => 'sort',
|
45
|
-
:projection => 'projection'
|
46
|
+
:projection => 'projection',
|
47
|
+
:return_document => 'returnDocument',
|
48
|
+
:upsert => 'upsert',
|
49
|
+
:ordered => 'ordered',
|
50
|
+
:write_concern => 'writeConcern'
|
46
51
|
}
|
47
52
|
|
48
53
|
# Operations that need a check if results on < 2.6 will match.
|
@@ -52,7 +57,7 @@ module Mongo
|
|
52
57
|
'updateMany',
|
53
58
|
'updateOne',
|
54
59
|
'replaceOne']
|
55
|
-
|
60
|
+
|
56
61
|
# The operation name.
|
57
62
|
#
|
58
63
|
# @return [ String ] name The operation name.
|
@@ -107,21 +112,25 @@ module Mongo
|
|
107
112
|
def requires_2_6?(collection)
|
108
113
|
REQUIRES_2_6.include?(name) && upsert
|
109
114
|
end
|
110
|
-
|
115
|
+
|
111
116
|
private
|
112
|
-
|
117
|
+
|
118
|
+
def bulk_write(collection)
|
119
|
+
collection.bulk_write(requests, options)
|
120
|
+
end
|
121
|
+
|
113
122
|
def delete_many(collection)
|
114
|
-
result = collection.
|
123
|
+
result = collection.delete_many(filter)
|
115
124
|
{ 'deletedCount' => result.deleted_count }
|
116
125
|
end
|
117
126
|
|
118
127
|
def delete_one(collection)
|
119
|
-
result = collection.
|
128
|
+
result = collection.delete_one(filter)
|
120
129
|
{ 'deletedCount' => result.deleted_count }
|
121
130
|
end
|
122
131
|
|
123
132
|
def insert_many(collection)
|
124
|
-
result = collection.insert_many(documents)
|
133
|
+
result = collection.insert_many(documents, options)
|
125
134
|
{ 'insertedIds' => result.inserted_ids }
|
126
135
|
end
|
127
136
|
|
@@ -137,48 +146,50 @@ module Mongo
|
|
137
146
|
end
|
138
147
|
|
139
148
|
def replace_one(collection)
|
140
|
-
result = collection.
|
149
|
+
result = collection.replace_one(filter, replacement, options)
|
141
150
|
update_return_doc(result)
|
142
151
|
end
|
143
152
|
|
144
153
|
def update_many(collection)
|
145
|
-
result = collection.
|
154
|
+
result = collection.update_many(filter, update, options)
|
146
155
|
update_return_doc(result)
|
147
156
|
end
|
148
157
|
|
149
158
|
def update_one(collection)
|
150
|
-
result = collection.
|
159
|
+
result = collection.update_one(filter, update, options)
|
151
160
|
update_return_doc(result)
|
152
161
|
end
|
153
162
|
|
154
163
|
def find_one_and_delete(collection)
|
155
|
-
|
156
|
-
ARGUMENT_MAP.each do |key, value|
|
157
|
-
view = view.send(key, arguments[value]) if arguments[value]
|
158
|
-
end
|
159
|
-
view.find_one_and_delete
|
164
|
+
collection.find_one_and_delete(filter, options)
|
160
165
|
end
|
161
166
|
|
162
167
|
def find_one_and_replace(collection)
|
163
|
-
|
164
|
-
ARGUMENT_MAP.each do |key, value|
|
165
|
-
view = view.send(key, arguments[value]) if arguments[value]
|
166
|
-
end
|
167
|
-
view.find_one_and_replace(replacement, upsert: upsert, return_document: return_document)
|
168
|
+
collection.find_one_and_replace(filter, replacement, options)
|
168
169
|
end
|
169
170
|
|
170
171
|
def find_one_and_update(collection)
|
171
|
-
|
172
|
-
|
173
|
-
|
172
|
+
collection.find_one_and_update(filter, update, options)
|
173
|
+
end
|
174
|
+
|
175
|
+
def options
|
176
|
+
ARGUMENT_MAP.reduce({}) do |opts, (key, value)|
|
177
|
+
arguments.key?(value) ? opts.merge!(key => send(key)) : opts
|
174
178
|
end
|
175
|
-
view.find_one_and_update(update, upsert: upsert, return_document: return_document)
|
176
179
|
end
|
177
180
|
|
178
181
|
def replacement
|
179
182
|
arguments['replacement']
|
180
183
|
end
|
181
184
|
|
185
|
+
def sort
|
186
|
+
arguments['sort']
|
187
|
+
end
|
188
|
+
|
189
|
+
def projection
|
190
|
+
arguments['projection']
|
191
|
+
end
|
192
|
+
|
182
193
|
def documents
|
183
194
|
arguments['documents']
|
184
195
|
end
|
@@ -187,10 +198,30 @@ module Mongo
|
|
187
198
|
arguments['document']
|
188
199
|
end
|
189
200
|
|
201
|
+
def write_concern
|
202
|
+
arguments['writeConcern']
|
203
|
+
end
|
204
|
+
|
205
|
+
def ordered
|
206
|
+
arguments['ordered']
|
207
|
+
end
|
208
|
+
|
190
209
|
def filter
|
191
210
|
arguments['filter']
|
192
211
|
end
|
193
212
|
|
213
|
+
def requests
|
214
|
+
arguments['requests'].map do |request|
|
215
|
+
case request.keys.first
|
216
|
+
when 'insertOne' then
|
217
|
+
{ insert_one: request['insertOne']['document'] }
|
218
|
+
when 'updateOne' then
|
219
|
+
update = request['updateOne']
|
220
|
+
{ update_one: { filter: update['filter'], update: update['update'] }}
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
194
225
|
def upsert
|
195
226
|
arguments['upsert']
|
196
227
|
end
|
@@ -209,4 +240,4 @@ module Mongo
|
|
209
240
|
end
|
210
241
|
end
|
211
242
|
end
|
212
|
-
end
|
243
|
+
end
|
data/spec/support/crud.rb
CHANGED
@@ -53,7 +53,9 @@ module Mongo
|
|
53
53
|
#
|
54
54
|
# @since 2.0.0
|
55
55
|
def initialize(file)
|
56
|
-
|
56
|
+
file = File.new(file)
|
57
|
+
@spec = YAML.load(ERB.new(file.read).result)
|
58
|
+
file.close
|
57
59
|
@description = File.basename(file)
|
58
60
|
@data = @spec['data']
|
59
61
|
@crud_tests = @spec['tests']
|
@@ -142,7 +144,13 @@ module Mongo
|
|
142
144
|
#
|
143
145
|
# @since 2.0.0
|
144
146
|
def compare_collection_data
|
145
|
-
actual_collection_data
|
147
|
+
if actual_collection_data.nil?
|
148
|
+
outcome_collection_data.nil?
|
149
|
+
else
|
150
|
+
actual_collection_data.all? do |doc|
|
151
|
+
outcome_collection_data.include?(doc)
|
152
|
+
end
|
153
|
+
end
|
146
154
|
end
|
147
155
|
|
148
156
|
# Whether this test requires server version >= 2.6 for its results to match
|