Skip to content

Commit a2191e1

Browse files
authored
fix(aggregations): Hide $documents operator in collection aggregations COMPASS-5843 (#3114)
* Hide the stage operator because it only works on db level * use metadata from ace-autocompleter rather * newer ace-autocompleter * update package-lock
1 parent 51c5850 commit a2191e1

File tree

7 files changed

+31
-31
lines changed

7 files changed

+31
-31
lines changed

package-lock.json

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-aggregations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"hadron-react-buttons": "^5.9.0",
8484
"hadron-react-components": "^5.15.0",
8585
"mocha": "^8.4.0",
86-
"mongodb-ace-autocompleter": "^0.13.0",
86+
"mongodb-ace-autocompleter": "^0.14.0",
8787
"mongodb-connection-model": "^21.17.0",
8888
"mongodb-data-service": "^21.21.0",
8989
"mongodb-query-parser": "^2.4.6",

packages/compass-aggregations/src/utils/stage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ const isNotWritable = ({ oName, allowWrites }) => [OUT, MERGE].includes(oName) &
8787
*/
8888
const isSupportedVersion = ({ oVersion, version }) => semver.gte(version, oVersion);
8989

90-
9190
/**
9291
* Is search on a view, time-series, or regular collection?
9392
*
@@ -125,6 +124,7 @@ export const filterStageOperators = ({ serverVersion, allowWrites, env, isTimeSe
125124
return STAGE_OPERATORS.filter((o) => {
126125
if (isNotWritable({ oName: o.name, allowWrites })) return false;
127126
if (isSearchOnView({ oName: o.name, isTimeSeries, isReadonly, sourceName })) return false;
127+
if (o.dbOnly) return false;
128128

129129
return isSupportedVersion({ oVersion: o.version, version: cleanVersion }) &&
130130
isSupportedEnv({ oEnv: o.env, env }) ||

packages/compass-aggregations/src/utils/stage.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@ describe('utils', function() {
110110
expect(searchMeta.length).to.be.equal(1);
111111
});
112112

113-
it('returns $documents stage for a regular collection', function() {
113+
// $documents only works for db.aggregate, not coll.aggregate
114+
it('does not return $documents stage for a regular collection', function() {
114115
const documents = filterStageOperators({ ...filter })
115116
.filter((o) => (o.name === '$documents'));
116117

117-
expect(documents.length).to.be.equal(1);
118+
expect(documents.length).to.be.equal(0);
118119
});
119120

120121
it('does not return full-text search stages for time-series on-prem', function() {

packages/compass-e2e-tests/tests/collection-aggregations-tab.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ describe('Collection aggregations tab', function () {
117117
'$bucketAuto',
118118
'$collStats',
119119
'$count',
120-
'$documents',
121120
'$facet',
122121
'$geoNear',
123122
'$graphLookup',

packages/compass-query-bar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"hadron-app-registry": "^8.12.0",
8585
"hadron-react-components": "^5.15.0",
8686
"mocha": "^7.0.1",
87-
"mongodb-ace-autocompleter": "^0.13.0",
87+
"mongodb-ace-autocompleter": "^0.14.0",
8888
"mongodb-query-parser": "^2.4.6",
8989
"ms": "^2.1.2",
9090
"nyc": "^15.1.0",

packages/compass-schema-validation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"less-loader": "^7.3.0",
9494
"mocha": "^5.0.0",
9595
"mocha-webpack": "^2.0.0-beta.0",
96-
"mongodb-ace-autocompleter": "^0.13.0",
96+
"mongodb-ace-autocompleter": "^0.14.0",
9797
"mongodb-connection-model": "^21.17.0",
9898
"mongodb-data-service": "^21.21.0",
9999
"mongodb-ns": "^2.4.0",

0 commit comments

Comments
 (0)