mongo 2.16.4 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/lib/mongo/auth/aws/request.rb +0 -1
  5. data/lib/mongo/client.rb +4 -0
  6. data/lib/mongo/collection/view/aggregation.rb +62 -17
  7. data/lib/mongo/collection/view/builder/aggregation.rb +11 -13
  8. data/lib/mongo/collection/view/builder/map_reduce.rb +5 -8
  9. data/lib/mongo/collection/view/change_stream.rb +7 -3
  10. data/lib/mongo/collection/view/iterable.rb +3 -20
  11. data/lib/mongo/collection/view/map_reduce.rb +3 -14
  12. data/lib/mongo/collection/view/readable.rb +24 -1
  13. data/lib/mongo/collection/view/writable.rb +23 -0
  14. data/lib/mongo/collection/view.rb +0 -1
  15. data/lib/mongo/collection.rb +21 -1
  16. data/lib/mongo/database/view.rb +4 -2
  17. data/lib/mongo/database.rb +6 -6
  18. data/lib/mongo/error/snapshot_session_invalid_server_version.rb +31 -0
  19. data/lib/mongo/error/snapshot_session_transaction_prohibited.rb +30 -0
  20. data/lib/mongo/error.rb +2 -0
  21. data/lib/mongo/operation/delete/op_msg.rb +2 -1
  22. data/lib/mongo/operation/find/builder/command.rb +1 -0
  23. data/lib/mongo/operation/result.rb +6 -0
  24. data/lib/mongo/operation/shared/executable.rb +4 -0
  25. data/lib/mongo/operation/shared/sessions_supported.rb +18 -2
  26. data/lib/mongo/operation/update/op_msg.rb +2 -1
  27. data/lib/mongo/query_cache.rb +2 -12
  28. data/lib/mongo/server/description/features.rb +3 -1
  29. data/lib/mongo/server/monitor/connection.rb +4 -10
  30. data/lib/mongo/server_selector/base.rb +26 -4
  31. data/lib/mongo/session.rb +19 -0
  32. data/lib/mongo/socket/ocsp_cache.rb +2 -3
  33. data/lib/mongo/socket.rb +1 -5
  34. data/lib/mongo/utils.rb +0 -6
  35. data/lib/mongo/version.rb +1 -1
  36. data/mongo.gemspec +1 -1
  37. data/spec/integration/query_cache_spec.rb +0 -159
  38. data/spec/integration/read_preference_spec.rb +16 -12
  39. data/spec/integration/sdam_events_spec.rb +0 -40
  40. data/spec/lite_spec_helper.rb +0 -7
  41. data/spec/mongo/collection/view/aggregation_spec.rb +71 -95
  42. data/spec/mongo/collection/view/change_stream_spec.rb +1 -1
  43. data/spec/mongo/collection/view/map_reduce_spec.rb +14 -17
  44. data/spec/mongo/collection/view/readable_spec.rb +0 -56
  45. data/spec/mongo/operation/read_preference_op_msg_spec.rb +24 -1
  46. data/spec/mongo/query_cache_spec.rb +0 -165
  47. data/spec/mongo/server_selector_spec.rb +136 -15
  48. data/spec/mongo/socket/ssl_spec.rb +26 -58
  49. data/spec/mongo/utils_spec.rb +0 -14
  50. data/spec/runners/auth.rb +1 -1
  51. data/spec/runners/change_streams/spec.rb +1 -1
  52. data/spec/runners/cmap.rb +1 -1
  53. data/spec/runners/command_monitoring.rb +1 -1
  54. data/spec/runners/connection_string.rb +1 -1
  55. data/spec/runners/crud/spec.rb +3 -1
  56. data/spec/runners/crud/verifier.rb +1 -2
  57. data/spec/runners/gridfs.rb +1 -1
  58. data/spec/runners/read_write_concern_document.rb +1 -1
  59. data/spec/runners/sdam.rb +1 -1
  60. data/spec/runners/server_selection.rb +1 -1
  61. data/spec/runners/server_selection_rtt.rb +1 -1
  62. data/spec/runners/unified/assertions.rb +3 -1
  63. data/spec/runners/unified/crud_operations.rb +77 -23
  64. data/spec/runners/unified/ddl_operations.rb +29 -1
  65. data/spec/runners/unified/entity_map.rb +3 -3
  66. data/spec/runners/unified/support_operations.rb +6 -1
  67. data/spec/runners/unified/test.rb +15 -3
  68. data/spec/runners/unified/test_group.rb +1 -1
  69. data/spec/shared/share/Dockerfile.erb +3 -3
  70. data/spec/shared/shlib/server.sh +1 -1
  71. data/spec/spec_tests/data/crud_unified/aggregate-let.yml +138 -0
  72. data/spec/spec_tests/data/crud_unified/aggregate-write-readPreference.yml +155 -0
  73. data/spec/spec_tests/data/crud_unified/db-aggregate-write-readPreference.yml +151 -0
  74. data/spec/spec_tests/data/crud_unified/deleteMany-let.yml +91 -0
  75. data/spec/spec_tests/data/crud_unified/deleteOne-let.yml +89 -0
  76. data/spec/spec_tests/data/crud_unified/find-let.yml +71 -0
  77. data/spec/spec_tests/data/crud_unified/findOneAndDelete-let.yml +88 -0
  78. data/spec/spec_tests/data/crud_unified/findOneAndReplace-let.yml +94 -0
  79. data/spec/spec_tests/data/crud_unified/findOneAndUpdate-let.yml +96 -0
  80. data/spec/spec_tests/data/crud_unified/updateMany-let.yml +103 -0
  81. data/spec/spec_tests/data/crud_unified/updateOne-let.yml +98 -0
  82. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +2 -2
  83. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +3 -3
  84. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest.yml +3 -3
  85. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +3 -3
  86. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +2 -2
  87. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +2 -2
  88. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Secondary.yml +4 -4
  89. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +2 -2
  90. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +4 -4
  91. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +2 -2
  92. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +2 -2
  93. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +3 -3
  94. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.yml +2 -2
  95. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml +2 -2
  96. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +2 -2
  97. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +2 -2
  98. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest.yml +3 -3
  99. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +3 -3
  100. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +2 -2
  101. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +2 -2
  102. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +2 -2
  103. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +5 -5
  104. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +3 -3
  105. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +5 -5
  106. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +3 -3
  107. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +2 -2
  108. data/spec/spec_tests/data/max_staleness/Sharded/SmallMaxStaleness.yml +2 -2
  109. data/spec/spec_tests/data/max_staleness/Single/SmallMaxStaleness.yml +1 -1
  110. data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -1
  111. data/spec/spec_tests/data/sessions_unified/snapshot-sessions-not-supported-client-error.yml +69 -0
  112. data/spec/spec_tests/data/sessions_unified/snapshot-sessions-not-supported-server-error.yml +102 -0
  113. data/spec/spec_tests/data/sessions_unified/snapshot-sessions-unsupported-ops.yml +258 -0
  114. data/spec/spec_tests/data/sessions_unified/snapshot-sessions.yml +482 -0
  115. data/spec/spec_tests/seed_list_discovery_spec.rb +1 -1
  116. data/spec/spec_tests/sessions_unified_spec.rb +13 -0
  117. data/spec/support/certificates/atlas-ocsp-ca.crt +47 -40
  118. data/spec/support/certificates/atlas-ocsp.crt +106 -101
  119. data/spec/support/utils.rb +0 -31
  120. data.tar.gz.sig +0 -0
  121. metadata +1084 -1058
  122. metadata.gz.sig +0 -0
  123. data/spec/integration/find_options_spec.rb +0 -227
