Comments (6)
It doesn't work with proto3 semantics either.
from protoc-plugin.
Hi @lakshay2395. I'm sorry that you are running into trouble. Could you elaborate on what you are seeing? I know we use oneof in our production proto3 specifications, so its not clear to me what you are running into.
from protoc-plugin.
I'm seeing this issue (or a different but related issue?) as well in cases where a sub-message has no fields:
syntax = "proto3";
package test;
message A {
int32 i = 1;
}
message E {}
message M {
oneof oo {
A a = 1;
E b = 2;
}
int32 c = 3;
}
REPL session:
user=> (require '[protojure.protobuf :as pb] '[test :as t])
nil
user=> (test/pb->M (pb/->pb (test/new-M {:oo {:a {:i 1}} :c 1})))
#test.M-record{:oo {:a #test.A-record{:i 1}}, :c 1}
user=> (test/pb->M (pb/->pb (test/new-M {:oo {:b {}} :c 1})))
#test.M-record{:oo nil, :c 1}
It can be fixed by dropping this check. Perhaps there should be a flag on the fn so that the empty record can be serialized (for oneofs)? Or is there ever a reason to drop an empty record, even outside of oneof? It seems to me that there's a semantic difference between "this record is present with no fields" and "this record isn't present at all," but I'm not super familiar with protobuf in general--I just know it affects my use case.
EDIT: After doing more research I definitely think that dropping that check is the right behaviour. Proto3 says that the default value of a message is "not set," meaning that a message which has been set to {}
is not the default value and should not be elided. I'm currently using an alter-var-root
in my code that removes that when
, and everything appears to work properly on proto2.
from protoc-plugin.
I believe this is fixed with d402568
from protoc-plugin.
@ghaskins as far as I understand it this bug (or at least the part I posted about) is actually part of protojure/lib
and was not fixed by #54. That being said, I'll reopen the issue over there because that's probably a better place for it.
from protoc-plugin.
@sharrap apologies, that was my misunderstanding. And yes, moving it over there makes sense to me too.
from protoc-plugin.
Related Issues (20)
- Split client and server generation HOT 1
- Add support for --version switch
- Crash during compilation
- Support v1.1.x protojure-lib
- Support multiple .proto files declaring a common 'package'
- Output includes dependencies
- Support 'Any' type
- Oneof Fields with underscores not consistently rewritten with hiphens
- option go_package bug HOT 1
- Support proto3 "presence" feature HOT 2
- Missing fields in generated records when a message field is named "values" HOT 1
- Oneof convert-* field name collision
- Bug: Enum default values in proto2
- Problem to generated proto when has java_package on proto files. HOT 3
- Is there any generated function to revert from protobuf to edn? HOT 4
- Test configuration HOT 2
- Golang fork behavior problem HOT 7
- Why does the namespace require itself? HOT 7
- from edn to google.protobuf.struct
- Support for optional fields in proto3?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protoc-plugin.