Skip to content

🤨 Cannot manually insert type in discriminator column of parent entity class when using single table inheritance when creating instance of parent entity #9033

@AlfaHound

Description

@AlfaHound

Issue Description

Not sure if this is the intended behavior or not, but is it possible to directly just use the parent entity class when using STI and manually set the type? I have been trying to do bulk inserts with fake data by using the parent class, but the 'type' column gets overwritten with the parent entity class's name.

Steps to Reproduce

  1. Copy paste single table inheritance example from docs,
  2. Add column for type in the Content class
  3. Attempt to insert data into the Content table using querybuilder, or if you want to implement base entity, the create() method, with the type field set to any of the child entities.
  4. Inserts will work, but the results will have type column overwritten with "Content", regardless if it is input or not.

My Environment

Dependency Version
Operating System Windows 10
Node.js version 14.17.5
Typescript version 4.5.2
TypeORM version 0.3.6

Relevant Database Driver(s)

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 yes
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres no
react-native no
sap no
spanner no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

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

  • ✖️ Yes, I have the time, and I know how to start.
  • ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

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