-
Notifications
You must be signed in to change notification settings - Fork 911
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
Conversation
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.
I had to force push to accommodate changes in the the evergreen config requirements
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.
I still don't have a better name for MgoKeyHandling and am open to suggestions
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 |
bson/bsoncodec/map_codec.go
Outdated
return val.String(), nil | ||
} | ||
// KeyMarshalers are marshaled | ||
if tm, ok := val.Interface().(KeyMarshaler); ok { |
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.
nit: I assume tm
was for TextMarshaler
. Change to km
.
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.
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
.
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.
from what i can tell, map keys aren't addressable, so I didn't any of the pointer to value things.
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.
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.
No description provided.