-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Open DB Flags and URI DB Name in SQLite (#9468)
* Add the open database flags for sqlite3. * Check for URI before trying to create the DB dir. * Spacing. * Add the sqlite open connection flags. * Spacing. Co-authored-by: Adrian Burlacu <adrian.burlacu@live.com>
- Loading branch information
1 parent
71efa8e
commit 73148c9
Showing
3 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import "reflect-metadata" | ||
import { expect } from "chai" | ||
import { DataSource } from "../../../src/data-source/DataSource" | ||
import { | ||
closeTestingConnections, | ||
createTestingConnections, | ||
reloadTestingDatabases, | ||
} from "../../utils/test-utils" | ||
const sqlite3 = require("sqlite3") | ||
|
||
describe("sqlite driver > file open flags", () => { | ||
let connections: DataSource[] | ||
before( | ||
async () => | ||
(connections = await createTestingConnections({ | ||
name: "file:./temp/sqlitedb-memory.db?mode=memory", | ||
entities: [], | ||
enabledDrivers: ["sqlite"], | ||
driverSpecific: { | ||
flags: | ||
sqlite3.OPEN_URI | | ||
sqlite3.OPEN_SHAREDCACHE | | ||
sqlite3.OPEN_READWRITE | | ||
sqlite3.OPEN_CREATE, | ||
}, | ||
})), | ||
) | ||
beforeEach(() => reloadTestingDatabases(connections)) | ||
after(() => closeTestingConnections(connections)) | ||
|
||
it("should open a DB with flags as expected", () => | ||
Promise.all( | ||
connections.map(async (connection) => { | ||
// if we come this far, test was successful as a connection was established | ||
const result = await connection.query("PRAGMA journal_mode") | ||
|
||
expect(result).to.eql([{ journal_mode: "wal" }]) | ||
}), | ||
)) | ||
}) |