diff options
author | David Percy <david.percy@mongodb.com> | 2022-07-12 20:24:57 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-17 15:37:04 +0000 |
commit | b902366ad23713ed7493e121f0218fead287bc6d (patch) | |
tree | 762de8a4a020d82ff3cf43faf7a35ba736e37a30 /jstests/query_golden | |
parent | aca57c0414496efbfaa914343e3b599366f15a14 (diff) | |
download | mongo-b902366ad23713ed7493e121f0218fead287bc6d.tar.gz |
SERVER-67415 Create golden-data JS suites
Adds two new suites: query_golden_classic and query_golden_cqf, which
use the golden-data test framework (docs/golden_data_test_framework.md).
These suites diff the expected and actual output instead of using
assert.eq and similar functions.
This change includes some refactoring of the golden-test classes to avoid
pulling the unittest library into the mongo shell.
Diffstat (limited to 'jstests/query_golden')
-rw-r--r-- | jstests/query_golden/array_index.js | 39 | ||||
-rw-r--r-- | jstests/query_golden/eq.js | 30 | ||||
-rw-r--r-- | jstests/query_golden/example.js | 16 | ||||
-rw-r--r-- | jstests/query_golden/expected_output/array_index | 70 | ||||
-rw-r--r-- | jstests/query_golden/expected_output/eq | 979 | ||||
-rw-r--r-- | jstests/query_golden/expected_output/example | 23 | ||||
-rw-r--r-- | jstests/query_golden/expected_output/null_missing | 49 | ||||
-rw-r--r-- | jstests/query_golden/libs/example_data.js | 143 | ||||
-rw-r--r-- | jstests/query_golden/null_missing.js | 45 |
9 files changed, 1394 insertions, 0 deletions
diff --git a/jstests/query_golden/array_index.js b/jstests/query_golden/array_index.js new file mode 100644 index 00000000000..18e0a5cae51 --- /dev/null +++ b/jstests/query_golden/array_index.js @@ -0,0 +1,39 @@ +/** + * Test that indexes on arrays can satisfy an $eq/$lt predicate, which matches if any + * array element matches. + * + * @tags: [ + * # Checks for 'IndexScan' node in explain. + * requires_cqf, + * ] + */ +(function() { +"use strict"; + +load("jstests/libs/optimizer_utils.js"); // For getPlanSkeleton. + +const coll = db.cqf_array_index; +coll.drop(); +assert.commandWorked(coll.insert([ + {a: [1, 2, 3, 4]}, + {a: [2, 3, 4]}, + {a: [2]}, + {a: 2}, + {a: [1, 3]}, +])); +// Generate enough documents for index to be preferable. +assert.commandWorked(coll.insert(Array.from({length: 100}, (_, i) => ({a: i + 10})))); +assert.commandWorked(coll.createIndex({a: 1})); + +function run(pipeline) { + jsTestLog(`Query: ${tojsononeline(pipeline)}`); + show(coll.aggregate(pipeline)); + const explain = coll.explain("executionStats").aggregate(pipeline); + print(`nReturned: ${explain.executionStats.nReturned}\n`); + print(`Plan skeleton: `); + printjson(getPlanSkeleton(explain)); +} + +run([{$match: {a: 2}}, {$unset: '_id'}]); +run([{$match: {a: {$lt: 2}}}, {$unset: '_id'}]); +})(); diff --git a/jstests/query_golden/eq.js b/jstests/query_golden/eq.js new file mode 100644 index 00000000000..ebc1d922e0d --- /dev/null +++ b/jstests/query_golden/eq.js @@ -0,0 +1,30 @@ +/** + * Tests $eq against a variety of BSON types and shapes. + */ + +load('jstests/query_golden/libs/example_data.js'); + +const docs = smallDocs(); + +const coll = db.query_golden_eq; +coll.drop(); + +let output = ''; + +jsTestLog('Inserting docs:'); +show(docs); +coll.insert(docs); +print(`Collection count: ${coll.count()}`); + +for (const leaf of leafs()) { + // TODO SERVER-67550 Equality to null does not match undefined, in Bonsai. + if (tojson(leaf).match(/null|undefined/)) + continue; + // TODO SERVER-67818 Bonsai NaN $eq NaN should be true. + if (tojson(leaf).match(/NaN/)) + continue; + + const query = coll.find({a: {$eq: leaf}}, {_id: 0}); + jsTestLog(`Query: ${tojsononeline(query._convertToCommand())}`); + show(query); +} diff --git a/jstests/query_golden/example.js b/jstests/query_golden/example.js new file mode 100644 index 00000000000..29ae77f34e9 --- /dev/null +++ b/jstests/query_golden/example.js @@ -0,0 +1,16 @@ +/** + * Example query-correctness test using the golden-data framework. + */ + +const coll = db.query_golden_example; +coll.drop(); + +for (let i = 0; i < 10; ++i) { + coll.insert({_id: i, a: i}); +} + +jsTestLog('Collection contents'); +show(coll.find()); + +jsTestLog('ID lookup'); +show(coll.find({_id: 5})); diff --git a/jstests/query_golden/expected_output/array_index b/jstests/query_golden/expected_output/array_index new file mode 100644 index 00000000000..c24ac01703b --- /dev/null +++ b/jstests/query_golden/expected_output/array_index @@ -0,0 +1,70 @@ + + +[jsTest] ---- +[jsTest] Query: [ { "$match" : { "a" : 2 } }, { "$unset" : "_id" } ] +[jsTest] ---- + +{ "a" : 2 } +{ "a" : [ 1, 2, 3, 4 ] } +{ "a" : [ 2 ] } +{ "a" : [ 2, 3, 4 ] } +nReturned: 4 +Plan skeleton: { + "queryPlanner" : { + "winningPlan" : { + "optimizerPlan" : { + "nodeType" : "Root", + "child" : { + "nodeType" : "Evaluation", + "child" : { + "nodeType" : "BinaryJoin", + "leftChild" : { + "nodeType" : "IndexScan" + }, + "rightChild" : { + "nodeType" : "LimitSkip", + "child" : { + "nodeType" : "Seek" + } + } + } + } + } + } + } +} + +[jsTest] ---- +[jsTest] Query: [ { "$match" : { "a" : { "$lt" : 2 } } }, { "$unset" : "_id" } ] +[jsTest] ---- + +{ "a" : [ 1, 2, 3, 4 ] } +{ "a" : [ 1, 3 ] } +nReturned: 2 +Plan skeleton: { + "queryPlanner" : { + "winningPlan" : { + "optimizerPlan" : { + "nodeType" : "Root", + "child" : { + "nodeType" : "Evaluation", + "child" : { + "nodeType" : "BinaryJoin", + "leftChild" : { + "nodeType" : "Unique", + "child" : { + "nodeType" : "IndexScan" + } + }, + "rightChild" : { + "nodeType" : "LimitSkip", + "child" : { + "nodeType" : "Seek" + } + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/jstests/query_golden/expected_output/eq b/jstests/query_golden/expected_output/eq new file mode 100644 index 00000000000..60f017eb31c --- /dev/null +++ b/jstests/query_golden/expected_output/eq @@ -0,0 +1,979 @@ + + +[jsTest] ---- +[jsTest] Inserting docs: +[jsTest] ---- + +{ "a" : "" } +{ "a" : "A" } +{ "a" : "a" } +{ "a" : "😀" } +{ "a" : -1 } +{ "a" : -1.7976931348623157e+308 } +{ "a" : -1.7976931348623157e+308 } +{ "a" : -2 } +{ "a" : -5e-324 } +{ "a" : -Infinity } +{ "a" : /(?:)/ } +{ "a" : /A/ } +{ "a" : /a/ } +{ "a" : /a/i } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 1 } +{ "a" : 2 } +{ "a" : 5e-324 } +{ "a" : BinData(0,"") } +{ "a" : BinData(0,"asdf") } +{ "a" : ISODate("0000-01-01T00:00:00Z") } +{ "a" : ISODate("1969-12-31T23:59:59.999Z") } +{ "a" : ISODate("1970-01-01T00:00:00Z") } +{ "a" : ISODate("2022-07-14T18:34:28.937Z") } +{ "a" : ISODate("9999-12-31T23:59:59.999Z") } +{ "a" : Infinity } +{ "a" : NaN } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("-1") } +{ "a" : NumberDecimal("-1.000") } +{ "a" : NumberDecimal("-1E-6176") } +{ "a" : NumberDecimal("-9.999999999999999999999999999999999E+6144") } +{ "a" : NumberDecimal("-Infinity") } +{ "a" : NumberDecimal("-Infinity") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberDecimal("1") } +{ "a" : NumberDecimal("1E-6176") } +{ "a" : NumberDecimal("9.999999999999999999999999999999999E+6144") } +{ "a" : NumberDecimal("NaN") } +{ "a" : NumberInt(-1) } +{ "a" : NumberInt(-2) } +{ "a" : NumberInt(-2147483648) } +{ "a" : NumberInt(0) } +{ "a" : NumberInt(1) } +{ "a" : NumberInt(2) } +{ "a" : NumberInt(2147483647) } +{ "a" : NumberLong("-9223372036854775808") } +{ "a" : NumberLong("9223372036854775807") } +{ "a" : NumberLong(-1) } +{ "a" : NumberLong(-2) } +{ "a" : NumberLong(0) } +{ "a" : NumberLong(1) } +{ "a" : NumberLong(2) } +{ "a" : ObjectId("000000000000000000000000") } +{ "a" : ObjectId("62d05ec744ca83616c92772c") } +{ "a" : ObjectId("62d05fa144ca83616c92772e") } +{ "a" : ObjectId("ffffffffffffffffffffffff") } +{ "a" : UUID("167c25c0-4f45-488a-960a-3171ec07726b") } +{ "a" : UUID("326d92af-2d76-452b-a03f-69f05ab98416") } +{ "a" : [ "" ] } +{ "a" : [ "A" ] } +{ "a" : [ "a" ] } +{ "a" : [ "😀" ] } +{ "a" : [ -1 ] } +{ "a" : [ -1.7976931348623157e+308 ] } +{ "a" : [ -1.7976931348623157e+308 ] } +{ "a" : [ -2 ] } +{ "a" : [ -5e-324 ] } +{ "a" : [ -Infinity ] } +{ "a" : [ /(?:)/ ] } +{ "a" : [ /A/ ] } +{ "a" : [ /a/ ] } +{ "a" : [ /a/i ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 1 ] } +{ "a" : [ 2 ] } +{ "a" : [ 5e-324 ] } +{ "a" : [ BinData(0,"") ] } +{ "a" : [ BinData(0,"asdf") ] } +{ "a" : [ ISODate("0000-01-01T00:00:00Z") ] } +{ "a" : [ ISODate("1969-12-31T23:59:59.999Z") ] } +{ "a" : [ ISODate("1970-01-01T00:00:00Z") ] } +{ "a" : [ ISODate("2022-07-14T18:34:28.937Z") ] } +{ "a" : [ ISODate("9999-12-31T23:59:59.999Z") ] } +{ "a" : [ Infinity ] } +{ "a" : [ NaN ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("-1") ] } +{ "a" : [ NumberDecimal("-1.000") ] } +{ "a" : [ NumberDecimal("-1E-6176") ] } +{ "a" : [ NumberDecimal("-9.999999999999999999999999999999999E+6144") ] } +{ "a" : [ NumberDecimal("-Infinity") ] } +{ "a" : [ NumberDecimal("-Infinity") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberDecimal("1") ] } +{ "a" : [ NumberDecimal("1E-6176") ] } +{ "a" : [ NumberDecimal("9.999999999999999999999999999999999E+6144") ] } +{ "a" : [ NumberDecimal("NaN") ] } +{ "a" : [ NumberInt(-1) ] } +{ "a" : [ NumberInt(-2) ] } +{ "a" : [ NumberInt(-2147483648) ] } +{ "a" : [ NumberInt(0) ] } +{ "a" : [ NumberInt(1) ] } +{ "a" : [ NumberInt(2) ] } +{ "a" : [ NumberInt(2147483647) ] } +{ "a" : [ NumberLong("-9223372036854775808") ] } +{ "a" : [ NumberLong("9223372036854775807") ] } +{ "a" : [ NumberLong(-1) ] } +{ "a" : [ NumberLong(-2) ] } +{ "a" : [ NumberLong(0) ] } +{ "a" : [ NumberLong(1) ] } +{ "a" : [ NumberLong(2) ] } +{ "a" : [ ObjectId("000000000000000000000000") ] } +{ "a" : [ ObjectId("62d05ec744ca83616c92772c") ] } +{ "a" : [ ObjectId("62d05fa144ca83616c92772e") ] } +{ "a" : [ ObjectId("ffffffffffffffffffffffff") ] } +{ "a" : [ UUID("167c25c0-4f45-488a-960a-3171ec07726b") ] } +{ "a" : [ UUID("326d92af-2d76-452b-a03f-69f05ab98416") ] } +{ "a" : [ [ ] ] } +{ "a" : [ ] } +{ "a" : [ false ] } +{ "a" : [ function inc(x) { + return x + 1; + } ] } +{ "a" : [ null ] } +{ "a" : [ true ] } +{ "a" : [ undefined ] } +{ "a" : [ { } ] } +{ "a" : [ { "$maxKey" : 1 } ] } +{ "a" : [ { "$minKey" : 1 } ] } +{ "a" : false } +{ "a" : function inc(x) { + return x + 1; + } } +{ "a" : null } +{ "a" : true } +{ "a" : undefined } +{ "a" : { } } +{ "a" : { "x" : "" } } +{ "a" : { "x" : "A" } } +{ "a" : { "x" : "a" } } +{ "a" : { "x" : "😀" } } +{ "a" : { "x" : -1 } } +{ "a" : { "x" : -1.7976931348623157e+308 } } +{ "a" : { "x" : -1.7976931348623157e+308 } } +{ "a" : { "x" : -2 } } +{ "a" : { "x" : -5e-324 } } +{ "a" : { "x" : -Infinity } } +{ "a" : { "x" : /(?:)/ } } +{ "a" : { "x" : /A/ } } +{ "a" : { "x" : /a/ } } +{ "a" : { "x" : /a/i } } +{ "a" : { "x" : 0 } } +{ "a" : { "x" : 0 } } +{ "a" : { "x" : 1 } } +{ "a" : { "x" : 2 } } +{ "a" : { "x" : 5e-324 } } +{ "a" : { "x" : BinData(0,"") } } +{ "a" : { "x" : BinData(0,"asdf") } } +{ "a" : { "x" : ISODate("0000-01-01T00:00:00Z") } } +{ "a" : { "x" : ISODate("1969-12-31T23:59:59.999Z") } } +{ "a" : { "x" : ISODate("1970-01-01T00:00:00Z") } } +{ "a" : { "x" : ISODate("2022-07-14T18:34:28.937Z") } } +{ "a" : { "x" : ISODate("9999-12-31T23:59:59.999Z") } } +{ "a" : { "x" : Infinity } } +{ "a" : { "x" : NaN } } +{ "a" : { "x" : NumberDecimal("-0") } } +{ "a" : { "x" : NumberDecimal("-0.000") } } +{ "a" : { "x" : NumberDecimal("-1") } } +{ "a" : { "x" : NumberDecimal("-1.000") } } +{ "a" : { "x" : NumberDecimal("-1E-6176") } } +{ "a" : { "x" : NumberDecimal("-9.999999999999999999999999999999999E+6144") } } +{ "a" : { "x" : NumberDecimal("-Infinity") } } +{ "a" : { "x" : NumberDecimal("-Infinity") } } +{ "a" : { "x" : NumberDecimal("0") } } +{ "a" : { "x" : NumberDecimal("0.000") } } +{ "a" : { "x" : NumberDecimal("1") } } +{ "a" : { "x" : NumberDecimal("1E-6176") } } +{ "a" : { "x" : NumberDecimal("9.999999999999999999999999999999999E+6144") } } +{ "a" : { "x" : NumberDecimal("NaN") } } +{ "a" : { "x" : NumberInt(-1) } } +{ "a" : { "x" : NumberInt(-2) } } +{ "a" : { "x" : NumberInt(-2147483648) } } +{ "a" : { "x" : NumberInt(0) } } +{ "a" : { "x" : NumberInt(1) } } +{ "a" : { "x" : NumberInt(2) } } +{ "a" : { "x" : NumberInt(2147483647) } } +{ "a" : { "x" : NumberLong("-9223372036854775808") } } +{ "a" : { "x" : NumberLong("9223372036854775807") } } +{ "a" : { "x" : NumberLong(-1) } } +{ "a" : { "x" : NumberLong(-2) } } +{ "a" : { "x" : NumberLong(0) } } +{ "a" : { "x" : NumberLong(1) } } +{ "a" : { "x" : NumberLong(2) } } +{ "a" : { "x" : ObjectId("000000000000000000000000") } } +{ "a" : { "x" : ObjectId("62d05ec744ca83616c92772c") } } +{ "a" : { "x" : ObjectId("62d05fa144ca83616c92772e") } } +{ "a" : { "x" : ObjectId("ffffffffffffffffffffffff") } } +{ "a" : { "x" : UUID("167c25c0-4f45-488a-960a-3171ec07726b") } } +{ "a" : { "x" : UUID("326d92af-2d76-452b-a03f-69f05ab98416") } } +{ "a" : { "x" : [ ] } } +{ "a" : { "x" : false } } +{ "a" : { "x" : function inc(x) { + return x + 1; + } } } +{ "a" : { "x" : null } } +{ "a" : { "x" : true } } +{ "a" : { "x" : undefined } } +{ "a" : { "x" : { } } } +{ "a" : { "x" : { "$maxKey" : 1 } } } +{ "a" : { "x" : { "$minKey" : 1 } } } +{ "a" : { "$maxKey" : 1 } } +{ "a" : { "$minKey" : 1 } } +Collection count: 213 + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : { "$minKey" : 1 } } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : [ { "$minKey" : 1 } ] } +{ "a" : { "$minKey" : 1 } } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : -Infinity } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -Infinity } +{ "a" : NumberDecimal("-Infinity") } +{ "a" : NumberDecimal("-Infinity") } +{ "a" : [ -Infinity ] } +{ "a" : [ NumberDecimal("-Infinity") ] } +{ "a" : [ NumberDecimal("-Infinity") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : -1.7976931348623157e+308 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -1.7976931348623157e+308 } +{ "a" : -1.7976931348623157e+308 } +{ "a" : [ -1.7976931348623157e+308 ] } +{ "a" : [ -1.7976931348623157e+308 ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : -2 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -2 } +{ "a" : -2 } +{ "a" : NumberLong(-2) } +{ "a" : [ -2 ] } +{ "a" : [ -2 ] } +{ "a" : [ NumberLong(-2) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : -1 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -1 } +{ "a" : -1 } +{ "a" : NumberDecimal("-1") } +{ "a" : NumberDecimal("-1.000") } +{ "a" : NumberLong(-1) } +{ "a" : [ -1 ] } +{ "a" : [ -1 ] } +{ "a" : [ NumberDecimal("-1") ] } +{ "a" : [ NumberDecimal("-1.000") ] } +{ "a" : [ NumberLong(-1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : -5e-324 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -5e-324 } +{ "a" : [ -5e-324 ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : 0 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberLong(0) } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberLong(0) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : 0 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberLong(0) } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberLong(0) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : 5e-324 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 5e-324 } +{ "a" : [ 5e-324 ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : 1 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 1 } +{ "a" : 1 } +{ "a" : NumberDecimal("1") } +{ "a" : NumberLong(1) } +{ "a" : [ 1 ] } +{ "a" : [ 1 ] } +{ "a" : [ NumberDecimal("1") ] } +{ "a" : [ NumberLong(1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : 2 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 2 } +{ "a" : 2 } +{ "a" : NumberLong(2) } +{ "a" : [ 2 ] } +{ "a" : [ 2 ] } +{ "a" : [ NumberLong(2) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : -1.7976931348623157e+308 } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -1.7976931348623157e+308 } +{ "a" : -1.7976931348623157e+308 } +{ "a" : [ -1.7976931348623157e+308 ] } +{ "a" : [ -1.7976931348623157e+308 ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : Infinity } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : Infinity } +{ "a" : [ Infinity ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : "" } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : "" } +{ "a" : [ "" ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : "a" } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : "a" } +{ "a" : [ "a" ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : "A" } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : "A" } +{ "a" : [ "A" ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : "😀" } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : "😀" } +{ "a" : [ "😀" ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : { } } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : [ { } ] } +{ "a" : { } } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : [ ] } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : [ [ ] ] } +{ "a" : [ ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : BinData(0,"") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : BinData(0,"") } +{ "a" : [ BinData(0,"") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : BinData(0,"asdf") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : BinData(0,"asdf") } +{ "a" : [ BinData(0,"asdf") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : UUID("326d92af-2d76-452b-a03f-69f05ab98416") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : UUID("326d92af-2d76-452b-a03f-69f05ab98416") } +{ "a" : [ UUID("326d92af-2d76-452b-a03f-69f05ab98416") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : UUID("167c25c0-4f45-488a-960a-3171ec07726b") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : UUID("167c25c0-4f45-488a-960a-3171ec07726b") } +{ "a" : [ UUID("167c25c0-4f45-488a-960a-3171ec07726b") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ObjectId("62d05ec744ca83616c92772c") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ObjectId("62d05ec744ca83616c92772c") } +{ "a" : [ ObjectId("62d05ec744ca83616c92772c") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ObjectId("62d05fa144ca83616c92772e") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ObjectId("62d05fa144ca83616c92772e") } +{ "a" : [ ObjectId("62d05fa144ca83616c92772e") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ObjectId("000000000000000000000000") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ObjectId("000000000000000000000000") } +{ "a" : [ ObjectId("000000000000000000000000") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ObjectId("ffffffffffffffffffffffff") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ObjectId("ffffffffffffffffffffffff") } +{ "a" : [ ObjectId("ffffffffffffffffffffffff") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : false } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : [ false ] } +{ "a" : false } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : true } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : [ true ] } +{ "a" : true } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ISODate("2022-07-14T18:34:28.937Z") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ISODate("2022-07-14T18:34:28.937Z") } +{ "a" : [ ISODate("2022-07-14T18:34:28.937Z") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ISODate("0000-01-01T00:00:00Z") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ISODate("0000-01-01T00:00:00Z") } +{ "a" : [ ISODate("0000-01-01T00:00:00Z") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ISODate("9999-12-31T23:59:59.999Z") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ISODate("9999-12-31T23:59:59.999Z") } +{ "a" : [ ISODate("9999-12-31T23:59:59.999Z") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ISODate("1969-12-31T23:59:59.999Z") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ISODate("1969-12-31T23:59:59.999Z") } +{ "a" : [ ISODate("1969-12-31T23:59:59.999Z") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : ISODate("1970-01-01T00:00:00Z") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : ISODate("1970-01-01T00:00:00Z") } +{ "a" : [ ISODate("1970-01-01T00:00:00Z") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : /(?:)/ } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : /(?:)/ } +{ "a" : [ /(?:)/ ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : /a/ } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : /a/ } +{ "a" : [ /a/ ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : /A/ } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : /A/ } +{ "a" : [ /A/ ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : /a/i } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : /a/i } +{ "a" : [ /a/i ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : function inc(x) { +[jsTest] return x + 1; +[jsTest] } } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : [ { "code" : "function inc(x) {\n return x + 1;\n }" } ] } +{ "a" : { "code" : "function inc(x) {\n return x + 1;\n }" } } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberInt(-2147483648) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -2147483648 } +{ "a" : [ -2147483648 ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberInt(-2) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -2 } +{ "a" : -2 } +{ "a" : NumberLong(-2) } +{ "a" : [ -2 ] } +{ "a" : [ -2 ] } +{ "a" : [ NumberLong(-2) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberInt(-1) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -1 } +{ "a" : -1 } +{ "a" : NumberDecimal("-1") } +{ "a" : NumberDecimal("-1.000") } +{ "a" : NumberLong(-1) } +{ "a" : [ -1 ] } +{ "a" : [ -1 ] } +{ "a" : [ NumberDecimal("-1") ] } +{ "a" : [ NumberDecimal("-1.000") ] } +{ "a" : [ NumberLong(-1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberInt(0) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberLong(0) } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberLong(0) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberInt(1) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 1 } +{ "a" : 1 } +{ "a" : NumberDecimal("1") } +{ "a" : NumberLong(1) } +{ "a" : [ 1 ] } +{ "a" : [ 1 ] } +{ "a" : [ NumberDecimal("1") ] } +{ "a" : [ NumberLong(1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberInt(2) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 2 } +{ "a" : 2 } +{ "a" : NumberLong(2) } +{ "a" : [ 2 ] } +{ "a" : [ 2 ] } +{ "a" : [ NumberLong(2) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberInt(2147483647) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 2147483647 } +{ "a" : [ 2147483647 ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberLong("-9223372036854775808") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : NumberLong("-9223372036854775808") } +{ "a" : [ NumberLong("-9223372036854775808") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberLong(-2) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -2 } +{ "a" : -2 } +{ "a" : NumberLong(-2) } +{ "a" : [ -2 ] } +{ "a" : [ -2 ] } +{ "a" : [ NumberLong(-2) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberLong(-1) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -1 } +{ "a" : -1 } +{ "a" : NumberDecimal("-1") } +{ "a" : NumberDecimal("-1.000") } +{ "a" : NumberLong(-1) } +{ "a" : [ -1 ] } +{ "a" : [ -1 ] } +{ "a" : [ NumberDecimal("-1") ] } +{ "a" : [ NumberDecimal("-1.000") ] } +{ "a" : [ NumberLong(-1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberLong(0) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberLong(0) } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberLong(0) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberLong(1) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 1 } +{ "a" : 1 } +{ "a" : NumberDecimal("1") } +{ "a" : NumberLong(1) } +{ "a" : [ 1 ] } +{ "a" : [ 1 ] } +{ "a" : [ NumberDecimal("1") ] } +{ "a" : [ NumberLong(1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberLong(2) } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 2 } +{ "a" : 2 } +{ "a" : NumberLong(2) } +{ "a" : [ 2 ] } +{ "a" : [ 2 ] } +{ "a" : [ NumberLong(2) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberLong("9223372036854775807") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : NumberLong("9223372036854775807") } +{ "a" : [ NumberLong("9223372036854775807") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("-Infinity") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -Infinity } +{ "a" : NumberDecimal("-Infinity") } +{ "a" : NumberDecimal("-Infinity") } +{ "a" : [ -Infinity ] } +{ "a" : [ NumberDecimal("-Infinity") ] } +{ "a" : [ NumberDecimal("-Infinity") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("-9.999999999999999999999999999999999E+6144") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : NumberDecimal("-9.999999999999999999999999999999999E+6144") } +{ "a" : [ NumberDecimal("-9.999999999999999999999999999999999E+6144") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("-1.000") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -1 } +{ "a" : -1 } +{ "a" : NumberDecimal("-1") } +{ "a" : NumberDecimal("-1.000") } +{ "a" : NumberLong(-1) } +{ "a" : [ -1 ] } +{ "a" : [ -1 ] } +{ "a" : [ NumberDecimal("-1") ] } +{ "a" : [ NumberDecimal("-1.000") ] } +{ "a" : [ NumberLong(-1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("-1") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -1 } +{ "a" : -1 } +{ "a" : NumberDecimal("-1") } +{ "a" : NumberDecimal("-1.000") } +{ "a" : NumberLong(-1) } +{ "a" : [ -1 ] } +{ "a" : [ -1 ] } +{ "a" : [ NumberDecimal("-1") ] } +{ "a" : [ NumberDecimal("-1.000") ] } +{ "a" : [ NumberLong(-1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("-1E-6176") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : NumberDecimal("-1E-6176") } +{ "a" : [ NumberDecimal("-1E-6176") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("-0.000") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberLong(0) } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberLong(0) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("-0") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberLong(0) } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberLong(0) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("0") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberLong(0) } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberLong(0) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("0.000") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 0 } +{ "a" : 0 } +{ "a" : 0 } +{ "a" : NumberDecimal("-0") } +{ "a" : NumberDecimal("-0.000") } +{ "a" : NumberDecimal("0") } +{ "a" : NumberDecimal("0.000") } +{ "a" : NumberLong(0) } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ 0 ] } +{ "a" : [ NumberDecimal("-0") ] } +{ "a" : [ NumberDecimal("-0.000") ] } +{ "a" : [ NumberDecimal("0") ] } +{ "a" : [ NumberDecimal("0.000") ] } +{ "a" : [ NumberLong(0) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("1E-6176") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : NumberDecimal("1E-6176") } +{ "a" : [ NumberDecimal("1E-6176") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("1") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : 1 } +{ "a" : 1 } +{ "a" : NumberDecimal("1") } +{ "a" : NumberLong(1) } +{ "a" : [ 1 ] } +{ "a" : [ 1 ] } +{ "a" : [ NumberDecimal("1") ] } +{ "a" : [ NumberLong(1) ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("9.999999999999999999999999999999999E+6144") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : NumberDecimal("9.999999999999999999999999999999999E+6144") } +{ "a" : [ NumberDecimal("9.999999999999999999999999999999999E+6144") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : NumberDecimal("-Infinity") } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : -Infinity } +{ "a" : NumberDecimal("-Infinity") } +{ "a" : NumberDecimal("-Infinity") } +{ "a" : [ -Infinity ] } +{ "a" : [ NumberDecimal("-Infinity") ] } +{ "a" : [ NumberDecimal("-Infinity") ] } + + +[jsTest] ---- +[jsTest] Query: { "find" : "query_golden_eq", "filter" : { "a" : { "$eq" : { "$maxKey" : 1 } } }, "projection" : { "_id" : 0 } } +[jsTest] ---- + +{ "a" : [ { "$maxKey" : 1 } ] } +{ "a" : { "$maxKey" : 1 } } diff --git a/jstests/query_golden/expected_output/example b/jstests/query_golden/expected_output/example new file mode 100644 index 00000000000..e17af8eeee9 --- /dev/null +++ b/jstests/query_golden/expected_output/example @@ -0,0 +1,23 @@ + + +[jsTest] ---- +[jsTest] Collection contents +[jsTest] ---- + +{ "_id" : 0, "a" : 0 } +{ "_id" : 1, "a" : 1 } +{ "_id" : 2, "a" : 2 } +{ "_id" : 3, "a" : 3 } +{ "_id" : 4, "a" : 4 } +{ "_id" : 5, "a" : 5 } +{ "_id" : 6, "a" : 6 } +{ "_id" : 7, "a" : 7 } +{ "_id" : 8, "a" : 8 } +{ "_id" : 9, "a" : 9 } + + +[jsTest] ---- +[jsTest] ID lookup +[jsTest] ---- + +{ "_id" : 5, "a" : 5 } diff --git a/jstests/query_golden/expected_output/null_missing b/jstests/query_golden/expected_output/null_missing new file mode 100644 index 00000000000..25885c34454 --- /dev/null +++ b/jstests/query_golden/expected_output/null_missing @@ -0,0 +1,49 @@ + + +[jsTest] ---- +[jsTest] No indexes. Query: [ { "$match" : { "a.b" : null } } ] +[jsTest] ---- + +nReturned: 3 +Plan skeleton: { + "queryPlanner" : { + "winningPlan" : { + "optimizerPlan" : { + "nodeType" : "Root", + "child" : { + "nodeType" : "Filter", + "child" : { + "nodeType" : "PhysicalScan" + } + } + } + } + } +} + +[jsTest] ---- +[jsTest] Index on { "a.b" : 1 }. Query: [ { "$match" : { "a.b" : null } } ] +[jsTest] ---- + +nReturned: 3 +Plan skeleton: { + "queryPlanner" : { + "winningPlan" : { + "optimizerPlan" : { + "nodeType" : "Root", + "child" : { + "nodeType" : "BinaryJoin", + "leftChild" : { + "nodeType" : "IndexScan" + }, + "rightChild" : { + "nodeType" : "LimitSkip", + "child" : { + "nodeType" : "Seek" + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/jstests/query_golden/libs/example_data.js b/jstests/query_golden/libs/example_data.js new file mode 100644 index 00000000000..06629907cbb --- /dev/null +++ b/jstests/query_golden/libs/example_data.js @@ -0,0 +1,143 @@ + +// Helpers for generating small but diverse data examples. + +// Generates interesting "leaf" values: values that don't contain other values. +// This includes [] and {}. +function leafs() { + // See bsontypes.h or https://bsonspec.org/ for a complete list of BSON types. + // Not every type is represented here. + return [ + MinKey, + + // 'missing', aka "$$REMOVE" is not included here. + // It's not a first-class value because it can't be an element of an array. + // Instead, we can generate objects where a given field is missing. + + // NumberDouble + NaN, + -Infinity, + -1.79769313486231570815e+308, + -2.0, + -1.0, + -5e-324, + -0.0, + 0.0, + 5e-324, + 1.0, + 2.0, + -1.79769313486231570815e+308, + +Infinity, + + // String + "", + "a", + "A", + "\u{1f600}", // A code point that doesn't fit in a 16-bit unit. (A smiley emoji.) + + // Object + {}, + + // Array + [], + + // BinData + BinData(0, ''), + BinData(0, 'asdf'), + // UUID is one subtype of BinData. + UUID("326d92af-2d76-452b-a03f-69f05ab98416"), + UUID("167c25c0-4f45-488a-960a-3171ec07726b"), + + undefined, + + // ObjectId + // See oid.h, or https://www.mongodb.com/docs/manual/reference/method/ObjectId/. + ObjectId("62d05ec744ca83616c92772c"), + ObjectId("62d05fa144ca83616c92772e"), + ObjectId('000000000000000000000000'), + ObjectId('ffffffffffffffffffffffff'), + + // Boolean + false, + true, + + // Date + ISODate("2022-07-14T18:34:28.937Z"), + ISODate("0000-01-01T00:00:00Z"), // The smallest formattable date. + ISODate("9999-12-31T23:59:59.999Z"), // The greatest formattable date. + new Date(-1), // The greatest negative date, 1ms before 1970. + new Date(0), // The zero date, at 1970. + + null, + + // RegEx + new RegExp(''), + /a/, + /A/, + /a/i, + + // Code + function inc(x) { + return x + 1; + }, + + // Symbol--deprecated and maybe not even representable in Javascript. + + // NumberInt + NumberInt('-2147483648'), + NumberInt(-2), + NumberInt(-1), + NumberInt(0), + NumberInt(1), + NumberInt(2), + NumberInt('+2147483647'), + + NumberLong('-9223372036854775808'), + NumberLong(-2), + NumberLong(-1), + NumberLong(0), + NumberLong(1), + NumberLong(2), + NumberLong('+9223372036854775807'), + + NumberDecimal('NaN'), + NumberDecimal('-Infinity'), + NumberDecimal('-9.999999999999999999999999999999999e6144'), + NumberDecimal('-1.000'), + NumberDecimal('-1'), + NumberDecimal('-1e-6176'), + NumberDecimal('-0.000'), + NumberDecimal('-0'), + NumberDecimal('0'), + NumberDecimal('0.000'), + NumberDecimal('1e-6176'), + NumberDecimal('1'), + NumberDecimal('9.999999999999999999999999999999999e6144'), + NumberDecimal('-Infinity'), + + MaxKey, + ]; +} + +// Documents with (at most) a single field with the given name. +// Includes the "missing value" by including one empty doc. +function unaryDocs(fieldname, values) { + return values.map(v => ({[fieldname]: v})); +} + +// Arrays with exactly one element. +function unaryArrays(values) { + return values.map(v => [v]); +} + +function smallDocs() { + let values = leafs(); + values = values.concat(unaryDocs('x', values)).concat(unaryArrays(values)); + return unaryDocs('a', values); +} + +// Prepend an '_id' field to each document, numbered sequentially from 0. +// Preserves any existing '_id' value, but always moves that field to the beginning. +function sequentialIds(docs) { + let i = 0; + return docs.map(d => Object.merge({_id: i++}, d)); +} diff --git a/jstests/query_golden/null_missing.js b/jstests/query_golden/null_missing.js new file mode 100644 index 00000000000..676c11e29bb --- /dev/null +++ b/jstests/query_golden/null_missing.js @@ -0,0 +1,45 @@ +/** + * Test that $eq: null predicates include both null and missing, for both a + * collection scan and index scan. + * + * @tags: [ + * # Checks for CQF-specific node names in explain output. + * requires_cqf, + * ] + */ +(function() { +"use strict"; + +load("jstests/libs/optimizer_utils.js"); // For getPlanSkeleton. + +const coll = db.cqf_null_missing; +coll.drop(); + +assert.commandWorked(coll.insert([ + {a: 2}, + {a: {b: null}}, + {a: {c: 1}}, +])); +// Generate enough documents for index to be preferable. +assert.commandWorked(coll.insert(Array.from({length: 100}, (_, i) => ({a: {b: i + 10}})))); + +{ + const pipeline = [{$match: {'a.b': null}}]; + jsTestLog(`No indexes. Query: ${tojsononeline(pipeline)}`); + const explain = coll.explain("executionStats").aggregate(pipeline); + print(`nReturned: ${explain.executionStats.nReturned}\n`); + print(`Plan skeleton: `); + printjson(getPlanSkeleton(explain)); +} + +{ + const pipeline = [{$match: {'a.b': null}}]; + const index = {'a.b': 1}; + jsTestLog(`Index on ${tojsononeline(index)}. Query: ${tojson(pipeline)}`); + assert.commandWorked(coll.createIndex(index)); + const explain = coll.explain("executionStats").aggregate([{$match: {'a.b': null}}]); + print(`nReturned: ${explain.executionStats.nReturned}\n`); + print(`Plan skeleton: `); + printjson(getPlanSkeleton(explain)); +} +})(); |