-
Notifications
You must be signed in to change notification settings - Fork 213
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
Fix bson.D conversion in GRPC #2083
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.
The CI build is failing but this looks like it's going in the right direction
8cf0cd2
to
d917d4e
Compare
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
9e97d64
to
b30ddf6
Compare
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
b30ddf6
to
9d62e7c
Compare
pkg/storage/pluginstore/grpc.go
Outdated
if c == nil { | ||
c = []converter{ConvertFloatToInt} | ||
} |
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 don't think that it's possible for c to be nil here? If you call the function without passing any optional arguments the value is an empty array, not nil.
I noticed that in AsMap you always use the ConvertFloatToInt converter, even when they specify the optional custom converter parameter. Since you are passing c through to AsMap, I believe that this results in ConvertFloatToInt being used twice in AsMap when c is nil (which is never as I said above).
I'm pretty sure that you can delete these lines here and it will work exactly the same.
if c == nil { | |
c = []converter{ConvertFloatToInt} | |
} | |
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
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.
Just one thing to clear up and then this is ready to merge! 🚀
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.
🤞
What does this change
MongoDB expects to receive
bson.D
for$sort
and$group
in a aggregation pipeline.Prior to this PR, after the grpc server receives data from a client, it does not convert the data from []interface{} back to bson.D, which caused the query to fail.
This PR fixes this issue and adds tests to check for proper conversion.
What issue does it fix
Closes #2063
Notes for the reviewer
Put any questions or notes for the reviewer here.
Checklist
Reviewer Checklist