Description
The documentation example under “Complex fields / structs” (https://golang.objectbox.io/entity-annotations#complex-fields-structs) doesn’t work as shown. When embedding inline structs without their own ID field, the ObjectBox code generation fails, complaining that the inline struct has “no property recognized as an ID”. It seems every embedded struct also needs an ID.
Basic info
- ObjectBox version v1.9.0 (go) and v4.0.0 (generator)
- Reproducibility: always
- Device: Desktop
- OS: Debian Bookworm
- Runtime: mcr.microsoft.com/devcontainers/go:1.24-bookworm
How to reproduce
Steps to reproduce the behavior:
-
Create a Go struct that embeds another struct without its own ID, e.g.:
package model
//go:generate go run github.com/objectbox/objectbox-go/cmd/objectbox-gogen
type Metadata struct {
Name string
Info string
}
type Task struct {
ID uint64 `objectbox:"id"`
Title string
Metadata Metadata
}
-
Execute go generate ./...
Description
The documentation example under “Complex fields / structs” (https://golang.objectbox.io/entity-annotations#complex-fields-structs) doesn’t work as shown. When embedding inline structs without their own
IDfield, the ObjectBox code generation fails, complaining that the inline struct has “no property recognized as an ID”. It seems every embedded struct also needs anID.Basic info
How to reproduce
Steps to reproduce the behavior:
Create a Go struct that embeds another struct without its own
ID, e.g.:Execute
go generate ./...