Skip to content

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

Open
@head1328

Description

@head1328

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 ./...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions