Skip to content

Commit

Permalink
go.mod: bump github.com/hamba/avro/v2 from 2.19.0 to 2.21.1 (#1529)
Browse files Browse the repository at this point in the history
* go.mod: bump github.com/hamba/avro/v2 from 2.19.0 to 2.21.1

Bumps [github.com/hamba/avro/v2](https://github.com/hamba/avro) from 2.19.0 to 2.21.1.
- [Release notes](https://github.com/hamba/avro/releases)
- [Commits](hamba/avro@v2.19.0...v2.21.1)

---
updated-dependencies:
- dependency-name: github.com/hamba/avro/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* handle nullable union types

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Raúl Barroso <[email protected]>
Co-authored-by: Lovro Mažgon <[email protected]>
  • Loading branch information
3 people authored May 10, 2024
1 parent 00e1ec0 commit 0408984
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1
github.com/hamba/avro/v2 v2.19.0
github.com/hamba/avro/v2 v2.21.1
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-plugin v1.6.0
github.com/jackc/pgx/v5 v5.5.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Rep
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/hamba/avro/v2 v2.19.0 h1:jITwvb03UMLfTFHFKdvaMyU/G96iVWS5EiMsqo3flfE=
github.com/hamba/avro/v2 v2.19.0/go.mod h1:72DkWmMmAyZA+qHoI89u4RMCQ3X54vpEb1ap80iCIBg=
github.com/hamba/avro/v2 v2.21.1 h1:400/jTdLWQ3ib58y83VXlTJKijRouYQszY1SO0cMGt4=
github.com/hamba/avro/v2 v2.21.1/go.mod h1:ouJ4PkiAEP49u0lAtQyd5Gv04MehKj+7lXwD3zpLpY0=
github.com/hanwen/go-fuse v1.0.0/go.mod h1:unqXarDXqzAk0rt98O2tVndEPIpUgLD9+rwFisZH3Ok=
github.com/hanwen/go-fuse/v2 v2.1.0/go.mod h1:oRyA5eK+pvJyv5otpO/DgccS8y/RvYMaO00GgRLGryc=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestSchema_MarshalUnmarshal(t *testing.T) {
)),
}, {
name: "boolean ptr (nil)",
haveValue: func() *bool { return nil }(),
haveValue: (*bool)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
Expand All @@ -63,56 +63,276 @@ func TestSchema_MarshalUnmarshal(t *testing.T) {
haveValue: int(1),
wantValue: int(1),
wantSchema: avro.NewPrimitiveSchema(avro.Int, nil),
}, {
name: "int ptr (0)",
haveValue: func() *int { var v int; return &v }(),
wantValue: 0, // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int ptr (nil)",
haveValue: (*int)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int64",
haveValue: int64(1),
wantValue: int64(1),
wantSchema: avro.NewPrimitiveSchema(avro.Long, nil),
}, {
name: "int64 ptr (0)",
haveValue: func() *int64 { var v int64; return &v }(),
wantValue: int64(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Long, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int64 ptr (nil)",
haveValue: (*int64)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Long, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int32",
haveValue: int32(1),
wantValue: int(1),
wantSchema: avro.NewPrimitiveSchema(avro.Int, nil),
}, {
name: "int32 ptr (0)",
haveValue: func() *int32 { var v int32; return &v }(),
wantValue: int(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int32 ptr (nil)",
haveValue: (*int32)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int16",
haveValue: int16(1),
wantValue: int(1),
wantSchema: avro.NewPrimitiveSchema(avro.Int, nil),
}, {
name: "int16 ptr (0)",
haveValue: func() *int16 { var v int16; return &v }(),
wantValue: int(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int16 ptr (nil)",
haveValue: (*int16)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int8",
haveValue: int8(1),
wantValue: int(1),
wantSchema: avro.NewPrimitiveSchema(avro.Int, nil),
}, {
name: "int8 ptr (0)",
haveValue: func() *int8 { var v int8; return &v }(),
wantValue: int(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "int8 ptr (nil)",
haveValue: (*int8)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "uint32",
haveValue: uint32(1),
wantValue: int64(1),
wantSchema: avro.NewPrimitiveSchema(avro.Long, nil),
}, {
name: "uint32 ptr (0)",
haveValue: func() *uint32 { var v uint32; return &v }(),
wantValue: int64(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Long, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "uint32 ptr (nil)",
haveValue: (*uint32)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Long, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "uint16",
haveValue: uint16(1),
wantValue: int(1),
wantSchema: avro.NewPrimitiveSchema(avro.Int, nil),
}, {
name: "uint16 ptr (0)",
haveValue: func() *uint16 { var v uint16; return &v }(),
wantValue: int(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "uint16 ptr (nil)",
haveValue: (*uint16)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "uint8",
haveValue: uint8(1),
wantValue: int(1),
wantSchema: avro.NewPrimitiveSchema(avro.Int, nil),
}, {
name: "uint8 ptr (0)",
haveValue: func() *uint8 { var v uint8; return &v }(),
wantValue: int(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "uint8 ptr (nil)",
haveValue: (*uint8)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Int, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "float64",
haveValue: float64(1),
wantValue: float64(1),
wantSchema: avro.NewPrimitiveSchema(avro.Double, nil),
}, {
name: "float64 ptr (0)",
haveValue: func() *float64 { var v float64; return &v }(),
wantValue: float64(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Double, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "float64 ptr (nil)",
haveValue: (*float64)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Double, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "float32",
haveValue: float32(1),
wantValue: float32(1),
wantSchema: avro.NewPrimitiveSchema(avro.Float, nil),
}, {
name: "float32 ptr (0)",
haveValue: func() *float32 { var v float32; return &v }(),
wantValue: float32(0), // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Float, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "float32 ptr (nil)",
haveValue: (*float32)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.Float, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "string",
haveValue: "1",
wantValue: "1",
wantSchema: avro.NewPrimitiveSchema(avro.String, nil),
}, {
name: "string ptr (empty)",
haveValue: func() *string { var v string; return &v }(),
wantValue: "", // ptr is unmarshalled into value
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.String, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "string ptr (nil)",
haveValue: (*string)(nil),
wantValue: nil, // when unmarshaling we get an untyped nil
wantSchema: must(avro.NewUnionSchema(
[]avro.Schema{
avro.NewPrimitiveSchema(avro.String, nil),
avro.NewPrimitiveSchema(avro.Null, nil),
},
)),
}, {
name: "[]byte",
haveValue: []byte{1, 2, 3},
Expand Down Expand Up @@ -152,7 +372,7 @@ func TestSchema_MarshalUnmarshal(t *testing.T) {
}, {
name: "[]any (no data)",
haveValue: []any{},
wantValue: []any{},
wantValue: []any(nil), // TODO: smells like a bug, should be []any{}
wantSchema: avro.NewArraySchema(must(avro.NewUnionSchema( // empty slice values default to nullable strings
[]avro.Schema{
avro.NewPrimitiveSchema(avro.String, nil),
Expand Down
Loading

0 comments on commit 0408984

Please sign in to comment.