sqlite DEFAULT is not JSON-encoded

When using text("...", { mode: "json" }) with .default(), the default value is not JSON encoded leading to invalid SQL generation by drizzle-kit.

import { sqliteTable, text } from "drizzle-orm/sqlite-core";

export const table = sqliteTable("table", {
    row: text("row", { mode: "json" }).$type<string>().default("")
})

generates:
CREATE TABLE `table` (
    `row` text DEFAULT ''
);

(should be '""' instead)

Using an empty array .$type<string[]>().default([]) generates nothing:
CREATE TABLE `table` (
    `row` text DEFAULT 
);

(should be '[]')
Was this page helpful?