I've been developing a dashboard application using Prisma, Next.js, and supabase.
Recently, I encountered an issue when making a GET request. Prisma throws an error mentioning a column EventChart.åå
, with a strange alphabet "åå" that I haven't used anywhere in my code.
This is the specific error message:
PrismaClientKnownRequestError:
Invalid `prisma.eventChart.findMany()` invocation:
The column `EventChart.åå` does not exist in the current database.
at ai.handleRequestError (/Users/name/Desktop/unien-dashboard-app/unien-dashboard/dashboard/node_modules/@prisma/client/runtime/library.js:126:6775)
at ai.handleAndLogRequestError (/Users/name/Desktop/unien-dashboard-app/unien-dashboard/dashboard/node_modules/@prisma/client/runtime/library.js:126:6109)
at ai.request (/Users/name/Desktop/unien-dashboard-app/unien-dashboard/dashboard/node_modules/@prisma/client/runtime/library.js:126:5817)
at async l (/Users/name/Desktop/unien-dashboard-app/unien-dashboard/dashboard/node_modules/@prisma/client/runtime/library.js:131:9709)
at async GET (webpack-internal:///(rsc)/./app/api/eventChart/route.ts:18:27)
at async /Users/name/Desktop/unien-dashboard-app/unien-dashboard/dashboard/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:63251 {
code: 'P2022',
clientVersion: '5.9.1',
meta: { modelName: 'EventChart', column: 'EventChart.å\x8F\x82å\x8A' }
}
Snippet from route.ts file:
import { NextResponse } from "next/server"
import { main } from "../route"
import { PrismaClient } from "@prisma/client"
const prisma = new PrismaClient
export const GET = async (req: Request, res: NextResponse ) => {
try {
await main()
const eventData = await prisma.eventChart.findMany({
select: {
date: true,
userId: true,
actual: true,
expected: true,
}
})
return NextResponse.json({ message: "Success", eventData }, {status: 200})
} catch (err) {
console.error('Error in GET method:', err);
return NextResponse.json({ message: "Error", err }, {status: 500})
} finally {
await prisma.$disconnect()
}
}
Excerpt from schema.prisma:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
username String @unique
password String
email String
fees Fee?
eventChart EventChart[]
eventAreaChart EventAreaChart[]
memberChart MemberChart[]
task Task[]
event Event[]
}
...
Trying to fetch data:
"use client" ... <h1>Attempts Made:</h1> <p>・When I removed the <code>actual
andexpected
columns, the GET method worked as expected.import { NextResponse } from "next/server" import { main } from "../route" import { PrismaClient } from "@prisma/client" const prisma = new PrismaClient export const GET = async (req: Request, res: NextResponse ) => { try { await main() const eventData = await prisma.eventChart.findMany({ select: { date: true, userId: true, // actual: true, // expected: true, } }) return NextResponse.json({ message: "Success", eventData }, {status: 200}) } catch (err) { console.error('Error in GET method:', err); return NextResponse.json({ message: "Error", err }, {status: 500}) } finally { await prisma.$disconnect() } }
・I tried renaming the problematic columns following Prisma's documentation, which had resolved a similar issue with another model but was unsuccessful this time.
I've spent a week troubleshooting this problem without any progress, so I would greatly appreciate any assistance or insights you can provide. Thank you!