Skip to content

Commit

Permalink
move pragma journal mode setting to driver connection
Browse files Browse the repository at this point in the history
  • Loading branch information
imnotjames committed Sep 11, 2020
1 parent e721f32 commit 1801105
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/driver/sqlite/SqliteDriver.ts
Expand Up @@ -105,6 +105,10 @@ export class SqliteDriver extends AbstractSqliteDriver {
});
}

if (this.options.enableWAL) {
await run(`PRAGMA journal_mode = WAL;`);
}

// we need to enable foreign keys in sqlite to make sure all foreign key related features
// working properly. this also makes onDelete to work with sqlite.
await run(`PRAGMA foreign_keys = ON;`);
Expand Down
9 changes: 0 additions & 9 deletions src/driver/sqlite/SqliteQueryRunner.ts
Expand Up @@ -4,7 +4,6 @@ import {AbstractSqliteQueryRunner} from "../sqlite-abstract/AbstractSqliteQueryR
import {SqliteConnectionOptions} from "./SqliteConnectionOptions";
import {SqliteDriver} from "./SqliteDriver";
import {Broadcaster} from "../../subscriber/Broadcaster";
import {IsolationLevel} from "../types/IsolationLevel";

/**
* Runs queries on a single sqlite database connection.
Expand Down Expand Up @@ -81,12 +80,4 @@ export class SqliteQueryRunner extends AbstractSqliteQueryRunner {
await execute();
});
}

async startTransaction(isolationLevel?: IsolationLevel): Promise<void> {
if ((this.connection.options as SqliteConnectionOptions).enableWAL === true) {
await this.query("PRAGMA journal_mode = WAL");
}

return super.startTransaction(isolationLevel);
}
}

0 comments on commit 1801105

Please sign in to comment.