Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drizzle-orm/src/bun-sql/postgres/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class BunSQLPreparedQuery<T extends PreparedQueryConfig, TIsRqbV2 extends
});

return await this.queryWithCache(query, params, async () => {
return client.unsafe(query, params as any[]).values();
return await client.unsafe(query, params as any[]).values();
});
});

Expand Down
19 changes: 12 additions & 7 deletions drizzle-orm/src/pg-core/async/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,26 @@ export abstract class PgAsyncPreparedQuery<T extends PreparedQueryConfig> extend
: { type: 'skip' as const };

if (cacheStrat.type === 'skip') {
return query().catch((e) => {
try {
return await query();
} catch (e) {
throw new DrizzleQueryError(queryString, params, e as Error);
});
}
}

const cache = this.cache!;

// For mutate queries, we should query the database, wait for a response, and then perform invalidation
if (cacheStrat.type === 'invalidate') {
return Promise.all([
query(),
cache.onMutate({ tables: cacheStrat.tables }),
]).then((res) => res[0]).catch((e) => {
try {
const [result] = await Promise.all([
query(),
cache.onMutate({ tables: cacheStrat.tables }),
]);
return result;
} catch (e) {
throw new DrizzleQueryError(queryString, params, e as Error);
});
}
}

if (cacheStrat.type === 'try') {
Expand Down