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.

98 lines (76 loc) 1.99 kB
import { Entity, MikroORM, PrimaryKey, Property, t } from '@mikro-orm/mysql'; @Entity() export class Asset1 { @PrimaryKey({ columnType: 'bigint' }) id!: bigint; @Property() name!: string; } @Entity() export class Asset2 { @PrimaryKey({ type: 'bigint' }) id!: bigint; @Property() name!: string; } @Entity() export class Asset3 { @PrimaryKey({ type: t.bigint }) id!: bigint; @Property() name!: string; } test('bigint in mysql 1/3', async () => { const orm = await MikroORM.init({ dbName: `mikro_orm_test_gh_3739`, port: 3308, entities: [Asset1], }); await orm.schema.refreshDatabase(); const a1 = orm.em.create(Asset1, { name: 'foo', }); const a2 = orm.em.create(Asset1, { id: 90071992547409923n, name: 'foo', }); await orm.em.flush(); expect(typeof a1.id).toBe('bigint'); const a3 = await orm.em.fork().findOneOrFail(Asset1, a1); expect(typeof a3.id).toBe('bigint'); const a4 = await orm.em.fork().findOneOrFail(Asset1, a2); expect(typeof a4.id).toBe('bigint'); await orm.close(true); }); test('bigint in mysql 2/3', async () => { const orm = await MikroORM.init({ dbName: `mikro_orm_test_gh_3739`, port: 3308, entities: [Asset2], }); await orm.schema.refreshDatabase(); const a1 = orm.em.create(Asset2, { name: 'foo', }); await orm.em.flush(); expect(typeof a1.id).toBe('bigint'); const a2 = await orm.em.fork().findOneOrFail(Asset2, a1); expect(typeof a2.id).toBe('bigint'); await orm.close(true); }); test('bigint in mysql 3/3', async () => { const orm = await MikroORM.init({ dbName: `mikro_orm_test_gh_3739`, port: 3308, entities: [Asset3], }); await orm.schema.refreshDatabase(); const a1 = orm.em.create(Asset3, { name: 'foo', }); await orm.em.flush(); expect(typeof a1.id).toBe('bigint'); const a2 = await orm.em.fork().findOneOrFail(Asset3, a1); expect(typeof a2.id).toBe('bigint'); await orm.close(true); });