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

go generate fails due to missing entity #23

Open
jpeeler opened this issue Apr 5, 2020 · 6 comments
Open

go generate fails due to missing entity #23

jpeeler opened this issue Apr 5, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@jpeeler
Copy link

jpeeler commented Apr 5, 2020

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```
@vaind
Copy link
Contributor

vaind commented Apr 6, 2020

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)

@vaind
Copy link
Contributor

vaind commented Apr 6, 2020

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

@jpeeler
Copy link
Author

jpeeler commented Apr 6, 2020

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.

@vaind
Copy link
Contributor

vaind commented Apr 14, 2020

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:"-".

@jpeeler
Copy link
Author

jpeeler commented Apr 14, 2020

Understood - if you want to close this issue since it's a "can't/won't fix", that's fine.

@vaind vaind added the enhancement New feature or request label Aug 25, 2020
@IvanBelyakoff
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants