-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
TypeError: Cannot read property getInstanceProperties' of undefined #114
Comments
A possible solution (https://github.com/mikro-orm/mikro-orm/blob/master/lib/metadata/TypeScriptMetadataProvider.ts#L27): - const file = meta.path.match(/\/[^\/]+$/)[0].replace(/\.js$/, '.ts');
+ const file = meta.path.split(process.cwd())[1].replace(/\.js$/, '.ts'); That way |
Currently entity name has to be unique, but your approach is about having multiple entities in the |
@B4nan Yes. I'm structuring my project in modules, so that |
I don't think that is currently supported, it's definitely more complicated than your proposed change. ORM needs to be able to tell the entity name based on the file name and vice versa so it can find the TS source file for type sniffing via reflection. I would suggest to have each entity in dedicated file and then re-export them in your BTW you could also try to specify all types manually via |
In fact, the problem is bigger than what I thought. I'll follow your suggestion to have individual files with barrel export. I'll let you decide whether to close this issue or not as I don't know whether you'd be interested to ship this change with v3. |
I will add validation for such case so it will throw a bit more informative error about the requirement for unique file names in v3. Will close this once it's implemented. |
Validates that: - there can be only one entity with given class name - there are only well named entities (file name vs class name) - there was at least one discovered entity Closes #114
Validates that: - there can be only one entity with given class name - there are only well named entities (file name vs class name) - there was at least one discovered entity Closes #114
Validates that: - there can be only one entity with given class name - there are only well named entities (file name vs class name) - there was at least one discovered entity Closes #114
Closing as resolved. Available for testing via |
Try to create entities in files with same name but in different folders, like:
and you'll get the following error when initializing:
Investigating a bit, I found that TypeScriptMetadataProvider creates a map of source files keyed by the filename, causing some kind of conflict for the above mentioned case where multiple files have the same name but are on different folders.
The text was updated successfully, but these errors were encountered: