fuwaneko / node-protobuf

Google Protocol Buffers wrapper for Node.js [UNMAINTAINED]
179 stars 42 forks source link

Fixed null optional strings serialized to "null" #32

Closed elaberge closed 10 years ago

elaberge commented 10 years ago

node-protobuf currently serializes null strings as "null". I think this is error prone and a better solution would be to ignore such a field.

Unfortunately (unless I am mistaken), protobuf does not have a semantic for null values, making this solution only valid for optional fields.

This fix does not handle required fields. I suppose the correct behaviour would be to throw an exception in case a required field is set to null.

elaberge commented 10 years ago

I created bug #33 in reference to the null required fields behaviour. I only use optional fields, so the current fix is enough for me.

fuwaneko commented 10 years ago

Thank you, that's clearly a bug, null values on optional fields should not be serialized as of current protobuf version. There's a reference here: https://code.google.com/p/protobuf/issues/detail?id=57