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
Undefined metadata when persisting a collection #3180
Comments
I changed the metadata provider to:
and it now works. Strange that the |
You should pass a POJO to em.create, not entity instance. |
actually not, its coming from validation of required properties, your @ManyToOne(() => Task)
task?: Task; I will add better error handling around this, you should get a "missing metadata error" instead. ts-morph works fine because it extracts the target entity name from TS compiler API directly. your entity definition is missing many things, like |
Hi. Thanks for the response. That makes sense. Also, on the topic of em.create, I'm actually having some trouble understanding what should happen here. Originally I had:
but doing this i get this error:
so i started doing the .create but looking at the docs it should be totally fine for me to just persist the entity class no? |
You are using different class than the one that was discovered, exactly as that error says. How does your config look like? Do you set the |
this is what i have in my config:
moreover it looks like entity is discovered fine:
|
yes it is, but its not the same class as you use in your code. maybe you import it from dist or something like that? |
ah i see what's happening. the entity that is discovered is actually from how do i make it discover from |
you can force that via |
it should be detected automatically, how do you run your app? |
using so should i have a different config for prod and testing? and in prod it should automatically pick up the |
using |
|
i am using
|
yes, thats quite old version, upgrade and it should work automatically, you need 27.0.4+ i guess |
ah that did it! works now even without the tsnode config thanks so much @B4nan |
Describe the bug
A clear and concise description of what the bug is.
Stack trace
To Reproduce
Steps to reproduce the behavior:
I have two entities:
and
when i try to persist a new Execution entity:
I get the above error.
Expected behavior
I expect the flush to go thru.
Additional context
https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/entity/ArrayCollection.ts#L170
seems like this is the LoC that's breaking.
Also this is being run inside a nestJS service using "@mikro-orm/nestjs": "^5.0.1".
Running it on debug mode shows all the entities being discovered properly.
Versions
The text was updated successfully, but these errors were encountered: