Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(playground): codelens for active connection will inform about default connected database VSCODE-316 #621

Merged
merged 5 commits into from
Dec 7, 2023

Conversation

himanshusinghs
Copy link
Contributor

@himanshusinghs himanshusinghs commented Dec 5, 2023

Description

Original issue highlighted in VSCODE-316 (playground should run in database specified in connection string), is not reproducible anymore. It works as expected - if no use('database') call is specified in playground and there is a database specified in connection string then the playground will run in the database specified in connection string.

With this PR, we will now additionally highlight, in the playground, the default database that the playground will run in, if there is one specified in connection string.

Without default database in connection string With default database in connection string
mongodb+srv://<credentials>@host mongodb+srv://<credentials>@host/countries
image image

We additionally also provide autocomplete for the collection names on the db object when connected using a connection string with default database and there is no explicit use('DB') call in the playground.

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

Comment on lines -1311 to -1329
test('provide collection names completion for valid object names', async () => {
const content = 'use("test"); db.';
const position = { line: 0, character: 16 };
const document = TextDocument.create('init', 'javascript', 1, content);

testMongoDBService._cacheCollections('test', [{ name: 'empty' }]);

const result = await testMongoDBService.provideCompletionItems({
document,
position,
});
const findCollectionCompletion = result.find(
(item: CompletionItem) => item.label === 'empty'
);
expect(findCollectionCompletion).to.have.property(
'kind',
CompletionItemKind.Folder
);
});
Copy link
Contributor Author

@himanshusinghs himanshusinghs Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these tests (collection names completion tests) are not removed. I just moved them in a dynamic suite to test three different scenarios.

Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, one suggestion on reducing duplicated code

src/language/mongoDBService.ts Outdated Show resolved Hide resolved
@himanshusinghs himanshusinghs force-pushed the VSCODE-316-playgrounds-provide-default-db-info branch from 16033ac to cda24a9 Compare December 6, 2023 11:23
@himanshusinghs himanshusinghs merged commit f93f111 into main Dec 7, 2023
5 checks passed
@himanshusinghs himanshusinghs deleted the VSCODE-316-playgrounds-provide-default-db-info branch December 7, 2023 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants