Skip to content

GODRIVER-1494 add option for encoding/json style map encoding #345

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

Merged
merged 6 commits into from
Apr 13, 2020

Conversation

iwysiu
Copy link
Contributor

@iwysiu iwysiu commented Mar 24, 2020

No description provided.

@iwysiu iwysiu requested review from jyemin and divjotarora March 24, 2020 18:27
@jyemin jyemin requested review from craiggwilson and removed request for jyemin March 26, 2020 15:27
Copy link
Contributor Author

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

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

I had to force push to accommodate changes in the the evergreen config requirements

@iwysiu iwysiu requested a review from craiggwilson March 31, 2020 17:56
Copy link
Contributor Author

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

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

I still don't have a better name for MgoKeyHandling and am open to suggestions

@iwysiu
Copy link
Contributor Author

iwysiu commented Apr 10, 2020

Divjot and I talked, and we decided that it was less likely to be backwards breaking for users if we use our own interfaces instead of encoding/json's

return val.String(), nil
}
// KeyMarshalers are marshaled
if tm, ok := val.Interface().(KeyMarshaler); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I assume tm was for TextMarshaler. Change to km.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be checking if a pointer to value implements KeyMarshaler as well? Our standard registry lookup checks that for other interfaces we support like Marshaler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from what i can tell, map keys aren't addressable, so I didn't any of the pointer to value things.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, seems like encoding/json doesn't respect &T implementing TextMarshaler either. As discussed offline, this is likely because map keys and values can move around if the map is re-sized so any addresses to them would be invalidated.

@iwysiu iwysiu requested a review from divjotarora April 13, 2020 18:38
@iwysiu iwysiu merged commit 202644f into mongodb:master Apr 13, 2020
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