findUnique codemod does not work with variables names other than `prisma`
NMinhNguyen opened this issue · comments
Minh Nguyen commented
Describe the bug
The codemod expects the Prisma client to be called prisma
(
codemods/transforms/findUnique.ts
Line 11 in 708ff09
PrismaClient
instance is called anything else, e.g. client
. Ideally the codemod should trace the import and allow any variable name (identifier).
Before the codemod
import { PrismaClient } from '@prisma/client'
const client = new PrismaClient();
client.x.findOne({ where: { id: 'test' } });
After the codemod
import { PrismaClient } from '@prisma/client'
const client = new PrismaClient();
client.x.findOne({ where: { id: 'test' } });
Expected output
import { PrismaClient } from '@prisma/client'
const client = new PrismaClient();
client.x.findUnique({ where: { id: 'test' } });
Additional context
Add any other context about the problem here.
William Luke commented
Hey folks, this should now be supported in 0.7.0
.
I have also added the ability to pass in custom instance names (i.e --instanceNames=myClient
)
This is helpful when importing already instantiated clients.
import myClient from './myClient'
Please reopen if you are still having issues after upgrading