© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
3 replies
ShiroDev

sqlite DEFAULT is not JSON-encoded

When using
text("...", { mode: "json" })
text("...", { mode: "json" })
with
.default()
.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([])
.$type<string[]>().default([])
generates nothing:
CREATE TABLE `table` (
    `row` text DEFAULT 
);
CREATE TABLE `table` (
    `row` text DEFAULT 
);

(should be
'[]'
'[]'
)
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

SQLite json_each
Drizzle TeamDTDrizzle Team / help
3y ago
default to empty object for sqlite text field with JSON mode
Drizzle TeamDTDrizzle Team / help
2y ago
text mode json for sqlite Dq doesn't parse by default
Drizzle TeamDTDrizzle Team / help
2y ago
Default now time for sqlite?
Drizzle TeamDTDrizzle Team / help
3y ago