-
Notifications
You must be signed in to change notification settings - Fork 85
[WIP] output full bson objects MONGOSH-1285 #2584
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
base: main
Are you sure you want to change the base?
Conversation
packages/shell-api/src/deep-inspect-service-provider-wrapper.ts
Outdated
Show resolved
Hide resolved
packages/shell-api/src/deep-inspect-service-provider-wrapper.ts
Outdated
Show resolved
Hide resolved
packages/shell-api/src/deep-inspect-service-provider-wrapper.ts
Outdated
Show resolved
Hide resolved
| this: DeepInspectServiceProviderWrapper, | ||
| ...args: Parameters<Required<ServiceProvider>[K]> | ||
| ): // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore The returntype already contains a promise |
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.
A way around all this is to just make one function similar to bsonMethod() for each unique return type, kinda like what I did for the cursor methods.
packages/shell-api/src/deep-inspect-service-provider-wrapper.ts
Outdated
Show resolved
Hide resolved
packages/shell-api/src/deep-inspect-service-provider-wrapper.ts
Outdated
Show resolved
Hide resolved
2428a91 to
4b2991c
Compare
| undefined, | ||
| undefined, | ||
| initialServiceProvider | ||
| this.initialServiceProvider |
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.
btw it is VERY easy to accidentally pass initialServiceProvider (ie. the unwrapped value) to something in place of this.initialServiceProvider. Ask me how I know..
MONGOSH-1285
I built this on top of @addaleax's wip branch, so the types are still mostly from there.
The short version of what we're trying to do: For BSON that we get from the database we want to print all of it, untruncated, when it gets evaluated or otherwise inspected with util.inspect().
This solution wraps the ServiceProvider with another class that implements all the same methods. Then:
I have been testing it with this document which should be affected by the inspectOptions
depth,maxArrayLengthandmaxStringLength:And this doc has every BSON type which is useful for testing that we're not messing up existing BSON formatting:
You can test that the find cursor's tryNext was replaced by running:
Notice that the whole array, string and object all printed. However, this specific case already worked before because we special-case printing cursors and a few other things.
This will exercise the inspect function on the top-level array that was returned.
You can test that it recursively installed it on the documents inside that array by running:
or even
This needs a lot of tests. There are almost certainly some cases left that I've missed. And I'm unsure about some details. Just opening to have a discussion. Oh and we might want a way for users to opt out of it.