SQLite Query
My Drizzle + TypeScript + SQLite (better-sqlite-3) fails on
updateItemStatementQuery.run()
. Why is that? I have updated my fields to contain double quotes with ''
as suggested before from a previous help thread.3 Replies
I am using coalesce so it either takes the value in
${}
if it's non-null value, being the string value, or the second value which is the current value for no update if it's undefined
i also tried without the double ` and ' quoteswhat is the error?
There's a couple observations, that might not be related to your issue
You don't need to prepare the query if you're not reusing it
You don't need to wrap coalesce with quote
'
You don't need to set the type of the sql, because you are not selecting, drizzle is just ignoring those types sql<string>
If complete is a boolean, I think that's where it might be giving you problems, SQLite doesn't have boolean values
If complete
is a boolean, that database update is going to fail. Booleans are probably save to the database as numbers 0 ir 1. Make sure complete is a number if you are using sql like thisThe error is
complete is a boolean. this is my schema for the table
I tried each set field separately.
and
both fail and give that same error
In the schema the exported inferred type still has it as a boolean
Inspecting type Item
type Item = {
id: string;
rowVersion: number;
lastModified: Date;
listID: string;
title: string;
complete: boolean;
ord: number;
}
So how do I have complete be inserted as a boolean to satisfiy the typescript types but insert it as a number to satisfy SQLite taking booleans as integers?