loopbackio / loopbackio/loopback-connector-sqlite3

Transaction types

Đang mở
#50 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

feature
Ngôn ngữ chính
JavaScript
Star
13
Fork
21
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used 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 --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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với lib/transaction.js và so sánh cách xử lý transaction của nó với tài liệu về BEGIN ... TRANSACTION của SQLite. Kiểm tra connector xử lý DEFERRED, IMMEDIATE và EXCLUSIVE như thế nào, cũng như điều gì xảy ra với các giá trị isolation-level của LoopBack. Công việc hoàn tất khi các tùy chọn transaction được SQLite hỗ trợ được xử lý chính xác mà không sử dụng các tên isolation-level không được hỗ trợ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
database
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.