jstests/core/merge_sort_collation.js
// query on a collection and compares the results with the expected collection.
query on a collection and compares the results with the expected collection.
query on a collection and compares the results with the expected collection .
function executeQueryTestCase(testCase) {
    let coll = db.getCollection(collNamePrefix + collCount++);
    Object.assign(testCase, {ns: coll.getFullName()});
    jsTestLog(tojson(testCase));
    coll.drop();
    const collectionOptions = {};
    if (testCase.collectionCollation !== undefined) {
        collectionOptions.collation = testCase.collectionCollation;
    }
    assert.commandWorked(db.createCollection(coll.getName(), collectionOptions));
    if (testCase.indexes !== undefined) {
        assert.commandWorked(coll.createIndexes(testCase.indexes, testCase.indexOptions));
    }
    assert.commandWorked(coll.insert(testCase.inputDocuments));
    let projection = {};
    if (testCase.projection !== undefined) {
        projection = testCase.projection;
    }
    let cursor = coll.find(testCase.filter, projection).sort(testCase.sort);
    if (testCase.findCollation !== undefined) {
        cursor = cursor.collation(testCase.findCollation);
    }
    const actualResults = cursor.toArray();
    assert.eq(actualResults, testCase.expectedResults);
}
function executeQueryTestCase ( testCase ) { let coll = db . getCollection ( collNamePrefix + collCount ++ ) ; Object . assign ( testCase , { ns : coll . getFullName ( ) } ) ; jsTestLog ( tojson ( testCase ) ) ; coll . drop ( ) ; const collectionOptions = { } ; if ( testCase . collectionCollation !== undefined ) { collectionOptions . collation = testCase . collectionCollation ; } assert . commandWorked ( db . createCollection ( coll . getName ( ) , collectionOptions ) ) ; if ( testCase . indexes !== undefined ) { assert . commandWorked ( coll . createIndexes ( testCase . indexes , testCase . indexOptions ) ) ; } assert . commandWorked ( coll . insert ( testCase . inputDocuments ) ) ; let projection = { } ; if ( testCase . projection !== undefined ) { projection = testCase . projection ; } let cursor = coll . find ( testCase . filter , projection ) . sort ( testCase . sort ) ; if ( testCase . findCollation !== undefined ) { cursor = cursor . collation ( testCase . findCollation ) ; } const actualResults = cursor . toArray ( ) ; assert . eq ( actualResults , testCase . expectedResults ) ; }
query on a collection and compares the results with the expected collection.
query on a collection and compares the results with the expected collection .
// Drop the test collection. // Create a collection. // Create index(es). // Insert some documents into the collection. // Run a find query with optionally specified collation and projection. // Compare results to expected.