-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encoding: Longs default value of 0 is not being set on the wire #639
Comments
In general anything set (either on the object or present in the json from which it is parsed) should be on the wire. |
I always assumed that such default values would ideally be excluded on the wire for efficiency, at least that's what I'd expect. Do you know if this is an official implementation detail or if it just happens that the Java lib does it this way? |
I guess it is official implementation detail based on both C++ and Java libraries (~8 years of exp now). I don't know about the other languages. |
With proto3 I presume you can make the argument that default values should be excluded. But I have definitely been used to the behavior of value being set in the proto2 world. |
Could you help get a release out with a fix for this issue. This is the last remaining issue with migrating our code-base. |
Sorry, have been busy fixing jsPerf today. On top of that, a fix for this would break a lot of stuff, as the entire default values on prototypes model is involved. Just using see - but this could be broken if defined checks are optimized away. |
I've now tested an implementation that uses |
Now testing an implementation using |
As a side-product, generated toObject implementations are super fast now using |
Works great! Now I need a new release and I push our new converted code base to QA! |
Released on npm. Feel free to reopen if there are any issues! |
@dcodeIO I am seeing more related issues. nulled/undefined string fields are being sent as empty strings. across the wire Version: 6.5.0 |
Reference: https://github.com/dcodeIO/protobuf.js/blob/master/src/encoder.js#L88 Might be the case for required fields, yeah. Should throw on |
These are not required fields, lets continue conversation here #652 |
protobuf.js version: master
Is this intended? If the field is set java proto2 library does not ignore defaults and sets it on the byte stream
The text was updated successfully, but these errors were encountered: