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

Unable to run queries against multi-level abstract classes #3745

Closed
parisholley opened this issue Nov 15, 2022 · 0 comments
Closed

Unable to run queries against multi-level abstract classes #3745

parisholley opened this issue Nov 15, 2022 · 0 comments

Comments

@parisholley
Copy link
Contributor

Describe the bug
Given the following model:

abstract class BaseMikro {
  @PrimaryKey({ type: 'bigint' })
  id!: string;
}

@Entity({ discriminatorColumn: 'type', abstract: true })
abstract class LevelOne extends BaseMikro {
  @Property({ type: 'int' })
  type!: number;
}

@Entity({ abstract: true })
abstract class LevelTwo extends LevelOne {
  @PrimaryKey({ type: 'bigint' })
  id!: string;

  @Property()
  name!: string;
}

@Entity({ discriminatorValue: 1 })
export class LevelThree extends LevelTwo {
  @PrimaryKey({ type: 'bigint' })
  id!: string;

  @Property()
  name!: string;
}

Doing a find like so

orm.em.find(LevelTwo, {});

Stack trace

    MetadataError: Metadata for entity LevelTwo not found

      211 |
      212 |   static missingMetadata(entity: string): MetadataError {
    > 213 |     return new MetadataError(`Metadata for entity ${entity} not found`);
          |            ^
      214 |   }
      215 |
      216 |   static conflictingPropertyName(className: string, name: string, embeddedName: string): MetadataError {

      at Function.missingMetadata (packages/core/src/errors.ts:213:12)
      at MetadataStorage.get (packages/core/src/metadata/MetadataStorage.ts:78:27)
      at SqlEntityManager.tryFlush (packages/core/src/EntityManager.ts:991:30)
      at SqlEntityManager.find (packages/core/src/EntityManager.ts:115:14)
      at Object.<anonymous> (tests/issues/GH3743.test.ts:49:16)
@parisholley parisholley changed the title Unable to run queries against multi-level abstract glasses Unable to run queries against multi-level abstract classes Nov 15, 2022
parisholley added a commit to parisholley/mikro-orm that referenced this issue Nov 15, 2022
@B4nan B4nan closed this as completed in 0c56118 Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant