protoc-gen-gorm icon indicating copy to clipboard operation
protoc-gen-gorm copied to clipboard

Regression in GormTag index and unique_index handling

Open pjediny opened this issue 3 years ago • 0 comments

This code from version v0.21.0 will never allow for index; tag to be generated:

	if len(tag.Index) > 0 {
		if tag.GetIndex() == "" {
			gormRes += "index;"
		} else {
			gormRes += fmt.Sprintf("index:%s;", tag.GetIndex())
		}
	}

Same holds for the unique_index;.

The code should allow encoding three states:

  • index without name
  • index with name
  • no index

Currently it only allows index with name and no index variants. This is regression from previous version (v0.20.1).

Looking into GormTag proto message definition, it looks like it is not using optional anymore.

pjediny avatar Jul 23 '21 12:07 pjediny