bitwalker / exprotobuf

Protocol Buffers in Elixir made easy!
Apache License 2.0
486 stars 69 forks source link

Incorrect decode same item #102

Closed marinakr closed 5 years ago

marinakr commented 5 years ago
payload =
        ProtoItem.encode(
          %ProtoItem{
            status: :DONE,
            owner: item.owner,
            title: item.title,
            description: "elixir CRUD protobuffs",
            id: item.id
          }
          |> IO.inspect(label: 0)
        )

      ProtoItem.decode(payload) |> IO.inspect(label: -1)

Output:

0: %Protobuf.Definitions.Todo.Item{
  description: "elixir CRUD protobuffs",
  id: "ce2de1af-ccdd-4102-8696-f8efdf246566",
  owner: "2575df6d-e02b-4a24-a062-59e7836cb6b4",
  status: :DONE,
  title: "test task"
}
-1: %Protobuf.Definitions.Todo.Item{
  description: "ce2de1af-ccdd-4102-8696-f8efdf246566",
  id: nil,
  owner: "2575df6d-e02b-4a24-a062-59e7836cb6b4",
  status: :IN_PROCESS,
  title: "test task"
}

My proto file:

package todo;
message Item {
  enum Status {
    TODO = 0;
    IN_PROCESS = 1;
    PENDING = 2;
    DONE = 1;
  }
  required Status status = 1;
  required string owner = 2;
  required string title = 3;
  optional string description = 4;
  optional string id = 4;
}
marinakr commented 5 years ago

My fail, protofile contain description and id same code 4, same with statuses Find it only after posting this issue