Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(query-builder): fix pagination when PK uses
BigIntType
Closes #4227
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Entity, LoadStrategy, OneToMany, ManyToOne, Collection, PrimaryKey, BigIntType } from '@mikro-orm/core'; | ||
import { MikroORM } from '@mikro-orm/postgresql'; | ||
|
||
@Entity() | ||
class BidEntity { | ||
|
||
@PrimaryKey({ type: BigIntType }) | ||
id!: string; | ||
|
||
@ManyToOne('ItemEntity', { | ||
serializer: value => value.id, | ||
serializedName: 'itemId', | ||
}) | ||
item: any; | ||
|
||
} | ||
|
||
@Entity() | ||
class ItemEntity { | ||
|
||
@PrimaryKey({ type: BigIntType }) | ||
id!: string; | ||
|
||
@OneToMany('BidEntity', 'item', { | ||
orphanRemoval: true, | ||
strategy: LoadStrategy.JOINED, | ||
mappedBy: 'item', | ||
}) | ||
bids = new Collection<BidEntity>(this); | ||
|
||
} | ||
|
||
let orm: MikroORM; | ||
|
||
beforeAll(async () => { | ||
orm = await MikroORM.init({ | ||
dbName: ':memory:', | ||
entities: [BidEntity, ItemEntity], | ||
}); | ||
await orm.schema.refreshDatabase(); | ||
}); | ||
|
||
afterAll(() => orm.close(true)); | ||
|
||
test('select big int', async () => { | ||
await orm.em | ||
.createQueryBuilder(ItemEntity, 'item') | ||
.select('*') | ||
.leftJoinAndSelect('item.bids', 'bids') | ||
.limit(10) | ||
.getResultAndCount(); | ||
}); |