A transaction issue
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 13.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
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.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, sqlite
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100