mongo 2.0.0.rc → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -1
  4. data/README.md +1 -4
  5. data/lib/mongo/client.rb +1 -1
  6. data/lib/mongo/collection.rb +1 -1
  7. data/lib/mongo/collection/view.rb +1 -1
  8. data/lib/mongo/collection/view/writable.rb +26 -10
  9. data/lib/mongo/database.rb +1 -1
  10. data/lib/mongo/grid/file.rb +12 -0
  11. data/lib/mongo/grid/file/chunk.rb +1 -1
  12. data/lib/mongo/grid/file/metadata.rb +13 -0
  13. data/lib/mongo/operation/aggregate.rb +1 -1
  14. data/lib/mongo/operation/write.rb +1 -5
  15. data/lib/mongo/operation/write/bulk.rb +17 -0
  16. data/lib/mongo/operation/write/{bulk_delete.rb → bulk/bulk_delete.rb} +1 -1
  17. data/lib/mongo/operation/{bulk_delete → write/bulk/bulk_delete}/result.rb +3 -0
  18. data/lib/mongo/operation/write/{bulk_insert.rb → bulk/bulk_insert.rb} +1 -1
  19. data/lib/mongo/operation/{bulk_insert → write/bulk/bulk_insert}/result.rb +3 -0
  20. data/lib/mongo/operation/write/{bulk_mergable.rb → bulk/bulk_mergable.rb} +0 -0
  21. data/lib/mongo/operation/write/{bulk_update.rb → bulk/bulk_update.rb} +1 -1
  22. data/lib/mongo/operation/{bulk_update → write/bulk/bulk_update}/result.rb +8 -1
  23. data/lib/mongo/operation/write/{legacy_bulk_mergable.rb → bulk/legacy_bulk_mergable.rb} +0 -0
  24. data/lib/mongo/operation/write/delete.rb +2 -0
  25. data/lib/mongo/operation/write/delete/result.rb +40 -0
  26. data/lib/mongo/operation/write/insert.rb +2 -0
  27. data/lib/mongo/operation/write/insert/result.rb +32 -0
  28. data/lib/mongo/operation/write/update.rb +9 -4
  29. data/lib/mongo/operation/write/update/result.rb +160 -0
  30. data/lib/mongo/server/connectable.rb +11 -0
  31. data/lib/mongo/server/connection.rb +1 -0
  32. data/lib/mongo/server/connection_pool.rb +1 -1
  33. data/lib/mongo/server/connection_pool/queue.rb +1 -1
  34. data/lib/mongo/server/monitor.rb +16 -0
  35. data/lib/mongo/server/monitor/connection.rb +1 -0
  36. data/lib/mongo/socket/ssl.rb +30 -8
  37. data/lib/mongo/version.rb +1 -1
  38. data/lib/mongo/write_concern/acknowledged.rb +1 -1
  39. data/lib/mongo/write_concern/unacknowledged.rb +1 -1
  40. data/spec/certificates/ca.pem +17 -0
  41. data/spec/certificates/client.pem +101 -0
  42. data/spec/certificates/crl.pem +10 -0
  43. data/spec/certificates/crl_client_revoked.pem +12 -0
  44. data/spec/certificates/password_protected.pem +51 -0
  45. data/spec/certificates/server.pem +34 -0
  46. data/spec/mongo/collection/view/writable_spec.rb +175 -0
  47. data/spec/mongo/crud_spec.rb +42 -0
  48. data/spec/mongo/grid/file/metadata_spec.rb +23 -0
  49. data/spec/mongo/grid/file_spec.rb +34 -0
  50. data/spec/mongo/operation/write/delete_spec.rb +8 -0
  51. data/spec/mongo/operation/write/insert_spec.rb +21 -8
  52. data/spec/mongo/operation/write/update_spec.rb +52 -1
  53. data/spec/mongo/server/connection_spec.rb +33 -10
  54. data/spec/mongo/server/monitor_spec.rb +14 -0
  55. data/spec/spec_helper.rb +2 -17
  56. data/spec/support/crud.rb +203 -0
  57. data/spec/support/crud/read.rb +144 -0
  58. data/spec/support/crud/write.rb +214 -0
  59. data/spec/support/crud_tests/read/aggregate.yml +43 -0
  60. data/spec/support/crud_tests/read/count.yml +37 -0
  61. data/spec/support/crud_tests/read/distinct.yml +33 -0
  62. data/spec/support/crud_tests/read/find.yml +50 -0
  63. data/spec/support/crud_tests/write/deleteMany.yml +36 -0
  64. data/spec/support/crud_tests/write/deleteOne.yml +49 -0
  65. data/spec/support/crud_tests/write/findOneAndDelete.yml +54 -0
  66. data/spec/support/crud_tests/write/findOneAndReplace.yml +153 -0
  67. data/spec/support/crud_tests/write/findOneAndUpdate.yml +161 -0
  68. data/spec/support/crud_tests/write/insertMany.yml +24 -0
  69. data/spec/support/crud_tests/write/insertOne.yml +19 -0
  70. data/spec/support/crud_tests/write/replaceOne.yml +96 -0
  71. data/spec/support/crud_tests/write/updateMany.yml +83 -0
  72. data/spec/support/crud_tests/write/updateOne.yml +80 -0
  73. metadata +64 -20
  74. metadata.gz.sig +0 -0
  75. data/spec/mongo_orchestration_spec.rb +0 -70
  76. data/spec/support/mongo_orchestration.rb +0 -61
  77. data/spec/support/mongo_orchestration/requestable.rb +0 -109
  78. data/spec/support/mongo_orchestration/standalone.rb +0 -57
@@ -0,0 +1,54 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 22}
4
+ - {_id: 3, x: 33}
5
+
6
+ tests:
7
+ -
8
+ description: "FindOneAndDelete when many documents match"
9
+ operation:
10
+ name: findOneAndDelete
11
+ arguments:
12
+ filter:
13
+ _id: {$gt: 1}
14
+ projection: {x: 1, _id: 0}
15
+ sort: {x: 1}
16
+
17
+ outcome:
18
+ result: {x: 22}
19
+ collection:
20
+ data:
21
+ - {_id: 1, x: 11}
22
+ - {_id: 3, x: 33}
23
+ -
24
+ description: "FindOneAndDelete when one document matches"
25
+ operation:
26
+ name: findOneAndDelete
27
+ arguments:
28
+ filter: {_id: 2}
29
+ projection: {x: 1, _id: 0}
30
+ sort: {x: 1}
31
+
32
+ outcome:
33
+ result: {x: 22}
34
+ collection:
35
+ data:
36
+ - {_id: 1, x: 11}
37
+ - {_id: 3, x: 33}
38
+ -
39
+ description: "FindOneAndDelete when no documents match"
40
+ operation:
41
+ name: findOneAndDelete
42
+ arguments:
43
+ filter: {_id: 4}
44
+ projection: {x: 1, _id: 0}
45
+ sort: {x: 1}
46
+
47
+ outcome:
48
+ result: null
49
+ collection:
50
+ data:
51
+ - {_id: 1, x: 11}
52
+ - {_id: 2, x: 22}
53
+ - {_id: 3, x: 33}
54
+
@@ -0,0 +1,153 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 22}
4
+ - {_id: 3, x: 33}
5
+
6
+ tests:
7
+ -
8
+ description: "FindOneAndReplace when many documents match returning the document before modification"
9
+ operation:
10
+ name: findOneAndReplace
11
+ arguments:
12
+ filter:
13
+ _id: {$gt: 1}
14
+ replacement: {x: 32}
15
+ projection: {x: 1, _id: 0}
16
+ sort: {x: 1}
17
+
18
+ outcome:
19
+ result: {x: 22}
20
+ collection:
21
+ data:
22
+ - {_id: 1, x: 11}
23
+ - {_id: 2, x: 32}
24
+ - {_id: 3, x: 33}
25
+ -
26
+ description: "FindOneAndReplace when many documents match returning the document after modification"
27
+ operation:
28
+ name: findOneAndReplace
29
+ arguments:
30
+ filter:
31
+ _id: {$gt: 1}
32
+ replacement: {x: 32}
33
+ projection: {x: 1, _id: 0}
34
+ returnDocument: After
35
+ sort: {x: 1}
36
+
37
+ outcome:
38
+ result: {x: 32}
39
+ collection:
40
+ data:
41
+ - {_id: 1, x: 11}
42
+ - {_id: 2, x: 32}
43
+ - {_id: 3, x: 33}
44
+ -
45
+ description: "FindOneAndReplace when one document matches returning the document before modification"
46
+ operation:
47
+ name: findOneAndReplace
48
+ arguments:
49
+ filter: {_id: 2}
50
+ replacement: {x: 32}
51
+ projection: {x: 1, _id: 0}
52
+ sort: {x: 1}
53
+
54
+ outcome:
55
+ result: {x: 22}
56
+ collection:
57
+ data:
58
+ - {_id: 1, x: 11}
59
+ - {_id: 2, x: 32}
60
+ - {_id: 3, x: 33}
61
+ -
62
+ description: "FindOneAndReplace when one document matches returning the document after modification"
63
+ operation:
64
+ name: findOneAndReplace
65
+ arguments:
66
+ filter: {_id: 2}
67
+ replacement: {x: 32}
68
+ projection: {x: 1, _id: 0}
69
+ returnDocument: After
70
+ sort: {x: 1}
71
+
72
+ outcome:
73
+ result: {x: 32}
74
+ collection:
75
+ data:
76
+ - {_id: 1, x: 11}
77
+ - {_id: 2, x: 32}
78
+ - {_id: 3, x: 33}
79
+ -
80
+ description: "FindOneAndReplace when no documents match returning the document before modification"
81
+ operation:
82
+ name: findOneAndReplace
83
+ arguments:
84
+ filter: {_id: 4}
85
+ replacement: {x: 44}
86
+ projection: {x: 1, _id: 0}
87
+ sort: {x: 1}
88
+
89
+ outcome:
90
+ result: null
91
+ collection:
92
+ data:
93
+ - {_id: 1, x: 11}
94
+ - {_id: 2, x: 22}
95
+ - {_id: 3, x: 33}
96
+ -
97
+ description: "FindOneAndReplace when no documents match with upsert returning the document before modification"
98
+ operation:
99
+ name: findOneAndReplace
100
+ arguments:
101
+ filter: {_id: 4}
102
+ replacement: {x: 44}
103
+ projection: {x: 1, _id: 0}
104
+ sort: {x: 1}
105
+ upsert: true
106
+
107
+ outcome:
108
+ result: null
109
+ collection:
110
+ data:
111
+ - {_id: 1, x: 11}
112
+ - {_id: 2, x: 22}
113
+ - {_id: 3, x: 33}
114
+ - {_id: 4, x: 44}
115
+ -
116
+ description: "FindOneAndReplace when no documents match returning the document after modification"
117
+ operation:
118
+ name: findOneAndReplace
119
+ arguments:
120
+ filter: {_id: 4}
121
+ replacement: {x: 44}
122
+ projection: {x: 1, _id: 0}
123
+ returnDocument: After
124
+ sort: {x: 1}
125
+
126
+ outcome:
127
+ result: null
128
+ collection:
129
+ data:
130
+ - {_id: 1, x: 11}
131
+ - {_id: 2, x: 22}
132
+ - {_id: 3, x: 33}
133
+ -
134
+ description: "FindOneAndReplace when no documents match with upsert returning the document after modification"
135
+ operation:
136
+ name: findOneAndReplace
137
+ arguments:
138
+ filter: {_id: 4}
139
+ replacement: {x: 44}
140
+ projection: {x: 1, _id: 0}
141
+ returnDocument: After
142
+ sort: {x: 1}
143
+ upsert: true
144
+
145
+ outcome:
146
+ result: {x: 44}
147
+ collection:
148
+ data:
149
+ - {_id: 1, x: 11}
150
+ - {_id: 2, x: 22}
151
+ - {_id: 3, x: 33}
152
+ - {_id: 4, x: 44}
153
+
@@ -0,0 +1,161 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 22}
4
+ - {_id: 3, x: 33}
5
+
6
+ tests:
7
+ -
8
+ description: "FindOneAndUpdate when many documents match returning the document before modification"
9
+ operation:
10
+ name: findOneAndUpdate
11
+ arguments:
12
+ filter:
13
+ _id: {$gt: 1}
14
+ update:
15
+ $inc: {x: 1}
16
+ projection: {x: 1, _id: 0}
17
+ sort: {x: 1}
18
+
19
+ outcome:
20
+ result: {x: 22}
21
+ collection:
22
+ data:
23
+ - {_id: 1, x: 11}
24
+ - {_id: 2, x: 23}
25
+ - {_id: 3, x: 33}
26
+ -
27
+ description: "FindOneAndUpdate when many documents match returning the document after modification"
28
+ operation:
29
+ name: findOneAndUpdate
30
+ arguments:
31
+ filter:
32
+ _id: {$gt: 1}
33
+ update:
34
+ $inc: {x: 1}
35
+ projection: {x: 1, _id: 0}
36
+ returnDocument: After
37
+ sort: {x: 1}
38
+
39
+ outcome:
40
+ result: {x: 23}
41
+ collection:
42
+ data:
43
+ - {_id: 1, x: 11}
44
+ - {_id: 2, x: 23}
45
+ - {_id: 3, x: 33}
46
+ -
47
+ description: "FindOneAndUpdate when one document matches returning the document before modification"
48
+ operation:
49
+ name: findOneAndUpdate
50
+ arguments:
51
+ filter: {_id: 2}
52
+ update:
53
+ $inc: {x: 1}
54
+ projection: {x: 1, _id: 0}
55
+ sort: {x: 1}
56
+
57
+ outcome:
58
+ result: {x: 22}
59
+ collection:
60
+ data:
61
+ - {_id: 1, x: 11}
62
+ - {_id: 2, x: 23}
63
+ - {_id: 3, x: 33}
64
+ -
65
+ description: "FindOneAndUpdate when one document matches returning the document after modification"
66
+ operation:
67
+ name: findOneAndUpdate
68
+ arguments:
69
+ filter: {_id: 2}
70
+ update:
71
+ $inc: {x: 1}
72
+ projection: {x: 1, _id: 0}
73
+ returnDocument: After
74
+ sort: {x: 1}
75
+
76
+ outcome:
77
+ result: {x: 23}
78
+ collection:
79
+ data:
80
+ - {_id: 1, x: 11}
81
+ - {_id: 2, x: 23}
82
+ - {_id: 3, x: 33}
83
+ -
84
+ description: "FindOneAndUpdate when no documents match returning the document before modification"
85
+ operation:
86
+ name: findOneAndUpdate
87
+ arguments:
88
+ filter: {_id: 4}
89
+ update:
90
+ $inc: {x: 1}
91
+ projection: {x: 1, _id: 0}
92
+ sort: {x: 1}
93
+
94
+ outcome:
95
+ result: null
96
+ collection:
97
+ data:
98
+ - {_id: 1, x: 11}
99
+ - {_id: 2, x: 22}
100
+ - {_id: 3, x: 33}
101
+ -
102
+ description: "FindOneAndUpdate when no documents match with upsert returning the document before modification"
103
+ operation:
104
+ name: findOneAndUpdate
105
+ arguments:
106
+ filter: {_id: 4}
107
+ update:
108
+ $inc: {x: 1}
109
+ projection: {x: 1, _id: 0}
110
+ sort: {x: 1}
111
+ upsert: true
112
+
113
+ outcome:
114
+ result: null
115
+ collection:
116
+ data:
117
+ - {_id: 1, x: 11}
118
+ - {_id: 2, x: 22}
119
+ - {_id: 3, x: 33}
120
+ - {_id: 4, x: 1}
121
+ -
122
+ description: "FindOneAndUpdate when no documents match returning the document after modification"
123
+ operation:
124
+ name: findOneAndUpdate
125
+ arguments:
126
+ filter: {_id: 4}
127
+ update:
128
+ $inc: {x: 1}
129
+ projection: {x: 1, _id: 0}
130
+ returnDocument: After
131
+ sort: {x: 1}
132
+
133
+ outcome:
134
+ result: null
135
+ collection:
136
+ data:
137
+ - {_id: 1, x: 11}
138
+ - {_id: 2, x: 22}
139
+ - {_id: 3, x: 33}
140
+ -
141
+ description: "FindOneAndUpdate when no documents match with upsert returning the document after modification"
142
+ operation:
143
+ name: findOneAndUpdate
144
+ arguments:
145
+ filter: {_id: 4}
146
+ update:
147
+ $inc: {x: 1}
148
+ projection: {x: 1, _id: 0}
149
+ returnDocument: After
150
+ sort: {x: 1}
151
+ upsert: true
152
+
153
+ outcome:
154
+ result: {x: 1}
155
+ collection:
156
+ data:
157
+ - {_id: 1, x: 11}
158
+ - {_id: 2, x: 22}
159
+ - {_id: 3, x: 33}
160
+ - {_id: 4, x: 1}
161
+
@@ -0,0 +1,24 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+
4
+ tests:
5
+ -
6
+ description: "InsertMany with non-existing documents"
7
+ operation:
8
+ name: "insertMany"
9
+ arguments:
10
+ documents:
11
+ - {_id: 2, x: 22}
12
+ - {_id: 3, x: 33}
13
+
14
+ outcome:
15
+ result:
16
+ insertedIds:
17
+ - 2
18
+ - 3
19
+ collection:
20
+ data:
21
+ - {_id: 1, x: 11}
22
+ - {_id: 2, x: 22}
23
+ - {_id: 3, x: 33}
24
+
@@ -0,0 +1,19 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+
4
+ tests:
5
+ -
6
+ description: "InsertOne with a non-existing document"
7
+ operation:
8
+ name: "insertOne"
9
+ arguments:
10
+ document: {_id: 2, x: 22}
11
+
12
+ outcome:
13
+ result:
14
+ insertedId: 2
15
+ collection:
16
+ data:
17
+ - {_id: 1, x: 11}
18
+ - {_id: 2, x: 22}
19
+
@@ -0,0 +1,96 @@
1
+ data:
2
+ - {_id: 1, x: 11}
3
+ - {_id: 2, x: 22}
4
+ - {_id: 3, x: 33}
5
+
6
+ tests:
7
+ -
8
+ description: "ReplaceOne when many documents match"
9
+ operation:
10
+ name: "replaceOne"
11
+ arguments:
12
+ filter:
13
+ _id: {$gt: 1}
14
+ replacement: {x: 111}
15
+
16
+ outcome:
17
+ result:
18
+ matchedCount: 1
19
+ modifiedCount: 1
20
+ # can't verify collection because we don't have a way
21
+ # of knowing which document gets updated.
22
+ -
23
+ description: "ReplaceOne when one document matches"
24
+ operation:
25
+ name: "replaceOne"
26
+ arguments:
27
+ filter: {_id: 1}
28
+ replacement: {_id: 1, x: 111}
29
+
30
+ outcome:
31
+ result:
32
+ matchedCount: 1
33
+ modifiedCount: 1
34
+ collection:
35
+ data:
36
+ - {_id: 1, x: 111}
37
+ - {_id: 2, x: 22}
38
+ - {_id: 3, x: 33}
39
+ -
40
+ description: "ReplaceOne when no documents match"
41
+ operation:
42
+ name: "replaceOne"
43
+ arguments:
44
+ filter: {_id: 4}
45
+ replacement: {_id: 4, x: 1}
46
+
47
+ outcome:
48
+ result:
49
+ matchedCount: 0
50
+ modifiedCount: 0
51
+ collection:
52
+ data:
53
+ - {_id: 1, x: 11}
54
+ - {_id: 2, x: 22}
55
+ - {_id: 3, x: 33}
56
+ -
57
+ description: "ReplaceOne with upsert when no documents match without an id specified"
58
+ operation:
59
+ name: "replaceOne"
60
+ arguments:
61
+ filter: {_id: 4}
62
+ replacement: {x: 1}
63
+ upsert: true
64
+
65
+ outcome:
66
+ result:
67
+ matchedCount: 0
68
+ modifiedCount: 0
69
+ upsertedId: 4
70
+ collection:
71
+ data:
72
+ - {_id: 1, x: 11}
73
+ - {_id: 2, x: 22}
74
+ - {_id: 3, x: 33}
75
+ - {_id: 4, x: 1}
76
+ -
77
+ description: "ReplaceOne with upsert when no documents match with an id specified"
78
+ operation:
79
+ name: "replaceOne"
80
+ arguments:
81
+ filter: {_id: 4}
82
+ replacement: {_id: 4, x: 1}
83
+ upsert: true
84
+
85
+ outcome:
86
+ result:
87
+ matchedCount: 0
88
+ modifiedCount: 0
89
+ upsertedId: 4
90
+ collection:
91
+ data:
92
+ - {_id: 1, x: 11}
93
+ - {_id: 2, x: 22}
94
+ - {_id: 3, x: 33}
95
+ - {_id: 4, x: 1}
96
+