Skip to content

Commit

Permalink
Send Drizzle transaction warning only once per session
Browse files Browse the repository at this point in the history
  • Loading branch information
DallasHoff committed Dec 31, 2024
1 parent 0f58ef1 commit 0a46b45
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/drizzle/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ export class SQLocalDrizzle extends SQLocal {
params: unknown[],
method: Sqlite3Method
): Promise<RawResultData> => {
if (/^begin\b/i.test(sql)) {
if (
/^begin\b/i.test(sql) &&
!sessionStorage._sqlocal_sent_drizzle_transaction_warning
) {
console.warn(
"Drizzle's transaction method cannot isolate transactions from outside queries. It is recommended to use the transaction method of SQLocalDrizzle instead (See https://sqlocal.dallashoffman.com/api/transaction#drizzle)."
);
sessionStorage._sqlocal_sent_drizzle_transaction_warning = '1';
}
return this.exec(sql, params, method);
};
Expand Down

0 comments on commit 0a46b45

Please sign in to comment.