-
Notifications
You must be signed in to change notification settings - Fork 80
feat: allow opting out of schema sampling with config disableSchemaSampling=true MONGOSH-2370 #2503
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
Changes from all commits
2ffef9c
cd47bb7
96a209c
192d1f2
e23aa5b
041eef6
11e6904
37481d1
a784243
9f9290e
6781213
46b8ca2
fc56b38
7d71f3b
ce169b5
60bc141
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,6 +309,7 @@ describe('CliRepl', function () { | |
'maxTimeMS', | ||
'enableTelemetry', | ||
'editor', | ||
'disableSchemaSampling', | ||
'snippetIndexSourceURLs', | ||
'snippetRegistryURL', | ||
'snippetAutoload', | ||
|
@@ -2478,10 +2479,6 @@ describe('CliRepl', function () { | |
// be listed | ||
wantWatch = true; | ||
wantShardDistribution = true; | ||
|
||
// TODO: we need MQL support in mongodb-ts-autocomplete in order for it | ||
// to autocomplete collection field names | ||
wantQueryOperators = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. drive-by but I realised this test should actually be passing by now (with the env var set, obviously |
||
} | ||
} | ||
|
||
|
@@ -2492,8 +2489,11 @@ describe('CliRepl', function () { | |
await tick(); | ||
input.write('\u0009'); | ||
await waitCompletion(cliRepl.bus); | ||
await tick(); | ||
}; | ||
|
||
let docsLoadedPromise: Promise<void>; | ||
|
||
beforeEach(async function () { | ||
if (testServer === null) { | ||
cliReplOptions.shellCliOptions = { nodb: true }; | ||
|
@@ -2508,9 +2508,16 @@ describe('CliRepl', function () { | |
if (!(testServer as any)?._opts.args?.includes('--auth')) { | ||
// make sure there are some collections we can autocomplete on below | ||
input.write('db.coll.insertOne({})\n'); | ||
input.write('db.movies.insertOne({})\n'); | ||
await waitEval(cliRepl.bus); | ||
input.write('db.movies.insertOne({ year: 1 })\n'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something I haven't really given much thought before, but the mql library won't autocomplete under fields that it doesn't know about: const query: Query<{/* empty schema */}> = {
year: {
$g // you can't auto-complete here
}
} |
||
await waitEval(cliRepl.bus); | ||
} | ||
|
||
docsLoadedPromise = new Promise<void>((resolve) => { | ||
cliRepl.bus.once('mongosh:load-sample-docs-complete', () => { | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
|
||
afterEach(async function () { | ||
|
@@ -2521,6 +2528,29 @@ describe('CliRepl', function () { | |
await cliRepl.mongoshRepl.close(); | ||
}); | ||
|
||
it(`${ | ||
wantQueryOperators ? 'completes' : 'does not complete' | ||
} query operators`, async function () { | ||
input.write('db.movies.find({year: {$g'); | ||
await tabCompletion(); | ||
|
||
if (wantQueryOperators) { | ||
if (process.env.USE_NEW_AUTOCOMPLETE) { | ||
// wait for the documents to finish loading to be sure that the next | ||
// tabCompletion() call will work | ||
await docsLoadedPromise; | ||
} | ||
} | ||
|
||
await tabCompletion(); | ||
|
||
if (wantQueryOperators) { | ||
expect(output).to.include('db.movies.find({year: {$gte'); | ||
} else { | ||
expect(output).to.not.include('db.movies.find({year: {$gte'); | ||
} | ||
}); | ||
|
||
it(`${ | ||
wantWatch ? 'completes' : 'does not complete' | ||
} the watch method`, async function () { | ||
|
@@ -2644,19 +2674,6 @@ describe('CliRepl', function () { | |
expect(output).to.include('use admin'); | ||
}); | ||
|
||
it(`${ | ||
wantQueryOperators ? 'completes' : 'does not complete' | ||
} query operators`, async function () { | ||
input.write('db.movies.find({year: {$g'); | ||
await tabCompletion(); | ||
await tabCompletion(); | ||
if (wantQueryOperators) { | ||
expect(output).to.include('db.movies.find({year: {$gte'); | ||
} else { | ||
expect(output).to.not.include('db.movies.find({year: {$gte'); | ||
} | ||
}); | ||
|
||
it('completes properties of shell API result types', async function () { | ||
if (!hasCollectionNames) return this.skip(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -469,11 +469,6 @@ class MongoshNodeRepl implements EvaluationListener { | |
} | ||
})(), | ||
]); | ||
this.bus.emit( | ||
'mongosh:autocompletion-complete', | ||
replResults, | ||
mongoshResults | ||
); // For testing. | ||
|
||
// Sometimes the mongosh completion knows that what it is doing is right, | ||
// and that autocompletion based on inspecting the actual objects that | ||
|
@@ -513,6 +508,8 @@ class MongoshNodeRepl implements EvaluationListener { | |
results = results.filter( | ||
(result) => !CONTROL_CHAR_REGEXP.test(result) | ||
); | ||
// emit here so that on nextTick the results should be output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OMG. autocomplete became async and there's another await. |
||
this.bus.emit('mongosh:autocompletion-complete'); // For testing. | ||
return [results, completeOn]; | ||
} finally { | ||
this.insideAutoCompleteOrGetPrompt = false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,10 +71,7 @@ async function waitEval(bus: MongoshBus) { | |
} | ||
|
||
async function waitCompletion(bus: MongoshBus) { | ||
await Promise.race([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This timeout was just always going to be flaky and pressing tab twice doesn't necessarily mean it completed a potentially slow operation anyway. tabtab() always relied on 2 * 250ms being enough. |
||
waitBus(bus, 'mongosh:autocompletion-complete'), | ||
new Promise((resolve) => setTimeout(resolve, 10_000)?.unref?.()), | ||
]); | ||
await waitBus(bus, 'mongosh:autocompletion-complete'); | ||
await tick(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't realise this was only failing on latest and that latest means latest alpha, not latest production release.