objectbox-go
objectbox-go copied to clipboard
go generate fails due to missing entity
Reproducer here: https://github.com/jpeeler/objectbox-test
I don't understand the failure as Credential is present in the same file as Institution, which is clearly found.
Copied output from commit:
$ go generate
Generating ObjectBox bindings for main.go
2020/04/04 21:58:49 Notice: skipping unavailable (private) property wall found in MyInstitution.Institution.InstitutionStatus.ItemLogins.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property ext found in MyInstitution.Institution.InstitutionStatus.ItemLogins.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property loc found in MyInstitution.Institution.InstitutionStatus.ItemLogins.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property wall found in MyInstitution.Institution.InstitutionStatus.TransactionsUpdates.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property ext found in MyInstitution.Institution.InstitutionStatus.TransactionsUpdates.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property loc found in MyInstitution.Institution.InstitutionStatus.TransactionsUpdates.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property wall found in MyInstitution.Institution.InstitutionStatus.Auth.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property ext found in MyInstitution.Institution.InstitutionStatus.Auth.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property loc found in MyInstitution.Institution.InstitutionStatus.Auth.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property wall found in MyInstitution.Institution.InstitutionStatus.Balance.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property ext found in MyInstitution.Institution.InstitutionStatus.Balance.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property loc found in MyInstitution.Institution.InstitutionStatus.Balance.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property wall found in MyInstitution.Institution.InstitutionStatus.Identity.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property ext found in MyInstitution.Institution.InstitutionStatus.Identity.LastStatusChange
2020/04/04 21:58:49 Notice: skipping unavailable (private) property loc found in MyInstitution.Institution.InstitutionStatus.Identity.LastStatusChange
can't merge binding model information: entity named 'Credential' was not found
exit status 2
main.go:8: running "go": exit status 1```
So you're trying to save data from some 3rd party library. As expected, that library doesn't have the expected model annotations, namely the problem is with Institution.Credentials field:
type Institution struct {
Credentials []Credential `json:"credentials"`
...
}
type Credential struct {
Label string `json:"label"`
Name string `json:"name"`
Type string `json:"type"`
}
ObjectBox-Go thinks Institution.Credentials field is a many-to-many when creating the model for Institution but can't find the target entity Credential because it's not recognized as such (and cannot be, since it doesn't have a mandatory Id/ID field)
Could you explain what you're trying to achieve? What data do you want to store? How do you intend to read/query the data? We have done some custom handling of a pre-defined model here for EdgeX https://github.com/objectbox/edgex-objectbox/tree/fuji/internal/pkg/db/objectbox but that may be an overkill for your use-case
I had planned on storing MyInstitutions. I thought at a minimum I would be able to do a GetAll() to get the data (each institution) back. Ideally, the embedded part would be queryable. I was really only expecting that the embedding "trick" would work just for fields in Institution that are primitive DB types, nothing else.
Unfortunately, that's not gonna work without some custom handling similar to the EdgeX example I've linked above. We've opted for a better-safe-than-sorry approach in ObjectBox-Go of not skipping unknown fields but failing the generation altogether, with user being able to either fix the time or skip them explicitly by tagging with objectbox:"-".
Understood - if you want to close this issue since it's a "can't/won't fix", that's fine.
Hey @vaind , I am a somewhat newcomer in golang, and was going to try ObjectBox for our project, which heavily relies on 3rd party packages and their types to be stored. Did I get it right, that for such cases, ObjectBox is not a good option, because it is not easy/straightforward to store 3rd party types in the db, because we can't annotate them properly?