Skip to content

adapter-mariadb select json field fail #28143

@seralo

Description

@seralo

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

⚠️ Major: Breaks core functionality (e.g., migrations fail)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions