-
-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
Description
When updating a jsonb column to include a string with newlines I get the error: SyntaxError: Bad control character in string literal in JSON
Env
"dependencies": {
"drizzle-kit": "^0.31.7",
"drizzle-orm": "^0.44.7",
"pg": "^8.16.3",
"tsx": "^4.20.6"
},
"devDependencies": {
"@types/pg": "^8.15.6"
}
Drizzle Schema
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';
import { jsonb, pgTable, varchar } from 'drizzle-orm/pg-core';
import { eq, sql } from 'drizzle-orm';
const testTable = pgTable('jsonb_test', {
id: varchar('id', { length: 256 }).notNull().primaryKey(),
jsonbColumn: jsonb('jsonb_column').$type<{ test: string }>(),
});
Example
// succeeds
await db.insert(testTable).values({
id: 'test',
jsonbColumn: { test: 'value\n' },
});
// fails
await db.update(testTable).set({
jsonbColumn: { test: 'value\n' },
}).where(eq(testTable.id, 'test')).returning();