Skip to content

Missing fields in generated records when a message field is named "values" #50

@enricodk

Description

@enricodk

In 0.9.3 when a Protocol Buffer message contains a field named: "values", all of the fields (except the "values" field) are missing in the generated code.

The message:

message A {
  string field1 = 1;
  string values = 2;
  string field3 = 3;
}

Produces:

(defrecord A-record [values]
  pb/Writer
  (serialize [this os]
    (serdes.core/write-String 2  {:optimize true} (:values this) os))
  pb/TypeReflection
  (gettype [this]
    "com.example.ab.A"))

(s/def :com.example.ab.A/values string?)
(s/def ::A-spec (s/keys :opt-un [:com.example.ab.A/values ]))
(def A-defaults {:values "" })

A similar message containing a field named: "values2"

message B {
  string field1 = 1;
  string values2 = 2;
  string field3 = 3;
}

Produces the correct record

(defrecord B-record [field1 values2 field3]
  pb/Writer
  (serialize [this os]
    (serdes.core/write-String 1  {:optimize true} (:field1 this) os)
    (serdes.core/write-String 2  {:optimize true} (:values2 this) os)
    (serdes.core/write-String 3  {:optimize true} (:field3 this) os))
  pb/TypeReflection
  (gettype [this]
    "com.example.ab.B"))

(s/def :com.example.ab.B/field1 string?)
(s/def :com.example.ab.B/values2 string?)
(s/def :com.example.ab.B/field3 string?)
(s/def ::B-spec (s/keys :opt-un [:com.example.ab.B/field1 :com.example.ab.B/values2 :com.example.ab.B/field3 ]))
(def B-defaults {:field1 "" :values2 "" :field3 "" })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions