Tomer Moran
Tomer Moran
DTDrizzle Team
Created by Tomer Moran on 12/4/2023 in #help
DB operations don't execute when promise is not awaited
The following snippet will not actually execute the SQL update:
function setEmailVerifiedWithoutBlocking(id: string) {
// If you replace `void` by `await`, this works
void db.update(myTable).set({ emailVerified: true }).where(eq(myTable.id, id))
}
function setEmailVerifiedWithoutBlocking(id: string) {
// If you replace `void` by `await`, this works
void db.update(myTable).set({ emailVerified: true }).where(eq(myTable.id, id))
}
My understanding is that this is because the promise is not chained by then, catch, or finally. This has nothing to do with the DB schema nor with the presence of the void keyword in front of it. I understand that this is part of a feature because sometimes you may want to do toSQL or prepare, in which case we do not want to execute the operation immediately. However the above situation represents a legit use-case (running a DB operation without blocking the current function), and the result is almost certainly not intended behaviour. I am aware of work-arounds like chaining an empty .finally(() => {}) or calling .execute() explicitely, but I thought I'd report this bug anyways because it may affect others.
8 replies
DTDrizzle Team
Created by Tomer Moran on 6/11/2023 in #help
How to declare 1-to-0:1 relation between tables?
As the title says. The existing helper one seems to be for 1-to-1 relations. Thanks!
5 replies
DTDrizzle Team
Created by Tomer Moran on 6/4/2023 in #help
Support for relational queries with views
Hello! I was wondering if there are plans to add support for relational queries with views? I am not presently able to define relations on a view as it is expecting a table as the first argument. Thanks!
3 replies