Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
612 changes: 103 additions & 509 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/compass-aggregations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@mongodb-js/explain-plan-helper": "^1.4.24",
"@mongodb-js/mongodb-constants": "^0.17.0",
"@mongodb-js/my-queries-storage": "^0.50.0",
"@mongodb-js/shell-bson-parser": "^1.2.0",
"@mongodb-js/shell-bson-parser": "^1.3.3",
"bson": "^6.10.4",
"compass-preferences-model": "^2.66.1",
"hadron-document": "^8.10.5",
Expand All @@ -87,7 +87,7 @@
"mongodb-database-model": "^2.36.0",
"mongodb-instance-model": "^12.58.1",
"mongodb-ns": "^3.0.1",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"mongodb-schema": "^12.6.3",
"re-resizable": "^6.9.0",
"react": "^17.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-crud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@mongodb-js/explain-plan-helper": "^1.4.24",
"@mongodb-js/my-queries-storage": "^0.50.0",
"@mongodb-js/reflux-state-mixin": "^1.2.24",
"@mongodb-js/shell-bson-parser": "^1.2.0",
"@mongodb-js/shell-bson-parser": "^1.3.3",
"ag-grid-community": "^20.2.0",
"ag-grid-react": "^20.2.0",
"bson": "^6.10.4",
Expand All @@ -97,7 +97,7 @@
"mongodb": "^6.19.0",
"mongodb-data-service": "^22.35.0",
"mongodb-ns": "^3.0.1",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"react": "^17.0.2",
"reflux": "^0.4.1",
"semver": "^7.6.3"
Expand Down
18 changes: 15 additions & 3 deletions packages/compass-crud/src/stores/crud-store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@ describe('store', function () {
);
});

