-
Notifications
You must be signed in to change notification settings - Fork 2.1k
adapter-mariadb select json field fail #28143
Copy link
Copy link
Closed
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.topic: @prisma/adapter-mariadbtopic: JsonScalar type `Json`Scalar type `Json`topic: driverAdapterstopic: mariadbtopic: mysqltrackedThis issue is internally tracked by the Prisma Team on Linear.This issue is internally tracked by the Prisma Team on Linear.
Description
Bug description
When using JSON fields from $queryRawUnsafe an error is returned:
"Unsupported column type: LONG_BLOB"
or
"Cannot serialize value of type object as Bytes"
Severity
Reproduction
schema extract
model test_json {
id Int @id @default(autoincrement()) @db.UnsignedInt
data Json? @db.Json
}
fill a row with json data
Code
prisma.$queryRawUnsafe("SELECT data FROM test_json")
Expected vs. Actual Behavior
return rows with json field as text (like with rust engine) (or json object).
Frequency
Consistently reproducible
Does this occur in development or production?
Only in development (e.g., CLI tools, migrations, Prisma Studio)
Is this a regression?
Works with rust engine.
Breaks with client engine and PrismaMariaDb adapter.
Workaround
Keep rust engine.
Prisma Schema & Queries
model test_json {
id Int @id @default(autoincrement()) @db.UnsignedInt
data Json? @db.Json
}prisma.$queryRawUnsafe("SELECT data FROM test_json")//With full table creation and insert:
await db.$executeRaw`DROP TABLE IF EXISTS _test_json`;
await db.$executeRaw`CREATE TABLE _test_json(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,data JSON DEFAULT NULL);`;
await db.$executeRaw`INSERT INTO _test_json(data) VALUES ('{"long":"0123456789"}'),('{"long":"0123456789"}');`;
const testJson=await db.$queryRaw`SELECT id, data FROM _test_json`;Prisma Config
// Add your `prisma.config.ts`Logs & Debug Info
prisma:query DROP TABLE IF EXISTS _test_json
prisma:query CREATE TABLE _test_json(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,data JSON DEFAULT NULL);
prisma:query INSERT INTO _test_json(data) VALUES ('{"long":"0123456789"}'),('{"long":"0123456789"}');
prisma:query SELECT id, data FROM _test_json
prisma:error Cannot serialize value of type object as Bytes
Environment & Setup
- Database: MariaDB
Prisma Version
// Prisma version output
prisma@6.16.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.topic: @prisma/adapter-mariadbtopic: JsonScalar type `Json`Scalar type `Json`topic: driverAdapterstopic: mariadbtopic: mysqltrackedThis issue is internally tracked by the Prisma Team on Linear.This issue is internally tracked by the Prisma Team on Linear.