Skip to content

REP-5806 Parse document filter as extended JSON #111

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

FGasper
Copy link
Collaborator

@FGasper FGasper commented May 1, 2025

Previously we parsed the document filter as plain JSON, which made it impossible to filter on ObjectID or other BSON-specific types.

This changeset fixes that by parsing the document filter as MongoDB’s extended JSON.

I’m going to merge the commits as-is rather than squashing. Note that there are two unrelated UX improvements here, as well as a fix for a race condition in an unrelated test, in discrete commits.

@FGasper FGasper marked this pull request as draft May 1, 2025 20:12
@FGasper FGasper force-pushed the REP-5806-doc-filter-ext-json branch from 803c1ba to ce20362 Compare May 2, 2025 14:29
@FGasper FGasper marked this pull request as ready for review May 2, 2025 14:29
Copy link
Collaborator

@ajayvijayakumar123 ajayvijayakumar123 left a comment

Choose a reason for hiding this comment

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

Looks good, had some questions!

FGasper added 4 commits May 2, 2025 11:47
Previously we parsed the document filter as plain JSON, which made it
impossible to filter on ObjectID or other BSON-specific types.

This changeset fixes that by parsing the document filter as MongoDB’s
extended JSON.
This avoids hard-to-understand phrases like this:
> failed comparison on field counter between srcClient ...

… which really sounds like there is a counter for fields rather than
a field named “counter”.
@FGasper FGasper force-pushed the REP-5806-doc-filter-ext-json branch from cb297d9 to 597d268 Compare May 2, 2025 15:47
@FGasper FGasper requested a review from ajayvijayakumar123 May 2, 2025 15:47
Copy link
Collaborator

@ajayvijayakumar123 ajayvijayakumar123 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@tdq45gj tdq45gj 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 question about a very trivial case


func (ejb extJSONBindingType) Bind(req *http.Request, obj any) error {
if req == nil || req.Body == nil {
return errors.New("invalid request")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should req.Body == nil be an error or should it return an empty struct?

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