We are trying to use Drizzle with SQLite. The drizzle schema is not the source of truth, so we are trying to introspect the DB and make minor tweaks if needed.
I noticed that BOOLEAN is introspected as numeric() by Drizzle. In SQLite, BOOLEAN is just syntactic sugar, but could that be used to infer number("column", { mode: "boolean" }) instead of numeric("column"). I believe numeric is actually the correct thing to convert to, according to Column Affinity though.
SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).
SQLite recognizes the keywords "TRUE" and "FALSE", as of version 3.23.0 (2018-04-02) but those keywords are really just alternative spellings for the integer literals 1 and 0 respectively.
active BOOLEAN NOT NULL
# Results in
active: numeric("active").notNull(),
After a quick play with Prisma, I noticed that they are introspecting BOOLEAN as a Prisma Boolean. Making it a lot easier to work with in your app logic. The issue with numeric is, anything is accepted.
Describe what you want
We are trying to use Drizzle with SQLite. The drizzle schema is not the source of truth, so we are trying to introspect the DB and make minor tweaks if needed.
I noticed that
BOOLEAN
is introspected asnumeric()
by Drizzle. In SQLite,BOOLEAN
is just syntactic sugar, but could that be used to infernumber("column", { mode: "boolean" })
instead ofnumeric("column")
. I believe numeric is actually the correct thing to convert to, according to Column Affinity though.https://www.sqlite.org/datatype3.html#boolean_datatype
After a quick play with Prisma, I noticed that they are introspecting
BOOLEAN
as a PrismaBoolean
. Making it a lot easier to work with in your app logic. The issue with numeric is, anything is accepted.