summaryrefslogtreecommitdiff
path: root/jstests/core/find_projection_meta_errors.js
blob: 6fd69cb9d04989c305a8daeea785a7e51c590f69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Basic tests for errors when parsing the $meta projection.

(function() {
    "use strict";

    const coll = db.find_projection_meta_errors;
    coll.drop();

    assert.commandWorked(coll.insert({a: 1}));
    assert.commandWorked(coll.insert({a: 2}));

    assert.commandFailedWithCode(
        db.runCommand({find: coll.getName(), projection: {score: {$meta: "searchScore"}}}),
        ErrorCodes.BadValue);

    assert.commandFailedWithCode(
        db.runCommand({find: coll.getName(), projection: {score: {$meta: "searchHighlights"}}}),
        ErrorCodes.BadValue);

    assert.commandFailedWithCode(
        db.runCommand({find: coll.getName(), projection: {score: {$meta: "some garbage"}}}),
        ErrorCodes.BadValue);
}());