Search code examples
node.jsormprisma

error code p2032 using prisma orm on sql db


hey im usuing prisma 3.14 and after changing one property of my schema from int to string i receive that error

throw new PrismaClientKnownRequestError(message, e.code, this.client.\_clientVersion, e.meta);

PrismaClientKnownRequestError:
Invalid `prisma.models.findMany()` invocation in


export const getAllModels = async () => {const resUnparsed = await prisma.models.findMany(

Error converting field "campaign_id" of expected non-nullable type "String", found incompatible value of "9156".
at Object.request (/home/shay/nbo-mvp/backend/node_modules/@prisma/client/insait/runtime/index.js:45405:15)

at async PrismaClient.\_request (/home/shay/nbo-mvp/backend/node_modules/@prisma/client/insait/runtime/index.js:46301:18) {
code: 'P2032',

clientVersion: '3.14.0',

meta: { field: 'campaign_id', expected_type: 'String', found: '9156' }

im not sure how to approach it since prisma documentation does not have this error code


Solution

  • It looks like your field campaign_id field is stored as an integer in the database, while you specified a String in your prisma.schema. You can check that by making a query directly in the db (e.g. in Postgresql):

    select pg_typeof( campaign_id ) from your_table;
    

    You might need to migrate first:

    npx run prisma migrate dev 
    

    Which will tell you in case of desynchronization