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

ximを使ったコードが有効にならない #80

Closed
54m opened this issue Aug 4, 2022 · 2 comments · Fixed by #99
Closed

ximを使ったコードが有効にならない #80

54m opened this issue Aug 4, 2022 · 2 comments · Fixed by #99
Assignees
Labels
bug Something isn't working

Comments

@54m
Copy link
Member

54m commented Aug 4, 2022

No description provided.

@54m 54m added the bug Something isn't working label Aug 4, 2022
@s-aska
Copy link
Contributor

s-aska commented Oct 12, 2022

動かない

Indexes           map[string]bool ``

動く

Indexes           map[string]bool `firestore:"indexes"`

原因

if e.RawTag == "" {
  ...
  continue
}

↑にひっかかって↓のブロックに処理が来ない

if rawKey == "" && e.RawName == "Indexes" && typeName == typeBoolMap {
	if err := g.parseIndexesField(tags); err != nil {
		return xerrors.Errorf("failed to parse indexes field: %w", err)
	}

	continue
}

https://github.com/go-generalize/volcago/blame/master/generator/structGenerator.go#L263-L275

@s-aska
Copy link
Contributor

s-aska commented Oct 12, 2022

https://github.com/go-generalize/volcago/blob/master/generator/templates/gen.go.tmpl#L1484

ここの {{ .FieldInfoForIndexes.FsTag }} が空になるんだけどそうすると

query = query.WherePath(firestore.FieldPath{"", key}, OpTypeEqual, true)

という感じのコードが生成されてしまう。

UniqueInfo は

ui := &UniqueInfo{
  Field: fieldInfo.Field,
  FsTag: func() string {
    ft := fieldInfo.Field
    if fsTagErr == nil {
      ft = strings.Split(fsTag.Value(), ",")[0]
    }
    if fsTagErr != nil || ft == "" {
      return fieldInfo.Field
    }
    return ft
  }(),
}

みたいに FsTag が関数になってて、こうなってると良い様子

@54m 54m assigned 54m and unassigned aerith Oct 12, 2022
54m added a commit that referenced this issue Oct 12, 2022
54m added a commit that referenced this issue Oct 12, 2022
@54m 54m closed this as completed in #99 Oct 12, 2022
54m added a commit that referenced this issue Oct 12, 2022
ximを使ったコードが有効にならない #80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants