'Prisma - ConnectorError
I'm trying to learn Prisma on my hobby project so I started with basics. The first thing I tried was a simple GET request which should list all results in a table.
// Using "@prisma/client": "^3.8.1",
const position = await prisma.position.findMany();
It worked fine but obviously, I don't have any data so it return an empty array. If I try to add some items to the Position table I'm getting error (mentioned below). Same error I'm getting also from Prisma Studio so I wonder If I did something wrong or what can I do to fix it.
Prisma schema
model Position {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
externalId String @db.VarChar(255)
benefits String @db.Text()
}
MySQL Schema
CREATE TABLE `Position` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`externalId` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`benefits` text COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Query:
await prisma.position.create({
data: {
name: 'Position Name',
externalId: '321',
benefits: 'My benefits',
},
});
Error:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1064, message: "target: referral.-.primary: vttablet: (errno 1064) (sqlstate 42000) (CallerID: unsecure_grpc_client): Sql: \"insert into Position(`name`, externalId,
benefits) values (:v1, :v2, :v3)\", BindVars: {}", state: "42000" })) })
at cb (C:\Develop\referral-nextjs-prisma\node_modules\@prisma\client\runtime\index.js:38695:17)
at async assetHandler (webpack-internal:///./pages/api/position/index.tsx:12:34)
at async Object.apiResolver (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\api-utils.js:102:9)
at async DevServer.handleApiRequest (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\base-server.js:1076:9)
at async Object.fn (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\base-server.js:963:37)
at async Router.execute (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\router.js:222:32)
at async DevServer.run (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\base-server.js:1103:29)
at async DevServer.run (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\dev\next-dev-server.js:444:20)
at async DevServer.handleRequest (C:\Develop\referral-nextjs-prisma\node_modules\next\dist\server\base-server.js:319:20) {
clientVersion: '3.8.1'
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
