Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 4 additions & 5 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@
"Error running process: ": "Error running process: ",
"Error saving the document": "Error saving the document",
"Error validating collection name availability: {0}": "Error validating collection name availability: {0}",
"Error while loading the autocompletion data": "Error while loading the autocompletion data",
"Error while loading the data": "Error while loading the data",
"Error while loading the document": "Error while loading the document",
"Error while refreshing the document": "Error while refreshing the document",
Expand Down Expand Up @@ -521,7 +520,7 @@
"Failed to validate source collection: {0}": "Failed to validate source collection: {0}",
"Failed with code \"{0}\".": "Failed with code \"{0}\".",
"Fair": "Fair",
"Filter: Enter the DocumentDB query filter in JSON format": "Filter: Enter the DocumentDB query filter in JSON format",
"Filter: Enter the DocumentDB query filter": "Filter: Enter the DocumentDB query filter",
"Find Query": "Find Query",
"Finished importing": "Finished importing",
"Folder name cannot be empty": "Folder name cannot be empty",
Expand Down Expand Up @@ -616,18 +615,18 @@
"Invalid Connection String: {error}": "Invalid Connection String: {error}",
"Invalid connection type selected.": "Invalid connection type selected.",
"Invalid document ID: {0}": "Invalid document ID: {0}",
"Invalid filter syntax: {0}. Please use valid JSON, for example: { \"name\": \"value\" }": "Invalid filter syntax: {0}. Please use valid JSON, for example: { \"name\": \"value\" }",
"Invalid filter syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { name: \"value\" }": "Invalid filter syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { name: \"value\" }",
"Invalid folder type.": "Invalid folder type.",
"Invalid mongoShell command format": "Invalid mongoShell command format",
"Invalid node type.": "Invalid node type.",
"Invalid payload for create index action": "Invalid payload for create index action",
"Invalid payload for drop index action": "Invalid payload for drop index action",
"Invalid payload for modify index action": "Invalid payload for modify index action",
"Invalid projection syntax: {0}": "Invalid projection syntax: {0}",
"Invalid projection syntax: {0}. Please use valid JSON, for example: { \"fieldName\": 1 }": "Invalid projection syntax: {0}. Please use valid JSON, for example: { \"fieldName\": 1 }",
"Invalid projection syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { fieldName: 1 }": "Invalid projection syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { fieldName: 1 }",
"Invalid semver \"{0}\".": "Invalid semver \"{0}\".",
"Invalid sort syntax: {0}": "Invalid sort syntax: {0}",
"Invalid sort syntax: {0}. Please use valid JSON, for example: { \"fieldName\": 1 }": "Invalid sort syntax: {0}. Please use valid JSON, for example: { \"fieldName\": 1 }",
"Invalid sort syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { fieldName: 1 }": "Invalid sort syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { fieldName: 1 }",
"It could be better": "It could be better",
"It looks like there aren't any other folders to move these items into.\nYou might want to create a new folder first.\n\nNote: You can't move items between 'DocumentDB Local' and regular connections.": "It looks like there aren't any other folders to move these items into.\nYou might want to create a new folder first.\n\nNote: You can't move items between 'DocumentDB Local' and regular connections.",
"item": "item",
Expand Down
50 changes: 21 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,14 @@
"@microsoft/vscode-azureresources-api": "~2.5.0",
"@monaco-editor/react": "~4.7.0",
"@mongodb-js/explain-plan-helper": "1.4.24",
"@mongodb-js/shell-bson-parser": "^1.5.6",
"@trpc/client": "~11.10.0",
"@trpc/server": "~11.10.0",
"@vscode/l10n": "~0.0.18",
"@vscode-documentdb/documentdb-constants": "*",
"@vscode-documentdb/schema-analyzer": "*",
"@vscode/l10n": "~0.0.18",
"acorn": "^8.16.0",
"acorn-walk": "^8.3.5",
"antlr4ts": "^0.5.0-alpha.4",
"bson": "~7.0.0",
"denque": "~2.1.0",
Expand Down
11 changes: 8 additions & 3 deletions src/documentdb/ClusterSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ParseMode, parse as parseShellBSON } from '@mongodb-js/shell-bson-parser';
import {
SchemaAnalyzer,
getPropertyNamesAtLevel,
Expand Down Expand Up @@ -540,7 +541,7 @@ export class ClusterSession {
* @remarks
* This method uses the same BSON parsing logic as ClustersClient.runFindQuery():
* - filter is parsed with toFilterQueryObj() which handles UUID(), Date(), MinKey(), MaxKey() constructors
* - projection and sort are parsed with EJSON.parse()
* - projection and sort are parsed with parseShellBSON() in Loose mode
*
* Use this method when you need the actual MongoDB Document objects for query execution.
* Use getCurrentFindQueryParams() when you only need the string representations.
Expand All @@ -555,7 +556,9 @@ export class ClusterSession {
let projectionObj: Document | undefined;
if (stringParams.project && stringParams.project.trim() !== '{}') {
try {
projectionObj = EJSON.parse(stringParams.project) as Document;
projectionObj = parseShellBSON(stringParams.project, {
mode: ParseMode.Loose,
}) as Document;
} catch (error) {
throw new Error(
l10n.t('Invalid projection syntax: {0}', error instanceof Error ? error.message : String(error)),
Expand All @@ -567,7 +570,9 @@ export class ClusterSession {
let sortObj: Document | undefined;
if (stringParams.sort && stringParams.sort.trim() !== '{}') {
try {
sortObj = EJSON.parse(stringParams.sort) as Document;
sortObj = parseShellBSON(stringParams.sort, {
mode: ParseMode.Loose,
}) as Document;
} catch (error) {
throw new Error(
l10n.t('Invalid sort syntax: {0}', error instanceof Error ? error.message : String(error)),
Expand Down
25 changes: 17 additions & 8 deletions src/documentdb/ClustersClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

import { appendExtensionUserAgent, callWithTelemetryAndErrorHandling, parseError } from '@microsoft/vscode-azext-utils';
import { ParseMode, parse as parseShellBSON } from '@mongodb-js/shell-bson-parser';
import * as l10n from '@vscode/l10n';
import { EJSON } from 'bson';
import {
Expand Down Expand Up @@ -513,13 +514,15 @@ export class ClustersClient {
// Parse and add projection if provided
if (queryParams.project && queryParams.project.trim() !== '{}') {
try {
options.projection = EJSON.parse(queryParams.project) as Document;
options.projection = parseShellBSON(queryParams.project, {
mode: ParseMode.Loose,
}) as Document;
} catch (error) {
const cause = error instanceof Error ? error : new Error(String(error));
throw new QueryError(
'INVALID_PROJECTION',
l10n.t(
'Invalid projection syntax: {0}. Please use valid JSON, for example: { "fieldName": 1 }',
'Invalid projection syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { fieldName: 1 }',
cause.message,
),
cause,
Expand All @@ -530,13 +533,15 @@ export class ClustersClient {
// Parse and add sort if provided
if (queryParams.sort && queryParams.sort.trim() !== '{}') {
try {
options.sort = EJSON.parse(queryParams.sort) as Document;
options.sort = parseShellBSON(queryParams.sort, {
mode: ParseMode.Loose,
}) as Document;
} catch (error) {
const cause = error instanceof Error ? error : new Error(String(error));
throw new QueryError(
'INVALID_SORT',
l10n.t(
'Invalid sort syntax: {0}. Please use valid JSON, for example: { "fieldName": 1 }',
'Invalid sort syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { fieldName: 1 }',
cause.message,
),
cause,
Expand Down Expand Up @@ -662,13 +667,15 @@ export class ClustersClient {
// Parse and add projection if provided
if (queryParams.project && queryParams.project.trim() !== '{}') {
try {
options.projection = EJSON.parse(queryParams.project) as Document;
options.projection = parseShellBSON(queryParams.project, {
mode: ParseMode.Loose,
}) as Document;
} catch (error) {
const cause = error instanceof Error ? error : new Error(String(error));
throw new QueryError(
'INVALID_PROJECTION',
l10n.t(
'Invalid projection syntax: {0}. Please use valid JSON, for example: { "fieldName": 1 }',
'Invalid projection syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { fieldName: 1 }',
cause.message,
),
cause,
Expand All @@ -679,13 +686,15 @@ export class ClustersClient {
// Parse and add sort if provided
if (queryParams.sort && queryParams.sort.trim() !== '{}') {
try {
options.sort = EJSON.parse(queryParams.sort) as Document;
options.sort = parseShellBSON(queryParams.sort, {
mode: ParseMode.Loose,
}) as Document;
} catch (error) {
const cause = error instanceof Error ? error : new Error(String(error));
throw new QueryError(
'INVALID_SORT',
l10n.t(
'Invalid sort syntax: {0}. Please use valid JSON, for example: { "fieldName": 1 }',
'Invalid sort syntax: {0}. Please use valid JSON or a DocumentDB API expression, for example: { fieldName: 1 }',
cause.message,
),
cause,
Expand Down
Loading
Loading