objectbox-go icon indicating copy to clipboard operation
objectbox-go copied to clipboard

Complex fields / structs not working as documented (Golang Example)

Open head1328 opened this issue 5 months ago • 1 comments
trafficstars

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:

  1. 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
    }
    
    
  2. Execute go generate ./...

head1328 avatar Jun 15 '25 08:06 head1328

Thanks for reporting! We'll try to verify this once there is time.

greenrobot-team avatar Jun 16 '25 05:06 greenrobot-team

@gigabaitkajiutec74 Please avoid asking for updates, we will provide them when we have them. Reading and answering comments like this take time away from actually working on tasks.

greenrobot-team avatar Jun 30 '25 04:06 greenrobot-team