2021-01-01 18:46:16 +02:00
|
|
|
const Transaction = require('../../../execution/transaction');
|
2020-12-30 16:13:35 +00:00
|
|
|
|
|
|
|
class Transaction_Sqlite extends Transaction {
|
|
|
|
begin(conn) {
|
|
|
|
// SQLite doesn't really support isolation levels, it is serializable by
|
|
|
|
// default and so we override it to ignore isolation level.
|
|
|
|
// There is a `PRAGMA read_uncommitted = true;`, but that's probably not
|
|
|
|
// what the user wants
|
|
|
|
if (this.isolationLevel) {
|
|
|
|
this.client.logger.warn(
|
|
|
|
'sqlite3 only supports serializable transactions, ignoring the isolation level param'
|
|
|
|
);
|
|
|
|
}
|
2023-03-29 04:59:05 -07:00
|
|
|
// SQLite infers read vs write transactions from the statement operation
|
|
|
|
// https://www.sqlite.org/lang_transaction.html#read_transactions_versus_write_transactions
|
|
|
|
if (this.readOnly) {
|
|
|
|
this.client.logger.warn(
|
|
|
|
'sqlite3 implicitly handles read vs write transactions'
|
|
|
|
);
|
|
|
|
}
|
2020-12-30 16:13:35 +00:00
|
|
|
return this.query(conn, 'BEGIN;');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Transaction_Sqlite;
|