nickmazuk
nickmazuk
Explore posts from servers
DTDrizzle Team
Created by nickmazuk on 8/19/2023 in #help
Not equal with relational queries
Has anyone used ne with relational queries? When I use the callback syntax, I get the following type error:
where: (table, { ne }) => ne(table.name, "name")
^^ Property 'ne' does not exist on type { ... }
where: (table, { ne }) => ne(table.name, "name")
^^ Property 'ne' does not exist on type { ... }
4 replies
DTDrizzle Team
Created by nickmazuk on 8/13/2023 in #help
Invalid serialization of JSON blobs
Has anyone gotten default values of JSON blobs to work with SQLite? When I try using an empty array, the SQL migration does not have a default value (despite having the DEFAULT keyword).
array: blob("array", { mode: 'json' }).$type<string[]>().default([]).notNull()
array: blob("array", { mode: 'json' }).$type<string[]>().default([]).notNull()
`array` blob DEFAULT NOT NULL,
`array` blob DEFAULT NOT NULL,
If I use an object, the default value is the toString serialization: [object Object], not the JSON.stringify serialization.
object: blob("object", { mode: 'json' }).$type<{}>().default({}).notNull()
object: blob("object", { mode: 'json' }).$type<{}>().default({}).notNull()
`object` blob DEFAULT [object Object] NOT NULL,
`object` blob DEFAULT [object Object] NOT NULL,
I also posted an issue on GitHub since this seems like a bug, but asking here in case any of you have found a workaround. https://github.com/drizzle-team/drizzle-orm/issues/1036
1 replies
DTDrizzle Team
Created by nickmazuk on 8/12/2023 in #help
SQLite: timestamp vs timestamp_ms modes
The SQLite column types docs mention there's multiple modes for integers. What's the difference between timestamp_ms and timestamp modes?
import { integer, sqliteTable } from "drizzle-orm/sqlite-core";

// you can customize integer mode to be timestamp, timestamp_ms
integer('id', { mode: 'timestamp_ms' })
integer('id', { mode: 'timestamp' }) // Date
import { integer, sqliteTable } from "drizzle-orm/sqlite-core";

// you can customize integer mode to be timestamp, timestamp_ms
integer('id', { mode: 'timestamp_ms' })
integer('id', { mode: 'timestamp' }) // Date
My assumption is the following: - timestamp_ms: Stores the timestamp including the milliseconds. Same precision as Date.now(). Equivalent to TIMESTAMP in MySQL. - timestamp: Stores the date only. Same precision as 2023-08-09. Equivalent to DATE in MySQL. https://github.com/drizzle-team/drizzle-orm/discussions/1007
7 replies