-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.topic: broken migrationstopic: migratetopic: sqlite
Description
Bug description
Prisma generates invalid SQL when using the Json type with a default value.
Severity
Reproduction
- Create a
schema.prismawith the contents from the prisma schema section of this issue - Run
prisma db push - Receive the error shown in the logs section of this issue
Expected vs. Actual Behavior
I expected Prisma to add the default correctly (in quotes). Instead I got an error from SQLite because Prisma generated invalid SQL.
Frequency
Consistently reproducible
Does this occur in development or production?
Only in development (e.g., CLI tools, migrations, Prisma Studio)
Is this a regression?
It hasn't worked in a previous version, it has been broken since support for Json in SQLite was added
Workaround
Avoid using default values with the Json scalar
Prisma Schema & Queries
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
model A {
id Int @id @default(autoincrement())
b Json @default("{\"something\": true}")
}Logs & Debug Info
This is the result from running prisma db push
Environment variables loaded from .env
Prisma schema loaded from schema.prisma
Datasource "db": SQLite database "dev.db" at "file:./dev.db"
Error: SQLite database error
unrecognized token: "{" in CREATE TABLE "A" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"b" JSONB NOT NULL DEFAULT {"something": true}
) at offset 103
0: sql_schema_connector::apply_migration::migration_step
with step=CreateTable { table_id: TableId(0) }
at schema-engine/connectors/sql-schema-connector/src/apply_migration.rs:21
1: sql_schema_connector::apply_migration::apply_migration
at schema-engine/connectors/sql-schema-connector/src/apply_migration.rs:10
2: schema_core::state::SchemaPush
at schema-engine/core/src/state.rs:504
Environment & Setup
- OS: macOS
- Database: SQLite
- Node.js version: v22.13.1
Prisma Version
prisma : 6.4.1
@prisma/client : 6.4.1
Computed binaryTarget : darwin-arm64
Operating System : darwin
Architecture : arm64
Node.js : v22.13.1
TypeScript : 4.9.5
Query Engine (Node-API) : libquery-engine a9055b89e58b4b5bfb59600785423b1db3d0e75d (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine : schema-engine-cli a9055b89e58b4b5bfb59600785423b1db3d0e75d (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm : @prisma/prisma-schema-wasm 6.4.0-29.a9055b89e58b4b5bfb59600785423b1db3d0e75d
Default Engines Hash : a9055b89e58b4b5bfb59600785423b1db3d0e75d
Studio : 0.509.0
tuliren and alex-kinokontuliren
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.topic: broken migrationstopic: migratetopic: sqlite