A transaction issue
未关闭
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 13.7k
- 派生
- 1.1k
- PR 合并指标
- 30 天内没有已合并 PR
描述
I just found I can't do a transaction.
LOG: 'BEGIN', []
LOG: 'INSERT OR IGNORE INTO device_model (device_sn) VALUES (?);', ['abcdefg']
LOG: 'COMMIT', []
LOG: 'executeSql error -> ', 'cannot commit - no transaction is active'
My table.
CREATE TABLE IF NOT EXISTS device_model(device_sn TEXT PRIMARY KEY ON CONFLICT REPLACE NOT NULL, status TEXT, properties TEXT);
SqliteObject class
export class SQLiteObject {
private _objectInstance;
constructor() {
this._objectInstance = new SQL.Database();
}
public executeSql(statement: string, params: any): Promise<any> {
return new Promise((resolve, reject) => {
try {
console.log(statement, params);
const st = this._objectInstance.prepare(statement, params);
const rows: Array<any> = [];
while (st.step()) {
let row = st.getAsObject();
rows.push(row);
}
st.free();
const payload = {
rows: {
item: function (i) {
return rows[i];
},
length: rows.length
},
rowsAffected: this._objectInstance.getRowsModified() || 0,
insertId: this._objectInstance.insertId || void 0
};
resolve(payload);
} catch (e) {
console.log('executeSql error -> ', e.message);
reject(e);
}
});
}
}
Did I do something wrong?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
The reported entry point is SQLiteObject.executeSql, using SQL.Database; start by reproducing the logged BEGIN, INSERT OR IGNORE, and COMMIT sequence. Compare the transaction behavior with the SQLite table definition and determine the expected handling of the no-active-transaction error; done means the reported sequence has a clear, verified outcome.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, sqlite
- 领域
- database
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100