Error in POST function: NeonDbError: value too long for type character varying(200)
This is what I am trying to do:
const chat_id = await db.insert(chats).values({ fileKey: file_key, pdfname: file_name, pdfUrl: getfileurl(file_key), userId, }) .returning({ insertedId: chats.id }); and this is my schema export const chats = pgTable('chats', { id: serial('id').primaryKey(), pdfname : text('pdf_name').notNull(), pdfUrl : text('pdf_url').notNull(), createdAt : timestamp('created_at').notNull().defaultNow(), userId: text('user_id').notNull(), fileKey : text('file_key').notNull(), }); what should I do to fix this?
const chat_id = await db.insert(chats).values({ fileKey: file_key, pdfname: file_name, pdfUrl: getfileurl(file_key), userId, }) .returning({ insertedId: chats.id }); and this is my schema export const chats = pgTable('chats', { id: serial('id').primaryKey(), pdfname : text('pdf_name').notNull(), pdfUrl : text('pdf_url').notNull(), createdAt : timestamp('created_at').notNull().defaultNow(), userId: text('user_id').notNull(), fileKey : text('file_key').notNull(), }); what should I do to fix this?
7 Replies
clever-tan•2y ago
Hey! This is Stephen from twitter
genetic-orangeOP•2y ago
Hi! I am sarthak
clever-tan•2y ago
Is the userid field set to 200 length?
genetic-orangeOP•2y ago
I just chaged that also to text to check iff that's the problem but it doesnt seem like it
it was previously set to 255 length
clever-tan•2y ago
And if you log out the fields before insert , there aren’t any that are longer than expected?
genetic-orangeOP•2y ago
yes as per example there
Length of file_key: 34
Length of file_name: 26
clever-tan•2y ago
hmm, can you verify the table structure. Just to make sure that types are set.
something like -
or using
\d <table-name> from psql
Just following up here - we were able to get this resolved offline. The userid was longer than expected and violating the column length.