ShiroDev
ShiroDev
DTDrizzle Team
Created by ShiroDev on 1/14/2024 in #help
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("")
})
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 ''
);
CREATE TABLE `table` (
`row` text DEFAULT ''
);
(should be '""' instead) Using an empty array .$type<string[]>().default([]) generates nothing:
CREATE TABLE `table` (
`row` text DEFAULT
);
CREATE TABLE `table` (
`row` text DEFAULT
);
(should be '[]')
4 replies