© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
joostschuur

default to empty object for sqlite text field with JSON mode

How can I default a
mode: 'json'
mode: 'json'
text type to an empty object in sqlite?

The following in a
sqliteTable
sqliteTable
definition results in a literal string of
([object Object])
([object Object])
:

  data: text('data', { mode: 'json' }).notNull().default({}),
  data: text('data', { mode: 'json' }).notNull().default({}),


Empty arrays are discussed here, but not empty objects:

https://orm.drizzle.team/learn/guides/empty-array-default-value#sqlite

Using
default(sql
default(sql
'{}'
)
)
(with backticks around the single quotes, I can't get the to show up in Discord markdown) or
default('{}')
default('{}')
defaults it to a literal
'{}'
'{}'
, and querying that gives an error:

SyntaxError: Unexpected token ''', "'{}'" is not valid JSON
    at JSON.parse (<anonymous>)
    at SQLiteTextJson.mapFromDriverValue
SyntaxError: Unexpected token ''', "'{}'" is not valid JSON
    at JSON.parse (<anonymous>)
    at SQLiteTextJson.mapFromDriverValue


I'm using drizzle-orm": v0.30.9 and Turso/libsql.
Drizzle ORM - Empty array as a default value
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
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

Using default with `text` json mode creates empty `DEFAULT`
Drizzle TeamDTDrizzle Team / help
2y ago
text mode json for sqlite Dq doesn't parse by default
Drizzle TeamDTDrizzle Team / help
2y ago
Drizzle ORM HTTP SQlite proxy does not work with JSON mode text
Drizzle TeamDTDrizzle Team / help
6mo ago
createInsertSchema forgets .$type() on text json mode fields in sqlite
Drizzle TeamDTDrizzle Team / help
3y ago