Search code examples
flatbuffers

Can I change deprecated field's type in flatbuffers?


Consider we have this fbs

include "/.../foo.fbs";

...

table Bar {
    foo:Foo (deprecated);
    message:SomeMessage;
}

root_type Bar;

Can I change foo's type to some bool, or maybe some empty table, without breaking backward compatibility? My goal here is to remove dependency from foo.fbs

Wrote a simple tool to serialize with old schema, and deserialize with new schema. Works fine, but still maybe there are some side effects of such manipulation


Solution

  • You can't change it to a bool as that is a type of a different size. Cleanest would be to simply make Foo an empty type rather than remove it, e.g. table Foo {}, though if you really must remove it, declaring foo:string (or any by reference / offset type) would also work, as long as it is never accessed.