-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-2706] fix: Fix issue with SQLite transactions #5934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,12 @@ export class DBClass { | |
| this.sqlite3 = SQLite.Factory(m); | ||
| const vfs = await MyVFS.create("plane", m); | ||
| this.sqlite3.vfs_register(vfs, true); | ||
| const db = await this.sqlite3.open_v2(`${dbName}.sqlite3`); | ||
| const db = await this.sqlite3.open_v2( | ||
| `${dbName}.sqlite3`, | ||
| this.sqlite3.OPEN_READWRITE | this.sqlite3.OPEN_CREATE, | ||
| "plane" | ||
| ); | ||
|
|
||
| this.instance.db = db; | ||
| this.instance.exec = async (sql: string) => { | ||
| const rows: any[] = []; | ||
|
|
@@ -57,6 +62,8 @@ export class DBClass { | |
| } | ||
|
|
||
| async exec(props: string | TQueryProps) { | ||
| // @todo this will fail if the transaction is started any other way | ||
| // eg: BEGIN, OR BEGIN TRANSACTION | ||
|
Comment on lines
+65
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Transaction syntax limitations could cause failures. The code only handles "BEGIN;" but not other valid SQLite transaction start commands like "BEGIN TRANSACTION;" or "BEGIN". This limitation could lead to transaction deadlocks or failures, especially when transactions are nested. Consider updating the condition to handle all valid transaction start syntaxes: - if (props === "BEGIN;") {
+ if (typeof props === "string" &&
+ (props === "BEGIN;" ||
+ props === "BEGIN" ||
+ props === "BEGIN TRANSACTION;")) {
|
||
| if (props === "BEGIN;") { | ||
| let promiseToAwait; | ||
| if (this.tp.length > 0) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.