Open
Description
With the new versions of adminjs and adminjs-typeorm I see that child relation is duplicated when I'm editing the parent.
Here are my entities:
@Entity()
class Bill extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column('text', { nullable: true })
content: string;
@Column('jsonb', { nullable: true })
contentJson: string;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
@OneToMany(() => Document, (document) => document.bill, {
cascade: true,
eager: true,
})
documents: Document[];
@OneToOne(() => Proposable, { nullable: true, onDelete: 'SET NULL' })
@JoinColumn()
proposable?: Proposable;
}
@Entity()
class Document extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column('text')
content: string;
@Column('jsonb', { nullable: true })
contentJson: string;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
@ManyToOne(() => Bill, (bill) => bill.documents, { onDelete: 'CASCADE' })
bill: Bill;
@RelationId((document: Document) => document.bill)
billId: number;
@OneToOne(() => Proposable, { nullable: true, onDelete: 'SET NULL' })
@JoinColumn()
proposable?: Proposable;
}
Once editing Bill
entity with adminjs I see next:
- Documents are duplicated on each parent edit
- References of the old copies are set to null
- Only the last set of copies has reference to parent