TLDR: changed name of a field in spec after serializing; the deserialized object still has the same value, so it's all good; but are they any side effects I should be aware of?
I have a flatbuffer spec defined in a .fbs
file. I serialize my object into a flatbuffer defined by this spec.
Now, I change the name of one field in a table. Say I change "foo" to "bar"
I deserialize the flatbuffer into my programming language's object.
I find that the same value that was insert for the field foo
is now the value for bar
.
This is the behavior I want. It's my understanding the values are determined based on the offset of the field so the actual name of the field should not matter.
However, I am wondering, are there any side-effect to what I have done?
Yes, you can totally change the name of a field. The only side effect is that you break the generated API: any callers will have to be changed to use the new name.
Your question is also answered in https://google.github.io/flatbuffers/flatbuffers_guide_writing_schema.html under "Schema evolution examples" along with others.