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

Cannot disable cascading removal of related entity #915

Closed
ml1nk opened this issue Oct 12, 2020 · 0 comments
Closed

Cannot disable cascading removal of related entity #915

ml1nk opened this issue Oct 12, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ml1nk
Copy link
Contributor

ml1nk commented Oct 12, 2020

Describe the bug
There are two entities A and B. A is independent from B and B has only an OneToOne relation to A. As such B is the owner of the relation and the foreign Key is also the primary key of this entity. It does not seem possible to remove B without removing the related A, but it should be.

To Reproduce

@Entity()
export class A {
  @PrimaryKey()
  id!: integer
}
export class B {
  [PrimaryKeyType]: number
  @OneToOne({ primary: true })
  object!: CoreObjectEntity
}

The removal of B (orm.em.removeAndFlush) always triggers the removal of A.

Expected behavior
The removal of B (orm.em.removeAndFlush) leaves A alone.

Additional context
I tried different properties (orphanRemoval, cascade) of OneToOne and also switched to ManyToOne to get the expected behavior but none worked.

Versions

Dependency Version
node 14.13.1
typescript 4.0.3
mikro-orm 4.0.7
pg 8.4.1
@B4nan B4nan added the bug Something isn't working label Oct 12, 2020
@B4nan B4nan closed this as completed in 37415ce Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants