UNPKG

undeexcepturi

Version:

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.

39 lines (26 loc) 695 B
import { Collection, Entity, ManyToOne, MikroORM, OneToMany, PrimaryKey, Property } from '@mikro-orm/sqlite'; @Entity() export class A { @PrimaryKey() id!: number; @Property() prop!: string; @OneToMany(() => B, b => b) coll = new Collection<B>(this); } @Entity() export class B { @PrimaryKey() id!: number; @ManyToOne(() => A, { nullable: true }) a?: A; } describe('GH issue 2393', () => { test('cascade persist with pre-filled PK and with cycles', async () => { await expect(MikroORM.init({ entities: [A, B], dbName: ':memory:', connect: false, })).rejects.toThrow('A.coll has unknown \'mappedBy\' reference: B.undefined'); }); });