If I had some protobufs created with the following protobuf schema
message Foo {
Bar1 bar_1 = 1;
Bar2 bar_2 = 2;
}
but later on updated the protobuf schema to
message Foo {
oneof foo {
Bar1 bar_1 = 1;
Bar2 bar_2 = 2;
}
}
Will this second version be able to read the protos created with the first version?
>Solution :
Yes, the second version of the protobuf schema should be able to read protobufs created with the first version. When you update a protobuf schema, the changes you make only affect how new protobufs are encoded and decoded. Protobufs that were created with the previous version of the schema will still be encoded and decoded using the old schema. This means that the second version of the schema should still be able to read protobufs created with the first version, even though the schema has changed.
However, it is worth noting that when you make changes to a protobuf schema, you should take care to ensure that the changes are backward-compatible. This means that the new schema should still be able to read protobufs created with the old schema, without losing any information. In the example you provided, the change from the first version of the schema to the second is backward-compatible, so the second version should be able to read protobufs created with the first version. However, if you made a change that was not backward-compatible, the second version of the schema would not be able to read protobufs created with the first version.