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

Add support for map of scalar value types as/and hstore data type for PostgreSQL database #204

Open
AnPiakhota-Infoblox opened this issue Mar 12, 2021 · 0 comments

Comments

@AnPiakhota-Infoblox
Copy link
Contributor

protoc-gen-gorm generates nothing against map field in proto3 file. For example the next proto message

message Request {
  option (gorm.opts) = {
    ormable: true
    multi_account: true
    include: []
  };
  gorm.types.UUIDValue id = 1;
  map<string, string> data = 2;
}

is generated into

type RequestORM struct {
	AccountID string
	Id        *go_uuid1.UUID `gorm:"type:uuid"`
}

Map is omitted but could be stored as PostgreSQL hstore data type that stores sets of key/value pairs. Other scalar types could be supported as well as far as they could be properly converted to their string representation.

Although hstore itself is not implemented in protoc-gen-gorm but it shouldn't be difficult to add it similar to JSONValue type. GORM V1 supports it as well.

message Request {
  option (gorm.opts) = {
    ormable: true
    multi_account: true
    include: []
  };
  gorm.types.UUIDValue id = 1;
  gorm.types.JSONValue config = 2;
  gorm.types.Hstore headers = 3;
}
type RequestORM struct {
  Config          *postgres.Jsonb    `gorm:"type:jsonb"`
  Headers         *postgres.Hstore   `gorm:"type:hstore"`
}
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

1 participant