@@ -0,0 +1,91 @@
1
+ description: "deleteMany-let"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ observeEvents: [ commandStartedEvent ]
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: &database0Name crud-tests
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: &collection0Name coll0
17
+
18
+ initialData: &initialData
19
+ - collectionName: *collection0Name
20
+ databaseName: *database0Name
21
+ documents:
22
+ - { _id: 1 }
23
+ - { _id: 2, name: "name" }
24
+ - { _id: 3, name: "name" }
25
+
26
+ tests:
27
+ - description: "deleteMany with let option"
28
+ runOnRequirements:
29
+ - minServerVersion: "5.0"
30
+ operations:
31
+ - name: deleteMany
32
+ object: *collection0
33
+ arguments:
34
+ filter: &filter
35
+ $expr:
36
+ $eq: [ "$name", "$$name" ]
37
+ let: &let0
38
+ name: "name"
39
+ expectResult:
40
+ deletedCount: 2
41
+ expectEvents:
42
+ - client: *client0
43
+ events:
44
+ - commandStartedEvent:
45
+ command:
46
+ delete: *collection0Name
47
+ deletes:
48
+ -
49
+ q: *filter
50
+ let: *let0
51
+ outcome:
52
+ -
53
+ collectionName: *collection0Name
54
+ databaseName: *database0Name
55
+ documents:
56
+ - { _id: 1 }
57
+
58
+ - description: "deleteMany with let option unsupported (server-side error)"
59
+ runOnRequirements:
60
+ - minServerVersion: "3.6.0"
61
+ maxServerVersion: "4.4.99"
62
+ operations:
63
+ - name: deleteMany
64
+ object: *collection0
65
+ arguments:
66
+ filter: &filter1
67
+ $expr:
68
+ $eq: [ "$name", "$$name" ]
69
+ let: &let1
70
+ name: "name"
71
+ expectError:
72
+ errorContains: "'delete.let' is an unknown field"
73
+ isClientError: false
74
+ expectEvents:
75
+ - client: *client0
76
+ events:
77
+ - commandStartedEvent:
78
+ command:
79
+ delete: *collection0Name
80
+ deletes:
81
+ -
82
+ q: *filter1
83
+ let: *let1
84
+ outcome:
85
+ -
86
+ collectionName: *collection0Name
87
+ databaseName: *database0Name
88
+ documents:
89
+ - { _id: 1 }
90
+ - { _id: 2, name: "name" }
91
+ - { _id: 3, name: "name" }
@@ -0,0 +1,89 @@
1
+ description: "deleteOne-let"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ observeEvents: [ commandStartedEvent ]
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: &database0Name crud-tests
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: &collection0Name coll0
17
+
18
+ initialData: &initialData
19
+ - collectionName: *collection0Name
20
+ databaseName: *database0Name
21
+ documents:
22
+ - { _id: 1 }
23
+ - { _id: 2 }
24
+
25
+ tests:
26
+ - description: "deleteOne with let option"
27
+ runOnRequirements:
28
+ - minServerVersion: "5.0"
29
+ operations:
30
+ - name: deleteOne
31
+ object: *collection0
32
+ arguments:
33
+ filter: &filter
34
+ $expr:
35
+ $eq: [ "$_id", "$$id" ]
36
+ let: &let0
37
+ id: 1
38
+ expectResult:
39
+ deletedCount: 1
40
+ expectEvents:
41
+ - client: *client0
42
+ events:
43
+ - commandStartedEvent:
44
+ command:
45
+ delete: *collection0Name
46
+ deletes:
47
+ -
48
+ q: *filter
49
+ let: *let0
50
+ outcome:
51
+ -
52
+ collectionName: *collection0Name
53
+ databaseName: *database0Name
54
+ documents:
55
+ - { _id: 2 }
56
+
57
+ - description: "deleteOne with let option unsupported (server-side error)"
58
+ runOnRequirements:
59
+ - minServerVersion: "3.6.0"
60
+ maxServerVersion: "4.4.99"
61
+ operations:
62
+ - name: deleteOne
63
+ object: *collection0
64
+ arguments:
65
+ filter: &filter1
66
+ $expr:
67
+ $eq: [ "$_id", "$$id" ]
68
+ let: &let1
69
+ id: 1
70
+ expectError:
71
+ errorContains: "'delete.let' is an unknown field"
72
+ isClientError: false
73
+ expectEvents:
74
+ - client: *client0
75
+ events:
76
+ - commandStartedEvent:
77
+ command:
78
+ delete: *collection0Name
79
+ deletes:
80
+ -
81
+ q: *filter1
82
+ let: *let1
83
+ outcome:
84
+ -
85
+ collectionName: *collection0Name
86
+ databaseName: *database0Name
87
+ documents:
88
+ - { _id: 1 }
89
+ - { _id: 2 }
@@ -0,0 +1,71 @@
1
+ description: "find-let"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ observeEvents: [ commandStartedEvent ]
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: &database0Name crud-tests
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: &collection0Name coll0
17
+
18
+ initialData: &initialData
19
+ - collectionName: *collection0Name
20
+ databaseName: *database0Name
21
+ documents:
22
+ - { _id: 1 }
23
+ - { _id: 2 }
24
+
25
+ tests:
26
+ - description: "Find with let option"
27
+ runOnRequirements:
28
+ - minServerVersion: "5.0"
29
+ operations:
30
+ - name: find
31
+ object: *collection0
32
+ arguments:
33
+ filter: &filter
34
+ $expr:
35
+ $eq: [ "$_id", "$$id" ]
36
+ let: &let0
37
+ id: 1
38
+ expectResult:
39
+ - { _id: 1 }
40
+ expectEvents:
41
+ - client: *client0
42
+ events:
43
+ - commandStartedEvent:
44
+ command:
45
+ find: *collection0Name
46
+ filter: *filter
47
+ let: *let0
48
+
49
+ - description: "Find with let option unsupported (server-side error)"
50
+ runOnRequirements:
51
+ - minServerVersion: "3.6.0"
52
+ maxServerVersion: "4.4.99"
53
+ operations:
54
+ - name: find
55
+ object: *collection0
56
+ arguments:
57
+ filter: &filter1
58
+ _id: 1
59
+ let: &let1
60
+ x: 1
61
+ expectError:
62
+ errorContains: "Unrecognized field 'let'"
63
+ isClientError: false
64
+ expectEvents:
65
+ - client: *client0
66
+ events:
67
+ - commandStartedEvent:
68
+ command:
69
+ find: *collection0Name
70
+ filter: *filter1
71
+ let: *let1
@@ -0,0 +1,88 @@
1
+ description: "findOneAndDelete-let"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ observeEvents: [ commandStartedEvent ]
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: &database0Name crud-tests
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: &collection0Name coll0
17
+
18
+ initialData: &initialData
19
+ - collectionName: *collection0Name
20
+ databaseName: *database0Name
21
+ documents:
22
+ - { _id: 1 }
23
+ - { _id: 2 }
24
+
25
+ tests:
26
+ - description: "findOneAndDelete with let option"
27
+ runOnRequirements:
28
+ - minServerVersion: "5.0"
29
+ operations:
30
+ - name: findOneAndDelete
31
+ object: *collection0
32
+ arguments:
33
+ filter: &filter
34
+ $expr:
35
+ $eq: [ "$_id", "$$id" ]
36
+ let: &let0
37
+ id: 1
38
+ expectEvents:
39
+ - client: *client0
40
+ events:
41
+ - commandStartedEvent:
42
+ command:
43
+ findAndModify: *collection0Name
44
+ query: *filter
45
+ remove: true
46
+ let: *let0
47
+ outcome:
48
+ -
49
+ collectionName: *collection0Name
50
+ databaseName: *database0Name
51
+ documents:
52
+ - { _id: 2 }
53
+
54
+ - description: "findOneAndDelete with let option unsupported (server-side error)"
55
+ runOnRequirements:
56
+ - minServerVersion: "4.2.0"
57
+ maxServerVersion: "4.4.99"
58
+ operations:
59
+ - name: findOneAndDelete
60
+ object: *collection0
61
+ arguments:
62
+ filter: &filter1
63
+ $expr:
64
+ $eq: [ "$_id", "$$id" ]
65
+ let: &let1
66
+ id: 1
67
+ expectError:
68
+ # This error message is consistent between 4.2.x and 4.4.x servers.
69
+ # Older servers return a different error message.
70
+ errorContains: "field 'let' is an unknown field"
71
+ isClientError: false
72
+ expectEvents:
73
+ - client: *client0
74
+ events:
75
+ - commandStartedEvent:
76
+ command:
77
+ findAndModify: *collection0Name
78
+ query: *filter1
79
+ remove: true
80
+ let: *let1
81
+ outcome:
82
+ -
83
+ collectionName: *collection0Name
84
+ databaseName: *database0Name
85
+ documents:
86
+ - { _id: 1 }
87
+ - { _id: 2 }
88
+
@@ -0,0 +1,94 @@
1
+ description: "findOneAndReplace-let"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ observeEvents: [ commandStartedEvent ]
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: &database0Name crud-tests
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: &collection0Name coll0
17
+
18
+ initialData: &initialData
19
+ - collectionName: *collection0Name
20
+ databaseName: *database0Name
21
+ documents:
22
+ - { _id: 1 }
23
+ - { _id: 2 }
24
+
25
+ tests:
26
+ - description: "findOneAndReplace with let option"
27
+ runOnRequirements:
28
+ - minServerVersion: "5.0"
29
+ operations:
30
+ - name: findOneAndReplace
31
+ object: *collection0
32
+ arguments:
33
+ filter: &filter
34
+ $expr:
35
+ $eq: [ "$_id", "$$id" ]
36
+ replacement: &replacement
37
+ x: "x"
38
+ let: &let0
39
+ id: 1
40
+ expectResult:
41
+ _id: 1
42
+ expectEvents:
43
+ - client: *client0
44
+ events:
45
+ - commandStartedEvent:
46
+ command:
47
+ findAndModify: *collection0Name
48
+ query: *filter
49
+ update: *replacement
50
+ let: *let0
51
+ outcome:
52
+ -
53
+ collectionName: *collection0Name
54
+ databaseName: *database0Name
55
+ documents:
56
+ - { _id: 1, x: "x" }
57
+ - { _id: 2 }
58
+
59
+ - description: "findOneAndReplace with let option unsupported (server-side error)"
60
+ runOnRequirements:
61
+ - minServerVersion: "4.2.0"
62
+ maxServerVersion: "4.4.99"
63
+ operations:
64
+ - name: findOneAndReplace
65
+ object: *collection0
66
+ arguments:
67
+ filter: &filter1
68
+ $expr:
69
+ $eq: [ "$_id", "$$id" ]
70
+ replacement: &replacement1
71
+ x: "x"
72
+ let: &let1
73
+ id: 1
74
+ expectError:
75
+ # This error message is consistent between 4.2.x and 4.4.x servers.
76
+ # Older servers return a different error message.
77
+ errorContains: "field 'let' is an unknown field"
78
+ isClientError: false
79
+ expectEvents:
80
+ - client: *client0
81
+ events:
82
+ - commandStartedEvent:
83
+ command:
84
+ findAndModify: *collection0Name
85
+ query: *filter1
86
+ update: *replacement1
87
+ let: *let1
88
+ outcome:
89
+ -
90
+ collectionName: *collection0Name
91
+ databaseName: *database0Name
92
+ documents:
93
+ - { _id: 1 }
94
+ - { _id: 2 }
@@ -0,0 +1,96 @@
1
+ description: "findOneAndUpdate-let"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ observeEvents: [ commandStartedEvent ]
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: &database0Name crud-tests
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: &collection0Name coll0
17
+
18
+ initialData: &initialData
19
+ - collectionName: *collection0Name
20
+ databaseName: *database0Name
21
+ documents:
22
+ - { _id: 1 }
23
+ - { _id: 2 }
24
+
25
+ tests:
26
+ - description: "findOneAndUpdate with let option"
27
+ runOnRequirements:
28
+ - minServerVersion: "5.0"
29
+ operations:
30
+ - name: findOneAndUpdate
31
+ object: *collection0
32
+ arguments:
33
+ filter: &filter
34
+ $expr:
35
+ $eq: [ "$_id", "$$id" ]
36
+ update: &update
37
+ - $set: {x: "$$x" }
38
+ let: &let0
39
+ id: 1
40
+ x: "foo"
41
+ expectResult:
42
+ _id: 1
43
+ expectEvents:
44
+ - client: *client0
45
+ events:
46
+ - commandStartedEvent:
47
+ command:
48
+ findAndModify: *collection0Name
49
+ query: *filter
50
+ update: *update
51
+ let: *let0
52
+ outcome:
53
+ -
54
+ collectionName: *collection0Name
55
+ databaseName: *database0Name
56
+ documents:
57
+ - { _id: 1, x: "foo" }
58
+ - { _id: 2 }
59
+
60
+ - description: "findOneAndUpdate with let option unsupported (server-side error)"
61
+ runOnRequirements:
62
+ - minServerVersion: "4.2.0"
63
+ maxServerVersion: "4.4.99"
64
+ operations:
65
+ - name: findOneAndUpdate
66
+ object: *collection0
67
+ arguments:
68
+ filter: &filter1
69
+ $expr:
70
+ $eq: [ "$_id", "$$id" ]
71
+ update: &update1
72
+ - $set: {x: "$$x"}
73
+ let: &let1
74
+ id: 1
75
+ x: "foo"
76
+ expectError:
77
+ # This error message is consistent between 4.2.x and 4.4.x servers.
78
+ # Older servers return a different error message.
79
+ errorContains: "field 'let' is an unknown field"
80
+ isClientError: false
81
+ expectEvents:
82
+ - client: *client0
83
+ events:
84
+ - commandStartedEvent:
85
+ command:
86
+ findAndModify: *collection0Name
87
+ query: *filter1
88
+ update: *update1
89
+ let: *let1
90
+ outcome:
91
+ -
92
+ collectionName: *collection0Name
93
+ databaseName: *database0Name
94
+ documents:
95
+ - { _id: 1 }
96
+ - { _id: 2 }
@@ -0,0 +1,103 @@
1
+ description: "updateMany-let"
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ createEntities:
6
+ - client:
7
+ id: &client0 client0
8
+ observeEvents: [ commandStartedEvent ]
9
+ - database:
10
+ id: &database0 database0
11
+ client: *client0
12
+ databaseName: &database0Name crud-tests
13
+ - collection:
14
+ id: &collection0 collection0
15
+ database: *database0
16
+ collectionName: &collection0Name coll0
17
+
18
+ initialData: &initialData
19
+ - collectionName: *collection0Name
20
+ databaseName: *database0Name
21
+ documents:
22
+ - { _id: 1 }
23
+ - { _id: 2, name: "name" }
24
+ - { _id: 3, name: "name" }
25
+
26
+
27
+ tests:
28
+ - description: "updateMany with let option"
29
+ runOnRequirements:
30
+ - minServerVersion: "5.0"
31
+ operations:
32
+ - name: updateMany
33
+ object: *collection0
34
+ arguments:
35
+ filter: &filter
36
+ $expr:
37
+ $eq: [ "$name", "$$name" ]
38
+ update: &update
39
+ - $set: {x: "$$x", y: "$$y" }
40
+ let: &let0
41
+ name: name
42
+ x: foo
43
+ y: { $literal: "bar" }
44
+ expectResult:
45
+ matchedCount: 2
46
+ modifiedCount: 2
47
+ upsertedCount: 0
48
+ expectEvents:
49
+ - client: *client0
50
+ events:
51
+ - commandStartedEvent:
52
+ command:
53
+ update: *collection0Name
54
+ updates:
55
+ -
56
+ q: *filter
57
+ u: *update
58
+ let: *let0
59
+ outcome:
60
+ -
61
+ collectionName: *collection0Name
62
+ databaseName: *database0Name
63
+ documents:
64
+ - { _id: 1 }
65
+ - { _id: 2, name: "name", x: "foo", y: "bar" }
66
+ - { _id: 3, name: "name", x: "foo", y: "bar" }
67
+
68
+ - description: "updateMany with let option unsupported (server-side error)"
69
+ runOnRequirements:
70
+ - minServerVersion: "3.6.0"
71
+ maxServerVersion: "4.4.99"
72
+ operations:
73
+ - name: updateMany
74
+ object: *collection0
75
+ arguments:
76
+ filter: &filter1
77
+ _id: 1
78
+ update: &update1
79
+ - $set: {x: "$$x"}
80
+ let: &let1
81
+ x: foo
82
+ expectError:
83
+ errorContains: "'update.let' is an unknown field"
84
+ isClientError: false
85
+ expectEvents:
86
+ - client: *client0
87
+ events:
88
+ - commandStartedEvent:
89
+ command:
90
+ update: *collection0Name
91
+ updates:
92
+ -
93
+ q: *filter1
94
+ u: *update1
95
+ let: *let1
96
+ outcome:
97
+ -
98
+ collectionName: *collection0Name
99
+ databaseName: *database0Name
100
+ documents:
101
+ - { _id: 1 }
102
+ - { _id: 2, name: "name" }
103
+ - { _id: 3, name: "name" }