it('should keep user projection when provided', async function () {
it('should keep user fields when provided', async function () {
await fetchDocuments(
dataService,
track,
Expand All @@ -2421,13 +2421,25 @@ describe('store', function () {
'test.test',
{},
{
projection: { _id: 1 },
projection: { _id: 1, pineapple: 1 },
hint: 'pineapple',
limit: 10,
skip: 7,
sort: { pineapple: 1 },
}
);
expect(find).to.have.been.calledOnce;
expect(find.getCall(0))
.to.have.nested.property('args.2.projection')
.deep.eq({ _id: 1 });
.deep.eq({ _id: 1, pineapple: 1 });
expect(find.getCall(0)).to.have.nested.property('args.2.limit').eq(10);
expect(find.getCall(0)).to.have.nested.property('args.2.skip').eq(7);
expect(find.getCall(0))
.to.have.nested.property('args.2.sort')
.deep.eq({ pineapple: 1 });
expect(find.getCall(0))
.to.have.nested.property('args.2.hint')
.eq('pineapple');
});

it('should retry find operation if failed with server error when applying custom projection', async function () {
Expand Down
32 changes: 20 additions & 12 deletions packages/compass-crud/src/stores/crud-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import type {
} from '@mongodb-js/compass-connections/provider';
import type { Query, QueryBarService } from '@mongodb-js/compass-query-bar';
import type { TrackFunction } from '@mongodb-js/compass-telemetry';
import type { MongoServerError } from 'mongodb';
import type { CollationOptions, MongoServerError } from 'mongodb';

export type BSONObject = TypeCastMap['Object'];
export type BSONArray = TypeCastMap['Array'];
Expand Down Expand Up @@ -587,7 +587,7 @@ class CrudStoreImpl
if (id !== undefined) {
doc.onRemoveStart();
try {
await this.dataService.deleteOne(this.state.ns, { _id: id } as any);
await this.dataService.deleteOne(this.state.ns, { _id: id as any });
// emit on the document(list view) and success state(json view)
doc.onRemoveSuccess();
const payload = { view: this.state.view, ns: this.state.ns };
Expand Down Expand Up @@ -864,6 +864,7 @@ class CrudStoreImpl
filter,
limit,
sort,
hint,
project: projection,
collation,
maxTimeMS,
Expand Down Expand Up @@ -892,9 +893,10 @@ class CrudStoreImpl
const opts = {
skip,
limit: nextPageCount,
sort,
projection,
collation,
hint: hint ?? undefined,
sort: sort ?? undefined,
projection: projection ?? undefined,
collation: collation as CollationOptions,
maxTimeMS: capMaxTimeMSAtPreferenceLimit(this.preferences, maxTimeMS),
promoteValues: false,
bsonRegExp: true,
Expand All @@ -918,7 +920,7 @@ class CrudStoreImpl
this.state.isDataLake,
ns,
filter ?? {},
opts as any,
opts,
{
abortSignal: signal,
}
Expand Down Expand Up @@ -1647,9 +1649,14 @@ class CrudStoreImpl
: query.maxTimeMS
),
signal,
...(query.hint
? {
hint: query.hint,
}
: {}),
};

if (this.isCountHintSafe(query)) {
if (!countOptions.hint && this.isCountHintSafe(query)) {
countOptions.hint = '_id_';
}

Expand All @@ -1669,11 +1676,12 @@ class CrudStoreImpl
}

const findOptions = {
sort,
projection: query.project,
sort: sort ?? undefined,
projection: query.project ?? undefined,
skip: query.skip,
limit: docsPerPage,
collation: query.collation,
collation: query.collation as CollationOptions,
hint: query.hint ?? undefined,
maxTimeMS: capMaxTimeMSAtPreferenceLimit(
this.preferences,
query.maxTimeMS
Expand Down Expand Up @@ -1703,7 +1711,7 @@ class CrudStoreImpl
// Only check if index was used if query filter or sort is not empty
if (!isEmpty(query.filter) || !isEmpty(query.sort)) {
void this.dataService
.explainFind(ns, query.filter ?? {}, findOptions as any, {
.explainFind(ns, query.filter ?? {}, findOptions, {
explainVerbosity: 'queryPlanner',
abortSignal: signal,
})
Expand Down Expand Up @@ -1770,7 +1778,7 @@ class CrudStoreImpl
this.state.isDataLake,
ns,
query.filter ?? {},
findOptions as any,
findOptions,
{
abortSignal: signal,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@lezer/highlight": "^1.2.1",
"@mongodb-js/compass-components": "^1.59.0",
"@mongodb-js/mongodb-constants": "^0.17.0",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"polished": "^4.2.2",
"prettier": "^2.7.1",
"react": "^17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-export-to-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@mongodb-js/compass-editor": "^0.61.0",
"@mongodb-js/compass-maybe-protect-connection-string": "^0.64.1",
"@mongodb-js/compass-telemetry": "^1.19.4",
"@mongodb-js/shell-bson-parser": "^1.2.0",
"@mongodb-js/shell-bson-parser": "^1.3.3",
"bson-transpilers": "^3.2.23",
"compass-preferences-model": "^2.66.1",
"@mongodb-js/compass-app-registry": "^9.4.28",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-import-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"mongodb": "^6.19.0",
"mongodb-data-service": "^22.35.0",
"mongodb-ns": "^3.0.1",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"mongodb-schema": "^12.6.3",
"papaparse": "^5.3.2",
"react": "^17.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-indexes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@mongodb-js/compass-telemetry": "^1.19.4",
"@mongodb-js/compass-workspaces": "^0.69.1",
"@mongodb-js/mongodb-constants": "^0.17.0",
"@mongodb-js/shell-bson-parser": "^1.2.0",
"@mongodb-js/shell-bson-parser": "^1.3.3",
"@mongodb-js/connection-info": "^0.23.0",
"bson": "^6.10.4",
"compass-preferences-model": "^2.66.1",
Expand All @@ -85,7 +85,7 @@
"mongodb-collection-model": "^5.36.0",
"mongodb-data-service": "^22.35.0",
"mongodb-ns": "^3.0.1",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"react": "^17.0.2",
"react-redux": "^8.1.3",
"redux": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-query-bar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"mongodb": "^6.19.0",
"mongodb-instance-model": "^12.58.1",
"mongodb-ns": "^3.0.1",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"mongodb-query-util": "^2.5.12",
"mongodb-schema": "^12.6.3",
"react": "^17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DEFAULT_PROJECT,
DEFAULT_COLLATION,
DEFAULT_MAX_TIME_MS,
DEFAULT_HINT,
} from 'mongodb-query-parser';

/**
Expand All @@ -30,7 +31,7 @@ const DEFAULT_QUERY_VALUES = {
project: DEFAULT_PROJECT,
collation: DEFAULT_COLLATION,
sort: DEFAULT_SORT,
hint: null,
hint: DEFAULT_HINT,
skip: DEFAULT_SKIP,
limit: DEFAULT_LIMIT,
maxTimeMS: DEFAULT_MAX_TIME_MS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const OPTION_DEFINITION: {
name: 'hint',
label: 'Index Hint',
type: 'document',
placeholder: '{ field: -1 }',
placeholder: '{ field: -1 } or "indexName"',
link: 'https://docs.mongodb.com/manual/reference/method/cursor.hint/',
},
collation: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type QueryFormFields = {
project: FormField<Document | null>;
collation: FormField<Document | null>;
sort: FormField<Document | null>;
hint: FormField<Document | null>;
hint: FormField<Document | string | null>;
skip: FormField<number>;
limit: FormField<number>;
maxTimeMS: FormField<number>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ describe('queryBarReducer', function () {

['maxTimeMS', '1', 1, true],
['maxTimeMS', '-1', DEFAULT_QUERY_VALUES['maxTimeMS'], false],

['hint', '"hintPineappleIndex"', 'hintPineappleIndex', true],
['hint', '{ pineapple: 1 }', { pineapple: 1 }, true],
['hint', 'pineapple', DEFAULT_QUERY_VALUES['hint'], false],
['hint', '1', DEFAULT_QUERY_VALUES['hint'], false],
['hint', '-1', DEFAULT_QUERY_VALUES['hint'], false],
];

specs.forEach(([field, str, expectedValue, expectedValid]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const applyFromHistory = (
return (dispatch, getState, { localAppRegistry, preferences }) => {
const currentFields = getState().queryBar.fields;
const currentQuery = currentQueryFieldsToRetain.reduce<
Record<string, Document | number>
Record<string, Document | number | string>
>((acc, key) => {
const { value } = currentFields[key];
if (value) {
Expand Down
8 changes: 1 addition & 7 deletions packages/compass-query-bar/src/utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function validateField(
}: Pick<UserPreferences, 'maxTimeMS' | 'maxTimeMSEnvLimit'>
) {
const validated = validate(field, value);
if (field === 'filter' && validated === '') {
if ((field === 'filter' || field === 'hint') && validated === '') {
// TODO(COMPASS-5205): Things like { i: $} confuses queryParser and
// ultimately it sets filter to '' whereas it has to be a {} (if valid) or
// false (if invalid). Should probably be fixed in mongodb-query-parser,
Expand Down Expand Up @@ -163,12 +163,6 @@ export function validateField(
}
}

// We don't have a validator for indexes, but indexes share the same structure as
// a sort document, so we're leveraging this to validate the hint field
if (field === 'hint') {
return validate('sort', value);
}

return validated;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/compass-schema-validation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"lodash": "^4.17.21",
"mongodb": "^6.19.0",
"mongodb-ns": "^3.0.1",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"react": "^17.0.2",
"react-redux": "^8.1.3",
"redux": "^4.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export const startAnalysis = (): SchemaThunkAction<

const driverOptions: AggregateOptions = {
maxTimeMS: capMaxTimeMSAtPreferenceLimit(preferences, query.maxTimeMS),
hint: query.hint ?? undefined,
};

analysisAbortControllerRef.current = new AbortController();
Expand Down
4 changes: 2 additions & 2 deletions packages/connection-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
"@mongodb-js/compass-components": "^1.59.0",
"@mongodb-js/compass-editor": "^0.61.0",
"@mongodb-js/connection-info": "^0.23.0",
"@mongodb-js/shell-bson-parser": "^1.2.0",
"@mongodb-js/shell-bson-parser": "^1.3.3",
"lodash": "^4.17.21",
"mongodb": "^6.19.0",
"mongodb-build-info": "^1.8.1",
"mongodb-connection-string-url": "^3.0.1",
"mongodb-data-service": "^22.35.0",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"react": "^17.0.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/databases-collections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"mongodb-database-model": "^2.36.0",
"mongodb-instance-model": "^12.58.1",
"mongodb-ns": "^3.0.1",
"mongodb-query-parser": "^4.3.0",
"mongodb-query-parser": "^4.5.0",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-redux": "^8.1.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/explain-plan-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
},
"dependencies": {
"@mongodb-js/shell-bson-parser": "^1.2.0",
"@mongodb-js/shell-bson-parser": "^1.3.3",
"mongodb-explain-compat": "^3.3.23"
},
"devDependencies": {
Expand Down
Loading