You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Because the SDK uses value types instead of pointer types for type Resource.(Db|Collection) users of the SDK will not be able to send empty strings for fields such as collection or db as they will be fully omitted when serialized to JSON.
Working with pointer values and structs can be fairly frustrating because you can't directly set a &"" in a struct without first assigning "" to a variable.
The aws-sdk-go gets around this by providing a function that takes a string and returns a pointer (aws.String)
I've wondered why they do that for the longest time and now I know :D
Describe the bug
Because the SDK uses value types instead of pointer types for
type Resource.(Db|Collection)
users of the SDK will not be able to send empty strings for fields such ascollection
ordb
as they will be fully omitted when serialized to JSON.I've put together an example in "The Go Playground" to demonstrate the issue: https://play.golang.org/p/OHNEv_7HIcc
Expected behavior
If I set
Resource.Collection = ""
I should have"collection": ""
in the JSON output.Logs
https://play.golang.org/p/OHNEv_7HIcc
Desktop (please complete the following information):
Additional context
This should be an issue everywhere the SDK is being used. For example, I think it will be an issue here in the terraform provider:
https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/mongodbatlas/resource_mongodbatlas_custom_db_role.go#L118
The text was updated successfully, but these errors were encountered: