-
Notifications
You must be signed in to change notification settings - Fork 14
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
Encoding zero values as null #42
Comments
Alternatively, allow marshal transform func to return some marker error/value? |
So to recap, the matrix of transforms that seem potentially reasonable here are:
(Did I miss any?) So we currently have A1 and B2 by default, and B3 can be configured. We're missing the ability to configure A2 at all (and that seems wrong! It's possible A2 should be the default, really...); and we're missing B1. Yep. And we could also try to get B1 by making marshal transform funcs support returning a sentinel value that means null, and that seems also like it would be reasonable to support but also seems like the less general case. So then, thinking outloud, is
With just these parameters, some of the other combos like B2+A1 would be unreachable. Is that desirable? Or do we need more parameters for these behaviors? |
Well, this is the current default. It's also what go does by default. (Not sure if it should be but users will be confused if it isn't) One solution is to just define both There's actually another dimension here: tags. Without tags (and with #37) fixed, I could just write a pair of transform functions to/from Really, I'm starting to become more and more convinced that using either |
Another question came to mind: Do we want these behaviors to be specified at the site of fields (as omitempty is), or on types? |
Well, for my usecase, types. In general, for fields, I'd just specify |
Currently, refmt:
MyStruct{}
)However, there isn't a way to say "encode zero values to null" (the inverse of 1). This can be useful when we always want to have a field present in an object but would like to make it clear that the field is empty.
Specifically, this would be really useful for CIDs in IPLD. Users can currently specify "omitempty" but, if they fail to include this, encoding a zero-value CID will return an error. With some way to say "encode the zero value to null", this would "just work".
Proposal: Add a
Nullable(nullable bool)
option to the atlas entry builder.The text was updated successfully, but these errors were encountered: