Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
enricodk opened this issue Nov 9, 2020 · 1 comment

Comments

@enricodk
Copy link

enricodk commented Nov 9, 2020

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 "" })
@slagyr
Copy link

slagyr commented Nov 1, 2023

Thanks for the report. This helped us figure out that the bug persists in v2.1.2. To compensate we rename values fields in the proto file, and then rename the generated code back to values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants