From 12c6835155c256eefac8fed7bd36c41120731b91 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 7 Feb 2022 13:48:22 -0500 Subject: [PATCH] fix(NODE-3878): use legacy count operation on collection.count (#3126) --- src/collection.ts | 8 ++++++-- .../client_side_encryption.spec.test.js | 6 +----- .../command-monitoring/command_monitoring.spec.test.js | 1 - .../retryable-reads/retryable_reads.spec.test.js | 2 -- test/integration/transactions/transactions.spec.test.js | 3 --- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/collection.ts b/src/collection.ts index 86429cbabb..81be9fe3ee 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -21,7 +21,7 @@ import type { import type { AggregateOptions } from './operations/aggregate'; import { BulkWriteOperation } from './operations/bulk_write'; import type { IndexInformationOptions } from './operations/common_functions'; -import type { CountOptions } from './operations/count'; +import { CountOperation, CountOptions } from './operations/count'; import { CountDocumentsOperation, CountDocumentsOptions } from './operations/count_documents'; import { DeleteManyOperation, @@ -1637,7 +1637,11 @@ export class Collection { filter ??= {}; return executeOperation( getTopology(this), - new CountDocumentsOperation(this as TODO_NODE_3286, filter, resolveOptions(this, options)), + new CountOperation( + MongoDBNamespace.fromString(this.namespace), + filter, + resolveOptions(this, options) + ), callback ); } diff --git a/test/integration/client-side-encryption/client_side_encryption.spec.test.js b/test/integration/client-side-encryption/client_side_encryption.spec.test.js index cef2a88453..93a5c25b33 100644 --- a/test/integration/client-side-encryption/client_side_encryption.spec.test.js +++ b/test/integration/client-side-encryption/client_side_encryption.spec.test.js @@ -35,10 +35,6 @@ describe('Client Side Encryption', function () { }); generateTopologyTests(testSuites, testContext, spec => { - return ( - !spec.description.match(/type=symbol/) && - !spec.description.match(/maxWireVersion < 8/) && - !spec.description.match(/Count with deterministic encryption/) // TODO(NODE-3369): Unskip - ); + return !spec.description.match(/type=symbol/) && !spec.description.match(/maxWireVersion < 8/); }); }); diff --git a/test/integration/command-monitoring/command_monitoring.spec.test.js b/test/integration/command-monitoring/command_monitoring.spec.test.js index 64ef1ac207..7301da92b9 100644 --- a/test/integration/command-monitoring/command_monitoring.spec.test.js +++ b/test/integration/command-monitoring/command_monitoring.spec.test.js @@ -240,7 +240,6 @@ describe('Command Monitoring spec tests', function () { } loadSpecTests('command-monitoring/legacy').forEach(scenario => { - if (scenario.name === 'command') return; // TODO(NODE-3369): remove when `count` spec tests have been fixed describe(scenario.name, function () { scenario.tests.forEach(test => { const requirements = { topology: ['single', 'replicaset', 'sharded'] }; diff --git a/test/integration/retryable-reads/retryable_reads.spec.test.js b/test/integration/retryable-reads/retryable_reads.spec.test.js index 92ad52b828..20d61ae5cb 100644 --- a/test/integration/retryable-reads/retryable_reads.spec.test.js +++ b/test/integration/retryable-reads/retryable_reads.spec.test.js @@ -23,8 +23,6 @@ describe('Retryable Reads', function () { spec.description.match(/listCollections/i) || spec.description.match(/listCollectionNames/i) || spec.description.match(/estimatedDocumentCount/i) || - // FIXME(NODE-3369): uncomment when `count` spec tests have been fixed - // spec.description.match(/count/i) || spec.description.match(/find/i) ); }); diff --git a/test/integration/transactions/transactions.spec.test.js b/test/integration/transactions/transactions.spec.test.js index 5ea5e1d58a..05b829324a 100644 --- a/test/integration/transactions/transactions.spec.test.js +++ b/test/integration/transactions/transactions.spec.test.js @@ -88,9 +88,6 @@ const SKIP_TESTS = [ 'commitTransaction retry fails on new mongos', 'unpin after transient error within a transaction and commit', - // TODO(NODE-3369): unskip count tests when spec tests have been updated - 'count', - // TODO(NODE-2034): Will be implemented as part of NODE-2034 'Client side error in command starting transaction', 'Client side error when transaction is in progress'