PrismaClientKnownRequestError not thrown for `The provided value for the column is too long for the column's type.`
See original GitHub issueBug description
In our application when we want to create a line myTable, we give a body with data. One attribute of the data does not respect the rule put in schema . We give an attribute with more than 20 characters in postgres database.
model MyTable {
// ...
myAttribute String @db.VarChar(20)
// ...
}
async (req: Request, res: Response, next: NextFunction): Promise<void> => {
try {
const myResult = await prisma.myTable.create({
data: {
...req.body,
},
});
res.json({ myResult });
} catch (error) {
next(error);
}
}
);
Then we have this log, but the catch block is not invoked
PrismaClientKnownRequestError:
Invalid `prisma.myTable.create()` invocation:
The provided value for the column is too long for the column's type. Column: (not available)
at cb (/home/site/wwwroot/node_modules/@prisma/client/runtime/index.js:38675:17) {
code: 'P2000',
clientVersion: '3.5.0',
meta: { column_name: '(not available)' }
}
We have the same issue with 3.10.0 version.
How to reproduce
Create a postgres database with a table with an attribut of type with a limit. Try to create a line in this table with a data attribut over the limit
Expected behavior
An error should bre throwed not just log
Prisma information
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
declare global {
// eslint-disable-next-line no-var
var prisma:
| PrismaClient<{ log: { emit: 'event'; level: 'query' }[] }, 'query', false>
| undefined;
}
export const prisma =
global.prisma ||
new PrismaClient({
log: [
// 'query', // uncomment for default query only logs
{ emit: 'event', level: 'query' },
],
});
Environment & setup
- OS:
- Database:
- Node.js version: NodeJs 14.17.4 Postgres 10.3 OS : MacOS / Linux
Prisma Version
3.10.0
3.5.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Error message reference - Prisma
Prisma Client throws a PrismaClientKnownRequestError exception if the query engine ... "The provided value for the column is too long for the column's...
Read more >Prisma failed queries don't return proper errors - Stack Overflow
For example PrismaClientKnownRequestError has code property, but PrismaClientValidationError does not and so on. Example:
Read more >Prisma | Orm-help - Linen
Question I am trying to update column names… Is there a way of pushing multiple items to… I want to build a simple...
Read more >How To Handle Prisma Unique Constraints with a Friendly Error
Often, your data model will have a unique constraint to prevent duplicate records. ... A Character has to have a unique name. No...
Read more >How to Build Netflix Clone with HTML,CSS and Javascript [Part 6]
In this video tutorial, we'll share How to Build Netflix Clone with HTML,CSS and Javascript [Part 6]. DO NOT MISS!!!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I fixed this on a MySQL DB by adding a @db.Text() identifier to the field on the Prisma schema. Looks like the basic string has a limit so this seems to fix it for now.
Thanks @siddharthsharma94! It helped!