diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-06-17 16:51:34 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-06-17 16:51:34 +0200 |
| commit | 9b0122bdcd5603746c2ec59d360d6dee1494ca7c (patch) | |
| tree | afc0e8230fbc7e856a900c9309ea13c0fbb3e5be /columnar/columnar_test.go | |
| parent | 86e4094f8f31a1266ada670ab48599b55fb2c61c (diff) | |
| download | go-gg-9b0122bdcd5603746c2ec59d360d6dee1494ca7c.tar.gz | |
columnar: fix handling of json:"-" fields
Diffstat (limited to 'columnar/columnar_test.go')
| -rw-r--r-- | columnar/columnar_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/columnar/columnar_test.go b/columnar/columnar_test.go index 17dc964..70e27c4 100644 --- a/columnar/columnar_test.go +++ b/columnar/columnar_test.go @@ -116,3 +116,23 @@ func TestJSONUnmarshalFromInconsistentLengths(t *testing.T) { err := json.Unmarshal([]byte(`{"Foo":[1,2],"Bar":[3,4,5]}`), PointerTo(columnar.List[Record]{})) AssertEqual(t, err.Error(), `cannot unmarshal from columns with inconsistent lengths [2 3]`) } + +func TestIgnoredFields(t *testing.T) { + type Record struct { + Foo int `json:"foo"` + Bonus int `json:"-"` + } + + // There used to be a bug where columnar got confused that the `Bonus` field + // ends up as a zero-length array after unmarshaling. + testSuccessfulJSONRoundtrip(t, + []Record{ + {Foo: 1, Bonus: 0}, + {Foo: 2, Bonus: 0}, + {Foo: 3, Bonus: 0}, + }, + jsonmatch.Object{ + "foo": jsonmatch.Array{1, 2, 3}, + }, + ) +} |
