Giter VIP home page Giter VIP logo

Comments (6)

lakshay2395 avatar lakshay2395 commented on June 14, 2024

It doesn't work with proto3 semantics either.

from protoc-plugin.

ghaskins avatar ghaskins commented on June 14, 2024

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.

sharrap avatar sharrap commented on June 14, 2024

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.

ghaskins avatar ghaskins commented on June 14, 2024

I believe this is fixed with d402568

from protoc-plugin.

sharrap avatar sharrap commented on June 14, 2024

@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.

ghaskins avatar ghaskins commented on June 14, 2024

@sharrap apologies, that was my misunderstanding. And yes, moving it over there makes sense to me too.

from protoc-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.