elixir-protobuf / protobuf

A pure Elixir implementation of Google Protobuf.
https://hexdocs.pm/protobuf/readme.html
MIT License
823 stars 143 forks source link

Unable to handle recursive types #11

Closed ssboisen closed 7 years ago

ssboisen commented 7 years ago

Hi,

Excellent library!

I'm looking at writing a client for Google Cloud Bigtable but ran into problems when using new on one of the types generated by protobuf-elixir.

The problem occurs because of the type RowFilter includes a property of type Condition which again include properties of type RowFilter. See this data.proto spec.

When calling new on RowFilter or RowFilter.Condition the __default_struct__ function is invoked recursively forever.

I havn't investigated a solution to the problem too much yet but wanted to bring it to you guys attention as your obviously much better informed on what a solution might be.

Again, thanks for all the great work on protobuf-elixir and grpc

Best regards

Simon, Denmark

tony612 commented 7 years ago

Thank you for reporting. I have never thought of this problem. I'll look into this :)

tony612 commented 7 years ago

@ssboisen What's your protobuf-elixir version? This problem should be fixed in v0.4.1 before. And I added a test for the situation here https://github.com/tony612/protobuf-elixir/commit/2e674d5f502fd3bf3c8babd58069685366bdbca1, which I think can express your problem. btw, I noticed there's oneof in RowFilter and I implemented that on master. If convenient, can you try that?

ssboisen commented 7 years ago

Doh I were using [{:protobuf, "~> 0.3.1"}] which is from the README.md in this repo, I am able to create the message now, great!