Skip to content

Custom discriminator values when using Single Table Inheritance with Entity Schemas #10494

@gabrielkim13

Description

@gabrielkim13

Feature Description

Add an option to specify custom discriminator values for Single Table Inheritance (STI), on the EntitySchema class.

Currently, when using separate Entity definitions, the only possible values on the discriminator column is the name of the entity class.

The Solution

Add a discriminatorValue to EntitySchema props, which will be used as the discriminator value in place of the entity class name, when defined.

It can leverage the fact that this feature is already implemented using the @ChildEntity decorator by just adding a DiscriminatorValueMetadataArgs object to the MetadataArgsStorage when running EntitySchemaTransformer#transform.

Considered Alternatives

None, if one wishes to use the EntitySchema API while having custom discriminator values.

Currently, this is only possible via the @ChildEntity decorator API.

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions