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
Fails to discover abstract classes through EntitySchema #4080
Comments
Looks more like a logging issue, or do you see something malfunctioning too, apart from the |
yes, when trying to run it in a full app it failed indicating that it could not locate either the BaseClass or the BaseInterface when I tried to access either of the concrete implementations or a separate class that references it.
On 02/28/2023 5:58 AM EST Martin Adámek ***@***.***> wrote:
Looks more like a logging issue, or do you see something malfunctioning too, apart from the undefined in your logs? The properties in the final metadata are correct, they include both id and name. Abstract classes won't have any metadata after discovery, it gets inlined to the implementing classes.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Ok, can you provide a reproduction that fails? As the one you provided works fine for me, I am able to create entities as well as query them. Sounds like you want to query by a base class, which is indeed not supported, as that does not make much sense, you need to query for a db table and a base class does not represent one. |
by adding the 2 lines below to the end of the "test" method i get the error shown at the bottom
code added to "test":
var entityManager = await pool.em.fork();
var queryResults = await entityManager.findOne(BaseClassSchema, 1);
output:
[info] MikroORM version: 5.6.12
[discovery] ORM entity discovery started, using ReflectMetadataProvider
[discovery] - processing entity undefined
[discovery] - processing entity DerivedClass
[discovery] - processing entity undefined
[discovery] - processing entity ImplementingClass
[discovery] - entity discovery finished, found 4 entities, took 10 ms
[info] MikroORM successfully connected to database community on ***@***.***:3306
[query] select 1 from information_schema.schemata where schema_name = 'community' [took 2 ms]
[query] show variables like 'auto_increment_increment' [took 11 ms]
***@***.***\core\errors.js:166
return new MetadataError(`Metadata for entity ${entity} not found`);
^
MetadataError: Metadata for entity undefined not found
at Function.missingMetadata ***@***.***\core\errors.js:166:16)
at MetadataStorage.get ***@***.***\core\metadata\MetadataStorage.js:54:42)
at SqlEntityManager.tryFlush ***@***.***\core\EntityManager.js:960:34)
at SqlEntityManager.findOne ***@***.***\core\EntityManager.js:305:18)
at test (C:\src\hf\test\dist\src\Test.js:59:44)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
entity: undefined
}
On 02/28/2023 8:44 AM EST Martin Adámek ***@***.***> wrote:
Ok, can you provide a reproduction that fails? As the one you provided works fine for me, I am able to create entities as well as query them.
Sounds like you want to query by a base class, which is indeed not supported, as that does not make much sense, you need to query for a db table and a base class does not represent one.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
As I already said above, you can't query by base class, that does not make any sense. |
consider:
class SomeOtherClass {
things: BaseClass[]
}
i would expect to be able to do that which would query the base class.
or more concretely, if I have Person that is a base for Employee and Manager I would expect to be able to query all instances of Person.
On 02/28/2023 10:17 AM EST Martin Adámek ***@***.***> wrote:
As I already said above, you can't query by base class, that does not make any sense.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Once again, this is not possible, you can't query by it, neither you can target it in a relation - as it does not represent any database table. |
Sounds like you want this: https://mikro-orm.io/docs/inheritance-mapping#single-table-inheritance |
Fails to discover abstract classes through EntitySchema (BaseClass and BaseInterface)
Stack trace
none
To Reproduce
the output is
Expected behavior
both BaseClass and BaseInterface should be discovered
Versions
The text was updated successfully, but these errors were encountered: