flatbuffers
flatbuffers copied to clipboard
Deprecated-but-readable table fields?
I'm wondering if there's a way to have fields that are deprecated for writing, but still have read accessors available. We have a bunch of serialized objects where we would like to soft-migrate to the non-deprecated attributes, but would still like to read the old values if they exist.
Not off the top of my head. We could add an attribute to only deprecate the writing part.
I would take a PR for this if you are interested, not high enough on my list to do myself.
@dbaileychess Understandable, let me see if I can fit it in.
What would you think of the name readonly
for the attribute?
I think I would prefer deprecated_writes
or something, to indicate that the field is in progress to be deprecated
.
Or deprecated_readonly
would work.
I would also have the use for that feature!
Yes! Every time I reach for the deprecated
attribute, I find that something like this is what I actually need, since I must keep backwards compatibility. I usually end up just renaming the field foo_deprecated
to indicate that it's not supposed to be written, but it would be nice to have something like deprecated_readonly
or whatever so that it would be a compile error to write to it, even by accident.
I felt inspired, and made an attempt at an implementation. PR here: https://github.com/google/flatbuffers/pull/8192