Open tvh opened 2 days ago
Hi @tvh thanks for the feedback, I am not sure whether we can solve this at our generator since the generator only has information about the current specification, it does not know, whether there is a previous version where the age property was placed at a different position. The only solution which I could image would be to build the integer based on the property name, through this the number would be stable and only changes if you also change the property name, maybe this would be better?
I think the only correct solution would be to add the tag to the typeschema model.
Deriving the number from the field name may work for most objects but will sometimes create conflicts. You only have ~500k numbers to choose from (see https://protobuf.dev/programming-guides/proto2/#assigning). That means collisions are relatively unlikely but far from impossible.
When serializing to protobuf, the binary protocol is not generated in a migration-safe manner. Say I do the following specs:
V1: typeschema:
protobuf:
V2 typeschema:
protobuf:
Now the
age
field change it's name and type, breaking the binary protocol.