loopbackio / loopbackio/loopback-connector-sqlite3
Transaction types
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 13
- 派生
- 21
- PR 合并指标
- 30 天内没有已合并 PR
描述
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).
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 lib/transaction.js 开始,将其事务处理与 SQLite 的 BEGIN ... TRANSACTION 文档进行比较。检查 connector 如何处理 DEFERRED、IMMEDIATE 和 EXCLUSIVE,以及 LoopBack 的隔离级别值会发生什么情况。当 SQLite 支持的事务选项得到正确处理,且不使用不受支持的隔离级别名称时,工作就完成了。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- database
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100