diff options
author | Alexander Ignatyev <alexander.ignatyev@mongodb.com> | 2023-03-14 16:57:39 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-03-14 21:17:16 +0000 |
commit | 9fc98cca286730529bb7f0c223569c3175b85a88 (patch) | |
tree | 73273095aa1663ee5a569755a51944604e0b3370 /jstests/core | |
parent | 90928148af6c132109cc7e54ee1cfc48c61b51b5 (diff) | |
download | mongo-9fc98cca286730529bb7f0c223569c3175b85a88.tar.gz |
SERVER-74496 Suppoprt nested documents in Wildcard Projections and fix _id processing
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/compound_wildcard_index_validation.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/jstests/core/compound_wildcard_index_validation.js b/jstests/core/compound_wildcard_index_validation.js index 80b5476b441..e10b0d88836 100644 --- a/jstests/core/compound_wildcard_index_validation.js +++ b/jstests/core/compound_wildcard_index_validation.js @@ -28,6 +28,17 @@ assert.commandWorked(coll.createIndex({"$**": 1, a: 1}, {"wildcardProjection": { assert.commandWorked( coll.createIndex({a: 1, "$**": -1, b: 1}, {"wildcardProjection": {a: 0, b: 0}})); +// Tests that _id can be excluded in an inclusion projection statement. +assert.commandWorked( + coll.createIndex({"$**": 1, "other": 1}, {"wildcardProjection": {"_id": 0, "a": 1}})); +// Tests that _id can be inccluded in an exclusion projection statement. +assert.commandWorked(coll.createIndex({"$**": 1, "another": 1}, + {"wildcardProjection": {"_id": 1, "a": 0, "another": 0}})); + +// Tests we wildcard projections allow nested objects. +assert.commandWorked( + coll.createIndex({"$**": 1, "d": 1}, {"wildcardProjection": {"a": {"b": 1, "c": 1}}})); + // // Invalid CWI specification. // @@ -55,6 +66,10 @@ assert.commandFailedWithCode(coll.createIndex({"a.$**": 1, b: 1}, {expireAfterSe // 'wildcardProjection' is not specified. assert.commandFailedWithCode(coll.createIndex({a: 1, "$**": 1}), 67); +// Tests that wildcard projections accept only numeric values. +assert.commandFailedWithCode( + coll.createIndex({"st": 1, "$**": 1}, {wildcardProjection: {"a": "something"}}), 51271); + // Tests that all compound wildcard indexes in the catalog can be validated by running validate() // command. |