#10918·Prisma

`Json` defaults not parsed correctly (MariaDB)

Author: Jarco-devCreated Jan 2, 2022Updated Sep 29, 2026
Labelsbug/1-unconfirmedkind/bugtech/enginestopic: Jsontopic: mariadbtopic: mysqltopic: defaulttopic: broken migrations

Bug description

When trying to set a deafult in a json field it will output the deafult in the migration.sql file with out ' and thus it will throw an error when trying to migrate because mysql doesn't know what to do with the deafult value this also only seems to be a problem as of 3.7.0 because in 3.6.0 it was working as expected for me

How to reproduce

  1. Create a model with a Json field that has a deafult value (either array or object both is broken)
  2. Run prisma migrate dev --name test
  3. The error will be thrown

Expected behavior

I expect it to create a migration and migrate successfully applying the defaults in the process

Prisma information

My models that use the json field with defaults

model Members {
  id           Int           @id @default(autoincrement())
  guild        String        @db.VarChar(19)
  inviter      String?       @db.VarChar(19)
  user         String        @db.VarChar(19)
  inviteCount  Json          @default("{\"regular\":0,\"left\":0,\"fake\":0,\"bonus\":0}")
  GuildConfigs GuildConfigs? @relation(fields: [guild], references: [guild])
}

model Suggestions {
  id           Int              @id @default(autoincrement())
  guild        String           @db.VarChar(19)
  channel      String           @db.VarChar(19)
  message      String           @db.VarChar(19)
  upVoters     Json             @default("[]")
  downVoters   Json             @default("[]")
  status       SuggestionStatus
  proposer     String           @db.VarChar(19)
  suggestion   String           @db.Text
  GuildConfigs GuildConfigs     @relation(fields: [guild], references: [guild])
}

Environment & setup

  • OS: Windows 10
  • Database: Mysql
  • Node.js version: 16.6.1

Prisma Version

prisma                  : 3.7.0
@prisma/client          : 3.7.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 8746e055198f517658c08a0c426c7eec87f5a85f (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli 8746e055198f517658c08a0c426c7eec87f5a85f (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core 8746e055198f517658c08a0c426c7eec87f5a85f (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt 8746e055198f517658c08a0c426c7eec87f5a85f (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : 8746e055198f517658c08a0c426c7eec87f5a85f
Studio                  : 0.445.0