summaryrefslogtreecommitdiff
path: root/jstests/core/find_and_modify_server6865.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/find_and_modify_server6865.js')
-rw-r--r--jstests/core/find_and_modify_server6865.js286
1 files changed, 140 insertions, 146 deletions
diff --git a/jstests/core/find_and_modify_server6865.js b/jstests/core/find_and_modify_server6865.js
index b38c0b1bee4..3583da42412 100644
--- a/jstests/core/find_and_modify_server6865.js
+++ b/jstests/core/find_and_modify_server6865.js
@@ -69,66 +69,60 @@
{_id: 42, c: 4});
// Simple query that uses $elemMatch in the projection.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
- },
- {query: {_id: 42}, fields: {b: {$elemMatch: {value: 2}}}, remove: true},
- {_id: 42, b: [{name: 'second', value: 2}]});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
+ },
+ {query: {_id: 42}, fields: {b: {$elemMatch: {value: 2}}}, remove: true},
+ {_id: 42, b: [{name: 'second', value: 2}]});
// Query on an array of values while using a positional projection.
- testFAMWorked({_id: 42, a: [1, 2]},
- {query: {a: 2}, fields: {'a.$': 1}, remove: true},
- {_id: 42, a: [2]});
+ testFAMWorked(
+ {_id: 42, a: [1, 2]}, {query: {a: 2}, fields: {'a.$': 1}, remove: true}, {_id: 42, a: [2]});
// Query on an array of objects while using a positional projection.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
- },
- {query: {_id: 42, 'b.name': 'third'}, fields: {'b.$': 1}, remove: true},
- {_id: 42, b: [{name: 'third', value: 3}]});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
+ },
+ {query: {_id: 42, 'b.name': 'third'}, fields: {'b.$': 1}, remove: true},
+ {_id: 42, b: [{name: 'third', value: 3}]});
// Query on an array of objects while using a position projection.
// Verifies that the projection {'b.$.value': 1} is treated the
// same as {'b.$': 1}.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
- },
- {query: {_id: 42, 'b.name': 'third'}, fields: {'b.$.value': 1}, remove: true},
- {_id: 42, b: [{name: 'third', value: 3}]});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
+ },
+ {query: {_id: 42, 'b.name': 'third'}, fields: {'b.$.value': 1}, remove: true},
+ {_id: 42, b: [{name: 'third', value: 3}]});
// Query on an array of objects using $elemMatch while using an inclusion projection.
- testFAMWorked(
- {
- _id: 42,
- a: 5,
- b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
- },
- {
- query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
- fields: {_id: 0, a: 5},
- remove: true
- },
- {a: 5});
+ testFAMWorked({
+ _id: 42,
+ a: 5,
+ b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
+ },
+ {
+ query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
+ fields: {_id: 0, a: 5},
+ remove: true
+ },
+ {a: 5});
// Query on an array of objects using $elemMatch while using the positional
// operator in the projection.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
- },
- {
- query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
- fields: {_id: 0, 'b.$': 1},
- remove: true
- },
- {b: [{name: 'john', value: 1}]});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
+ },
+ {
+ query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
+ fields: {_id: 0, 'b.$': 1},
+ remove: true
+ },
+ {b: [{name: 'john', value: 1}]});
//
// Update operations with new=false
@@ -145,17 +139,17 @@
{_id: 42, c: 4});
// Simple query that uses $elemMatch in the projection.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
- },
- {
- query: {_id: 42},
- fields: {b: {$elemMatch: {value: 2}}},
- update: {$set: {name: '2nd'}}, new: false
- },
- {_id: 42, b: [{name: 'second', value: 2}]});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
+ },
+ {
+ query: {_id: 42},
+ fields: {b: {$elemMatch: {value: 2}}},
+ update: {$set: {name: '2nd'}},
+ new: false
+ },
+ {_id: 42, b: [{name: 'second', value: 2}]});
// Query on an array of values while using a positional projection.
testFAMWorked(
@@ -164,17 +158,17 @@
{_id: 42, a: [2]});
// Query on an array of objects while using a positional projection.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
- },
- {
- query: {_id: 42, 'b.name': 'third'},
- fields: {'b.$': 1},
- update: {$set: {'b.$.kind': 'xyz'}}, new: false
- },
- {_id: 42, b: [{name: 'third', value: 3}]});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
+ },
+ {
+ query: {_id: 42, 'b.name': 'third'},
+ fields: {'b.$': 1},
+ update: {$set: {'b.$.kind': 'xyz'}},
+ new: false
+ },
+ {_id: 42, b: [{name: 'third', value: 3}]});
// Query on an array of objects while using $elemMatch in the projection,
// where the matched array element is modified.
@@ -184,32 +178,32 @@
{_id: 1, a: [{x: 1, y: 1}]});
// Query on an array of objects using $elemMatch while using an inclusion projection.
- testFAMWorked(
- {
- _id: 42,
- a: 5,
- b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
- },
- {
- query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
- fields: {_id: 0, a: 5},
- update: {$inc: {a: 6}}, new: false
- },
- {a: 5});
+ testFAMWorked({
+ _id: 42,
+ a: 5,
+ b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
+ },
+ {
+ query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
+ fields: {_id: 0, a: 5},
+ update: {$inc: {a: 6}},
+ new: false
+ },
+ {a: 5});
// Query on an array of objects using $elemMatch while using the positional
// operator in the projection.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
- },
- {
- query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
- fields: {_id: 0, 'b.$': 1},
- update: {$set: {name: 'james'}}, new: false
- },
- {b: [{name: 'john', value: 1}]});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
+ },
+ {
+ query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
+ fields: {_id: 0, 'b.$': 1},
+ update: {$set: {name: 'james'}},
+ new: false
+ },
+ {b: [{name: 'john', value: 1}]});
//
// Update operations with new=true
@@ -226,17 +220,17 @@
{_id: 42, c: 5});
// Simple query that uses $elemMatch in the projection.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
- },
- {
- query: {_id: 42},
- fields: {b: {$elemMatch: {value: 2}}},
- update: {$set: {'b.1.name': '2nd'}}, new: true
- },
- {_id: 42, b: [{name: '2nd', value: 2}]});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
+ },
+ {
+ query: {_id: 42},
+ fields: {b: {$elemMatch: {value: 2}}},
+ update: {$set: {'b.1.name': '2nd'}},
+ new: true
+ },
+ {_id: 42, b: [{name: '2nd', value: 2}]});
// Query on an array of values while using a positional projection.
testFAMFailed(
@@ -244,29 +238,29 @@
{query: {a: 2}, fields: {'a.$': 1}, update: {$set: {'b.kind': 'xyz'}}, new: true});
// Query on an array of objects while using a positional projection.
- testFAMFailed(
- {
- _id: 42,
- b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
- },
- {
- query: {_id: 42, 'b.name': 'third'},
- fields: {'b.$': 1},
- update: {$set: {'b.$.kind': 'xyz'}}, new: true
- });
+ testFAMFailed({
+ _id: 42,
+ b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
+ },
+ {
+ query: {_id: 42, 'b.name': 'third'},
+ fields: {'b.$': 1},
+ update: {$set: {'b.$.kind': 'xyz'}},
+ new: true
+ });
// Query on an array of objects while using $elemMatch in the projection.
- testFAMWorked(
- {
- _id: 42,
- b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
- },
- {
- query: {_id: 42},
- fields: {b: {$elemMatch: {value: 2}}, c: 1},
- update: {$set: {c: 'xyz'}}, new: true
- },
- {_id: 42, b: [{name: 'second', value: 2}], c: 'xyz'});
+ testFAMWorked({
+ _id: 42,
+ b: [{name: 'first', value: 1}, {name: 'second', value: 2}, {name: 'third', value: 3}]
+ },
+ {
+ query: {_id: 42},
+ fields: {b: {$elemMatch: {value: 2}}, c: 1},
+ update: {$set: {c: 'xyz'}},
+ new: true
+ },
+ {_id: 42, b: [{name: 'second', value: 2}], c: 'xyz'});
// Query on an array of objects while using $elemMatch in the projection,
// where the matched array element is modified.
@@ -276,30 +270,30 @@
{_id: 1, a: [{x: 1, y: 2}]});
// Query on an array of objects using $elemMatch while using an inclusion projection.
- testFAMWorked(
- {
- _id: 42,
- a: 5,
- b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
- },
- {
- query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
- fields: {_id: 0, a: 5},
- update: {$inc: {a: 6}}, new: true
- },
- {a: 11});
+ testFAMWorked({
+ _id: 42,
+ a: 5,
+ b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
+ },
+ {
+ query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
+ fields: {_id: 0, a: 5},
+ update: {$inc: {a: 6}},
+ new: true
+ },
+ {a: 11});
// Query on an array of objects using $elemMatch while using the positional
// operator in the projection.
- testFAMFailed(
- {
- _id: 42,
- b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
- },
- {
- query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
- fields: {_id: 0, 'b.$': 1},
- update: {$set: {name: 'james'}}, new: true
- });
+ testFAMFailed({
+ _id: 42,
+ b: [{name: 'john', value: 1}, {name: 'jess', value: 2}, {name: 'jeff', value: 3}]
+ },
+ {
+ query: {b: {$elemMatch: {name: 'john', value: {$lt: 2}}}},
+ fields: {_id: 0, 'b.$': 1},
+ update: {$set: {name: 'james'}},
+ new: true
+ });
})();