diff --git a/src/__tests__/find/find-order-by.test.ts b/src/__tests__/find/find-order-by.test.ts index 08c17526..f5d1660a 100755 --- a/src/__tests__/find/find-order-by.test.ts +++ b/src/__tests__/find/find-order-by.test.ts @@ -28,18 +28,21 @@ describe('find', () => { warnings: null, password: 'password5', birthday: new Date(now - 1000000000200), + money: BigInt(2), }, { email: 'user4@company.com', warnings: 15, password: 'password4', birthday: new Date(now - 1000000000000), + money: BigInt(1), }, { email: 'user6@company.com', warnings: 15, password: 'password3', birthday: new Date(now - 1000000000100), + money: BigInt(3), }, ]; @@ -171,6 +174,20 @@ describe('find', () => { } }); + it('Should return ordered items based on bitints', async () => { + const mockUsers = await prismock.user.findMany({ + orderBy: { money: 'desc' }, + select: { money: true, email: true }, + }); + + const realUsers = await prisma.user.findMany({ + orderBy: { money: 'desc' }, + select: { money: true, email: true }, + }); + + expect(mockUsers).toEqual(realUsers); + }); + it('Should return ordered items based on string', async () => { const mockUsers = await prismock.user.findMany({ orderBy: { email: 'desc' }, diff --git a/src/lib/operations/find/find.ts b/src/lib/operations/find/find.ts index 3ecde1e5..61feb1e8 100755 --- a/src/lib/operations/find/find.ts +++ b/src/lib/operations/find/find.ts @@ -86,6 +86,10 @@ export function calculateOrder( weight = values[0] - values[1]; } + if (typeof values[0] === 'bigint' && typeof values[1] === 'bigint') { + weight = Number(values[0]) - Number(values[1]); + } + if (typeof values[0] === 'string' && typeof values[1] === 'string') { weight = values[0].localeCompare(values[1]); }