Using default with `text` json mode creates empty `DEFAULT`

Hi all, entries: text('entries', { mode: 'json' }).$type<number[]>().default([]), results in
CREATE TABLE `User` (
`id` integer PRIMARY KEY NOT NULL,
`entries` text DEFAULT ,
`createdAt` integer DEFAULT CURRENT_TIMESTAMP,
`updatedAt` integer NOT NULL,
`lastSyncedAt` integer
);
CREATE TABLE `User` (
`id` integer PRIMARY KEY NOT NULL,
`entries` text DEFAULT ,
`createdAt` integer DEFAULT CURRENT_TIMESTAMP,
`updatedAt` integer NOT NULL,
`lastSyncedAt` integer
);
which then throws an error when i try to push to Turso. I suspect it's the empty entries default, when i remove all works fine. Is this expected or show i create a issue on github?
2 Replies
Mykhailo
Mykhailo10mo ago
Hello, @jpcafe! Try to update .default() with sql
// other columns
entries: text('entries', { mode: 'json' })
.$type<number[]>()
.default(sql`'[]'`),
// other columns
entries: text('entries', { mode: 'json' })
.$type<number[]>()
.default(sql`'[]'`),
jpcafe
jpcafeOP10mo ago
Ok thank you will try!
Want results from more Discord servers?
Add your server