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

Incorrect transformation for repeated non-nullable sub messages. #16

Open
ekhabarov opened this issue Feb 19, 2020 · 0 comments
Open

Incorrect transformation for repeated non-nullable sub messages. #16

ekhabarov opened this issue Feb 19, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@ekhabarov
Copy link
Contributor

Repo with an example https://github.com/ekhabarov/repeated

Reproducing steps

//service.proto
syntax = "proto3";

package mypackage;

option go_package = "pb";

import "protoc-gen-struct-transformer/options/annotations.proto";
import "protobuf/gogoproto/gogo.proto";

option (transformer.go_repo_package) = "repeated";
option (transformer.go_protobuf_package) = "pb";
option (transformer.go_models_file_path) = "models.go";

message Inner {
  option (transformer.go_struct) = "Inner";

  string text = 1;
}

message Outer {
  option (transformer.go_struct) = "Outer";

  int64 id = 1;
  repeated Inner inners = 2 [ (gogoproto.nullable) = false ]; // works correctly with option = true
}
//models.go
package repeated

type Inner struct {
	Text string
}

type Outer struct {
	ID     int
	Inners []Inner
}
  • Install necessary protoc plugins: protoc-gen-gogofaster, protoc-gen-struct-transformer
  • Run protoc
protoc \
  -I ${GOPATH}/src/github.com/bold-commerce \
  -I ${GOPATH}/src/github.com/gogo \
  -I . \
  --gogofaster_out=Mprotoc-gen-struct-transformer/options/annotations.proto=github.com/bold-commerce/protoc-gen-struct-transformer/options:./pb \
  --struct-transformer_out=package=transform,goimports=true:. ./service.proto
  • Build transform package.

Errors:

# github.com/ekhabarov/repeated/transform
./service_transformer.go:192:3: cannot use PbToInner(src.Inners, opts...) (type repeated.Inner) as type []repeated.Inner in field value
./service_transformer.go:192:24: cannot use src.Inners (type []pb.Inner) as type pb.Inner in argument to PbToInner
./service_transformer.go:261:3: cannot use InnerToPb(src.Inners, opts...) (type pb.Inner) as type []pb.Inner in field value
./service_transformer.go:261:24: cannot use src.Inners (type []repeated.Inner) as type repeated.Inner in argument to InnerToPb
@ekhabarov ekhabarov added the bug Something isn't working label Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant