Skip to content

Commit

Permalink
fix(client): include promise properties in fluent api own properties (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Mar 14, 2022
1 parent a71a46c commit 755d81b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -72,6 +72,20 @@ describe('prismaPromise', () => {
expect(createResult1).toStrictEqual(createResult2)
})

test('fluent promises should have promise properties', async () => {
const findUniquePromise = prisma.user.findUnique({
where: {
email: 'email@email.em',
},
})

expect('then' in findUniquePromise).toBe(true)
expect('finally' in findUniquePromise).toBe(true)
expect('catch' in findUniquePromise).toBe(true)

await findUniquePromise.finally()
})

beforeAll(async () => {
const PrismaClient = await getTestClient()
prisma = new PrismaClient()
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/runtime/core/model/applyFluent.ts
Expand Up @@ -119,7 +119,7 @@ export function applyFluent(
// we allow for chaining more with this recursive call
return applyFluent(client, ...modelArgs, ...dataArgs)
},
...defaultProxyHandlers(ownKeys),
...defaultProxyHandlers([...ownKeys, ...Object.getOwnPropertyNames(prismaPromise)]),
})
}
}
Expand Down

0 comments on commit 755d81b

Please sign in to comment.