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

Discriminator conflict reported even for non-inherited tables #2984

Closed
amaranth opened this issue Oct 24, 2018 · 0 comments · Fixed by #2985
Closed

Discriminator conflict reported even for non-inherited tables #2984

amaranth opened this issue Oct 24, 2018 · 0 comments · Fixed by #2985

Comments

@amaranth
Copy link
Contributor

Issue type:

[ ] question
[X] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[X] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[X] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

If you have two entity classes with the same name and one of them uses @TableInheritance TypeORM will check to see if other entities have the same discriminator and fail because the other class does. However, as this other class is just a plain entity the conflict shouldn't matter, they don't have any effect on each other.

entities/issue/note.ts:

@Entity({name: "issueNote"})
@TableInheritance({column: {type: "varchar", name: "type"}})
export class Note {

    @PrimaryGeneratedColumn()
    public id: number;

}

entities/commit/note.ts:

@Entity({name: "commitNote"})
export class Note {

    @PrimaryGeneratedColumn()
    public id: number;

}
Error: Entities Note and Note as equal discriminator values. Make sure their discriminator values are not equal using @DiscriminatorValue decorator.
    at EntityMetadataValidator.validate (/Users/travis/Projects/velocity/typeorm/src/metadata-builder/EntityMetadataValidator.ts:71:23)
amaranth added a commit to amaranth/typeorm that referenced this issue Oct 24, 2018
If an entity has the same discriminator value as one using
@TableInheritance this should be allowed as there is no way for them to
conflict. Fixes typeorm#2984.
amaranth added a commit to amaranth/typeorm that referenced this issue Oct 19, 2020
If an entity has the same discriminator value as one using
@TableInheritance this should be allowed as there is no way for them to
conflict. Fixes typeorm#2984.
imnotjames pushed a commit that referenced this issue Oct 20, 2020
If an entity has the same discriminator value as one using `TableInheritance` this should be allowed as 
there is no way for them to conflict.

This commit also fixes the discriminatorColumn 
check to check all the entities it should be
checking. Only the parent in an STI setup has the
"STI" inheritancePattern, the children just have the 
"entity-child" tableType. Before two children with 
the same discriminatorValue would be
(incorrectly) allowed as they'd never even get 
checked.

Fixes #2984
zaro pushed a commit to zaro/typeorm that referenced this issue Jan 12, 2021
…2985)

If an entity has the same discriminator value as one using `TableInheritance` this should be allowed as 
there is no way for them to conflict.

This commit also fixes the discriminatorColumn 
check to check all the entities it should be
checking. Only the parent in an STI setup has the
"STI" inheritancePattern, the children just have the 
"entity-child" tableType. Before two children with 
the same discriminatorValue would be
(incorrectly) allowed as they'd never even get 
checked.

Fixes typeorm#2984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants