loopbackio / loopbackio/loopback-connector-sqlite3

Transaction types

Offen
#50 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature
Vorherrschende Sprache
JavaScript
Sterne
13
Forks
21
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used [patch-package](https://github.com/ds300/patch-package) to patch `loopback-connector-sqlite3@3.0.0` for the project I'm working on.

The issue i'm facing is that loopback uses enum of isolation levels (below), which doesn't correspond to the sqlite3-supported list of transaction options.

The Loopback enum:
```
export declare enum IsolationLevel {
READ_COMMITTED = "READ COMMITTED",
READ_UNCOMMITTED = "READ UNCOMMITTED",
SERIALIZABLE = "SERIALIZABLE",
REPEATABLE_READ = "REPEATABLE READ"
}
```
Supported SQLITE3 `BEGIN ... TRANSACTION` is DEFERRED, IMMEDIATE and EXCLUSIVE (see https://www.sqlite.org/lang_transaction.html)

Here is the diff that solved my problem:

```diff
diff --git a/node_modules/loopback-connector-sqlite3/lib/transaction.js b/node_modules/loopback-connector-sqlite3/lib/transaction.js
index 580cc28..c348094 100644
--- a/node_modules/loopback-connector-sqlite3/lib/transaction.js
+++ b/node_modules/loopback-connector-sqlite3/lib/transaction.js
@@ -22,6 +24,9 @@ function mixinTransaction(SQLite3) {
cb = isolationLevel;
isolationLevel = 'DEFERRED';
}
+ if (!['DEFERRED', 'IMMEDIATE', 'EXCLUSIVE'].includes(isolationLevel)) {
+ isolationLevel = 'DEFERRED';
+ }

debug('Begin a transaction with isolation level: %s', isolationLevel);
this._getConnection(function(err, connection) {
```

This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit lib/transaction.js und vergleichen Sie die Transaktionsverarbeitung dort mit der Dokumentation von SQLite zu BEGIN ... TRANSACTION. Prüfen Sie, wie der Connector DEFERRED, IMMEDIATE und EXCLUSIVE behandelt und was bei den Isolationsstufenwerten von LoopBack passiert. Die Arbeit ist abgeschlossen, wenn von SQLite unterstützte Transaktionsoptionen korrekt behandelt werden, ohne nicht unterstützte Namen für Isolationsstufen zu verwenden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
database
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.