mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Initializing an In-memory database queues doesn’t throw.
This commit is contained in:
1 parent
631f071589
commit
c2db2dc8d0
4 files changed
+16
-4
No files matched your search
@@ -13,7 +13,7 @@ class InMemoryDatabaseTests : GRDBTestCase
|
||||
{
|
||||
func testInMemoryDatabase() {
|
||||
assertNoError {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let dbQueue = DatabaseQueue()
|
||||
try dbQueue.inTransaction { db in
|
||||
try db.execute("CREATE TABLE foo (bar TEXT)")
|
||||
try db.execute("INSERT INTO foo (bar) VALUES ('baz')")
|
||||
|
||||
@@ -29,6 +29,10 @@ public class Database {
|
||||
}
|
||||
}
|
||||
|
||||
convenience init(configuration: Configuration) {
|
||||
try! self.init(path: ":memory:", configuration: configuration)
|
||||
}
|
||||
|
||||
deinit {
|
||||
if sqliteConnection != nil {
|
||||
sqlite3_close(sqliteConnection)
|
||||
|
||||
@@ -15,9 +15,17 @@ public class DatabaseQueue {
|
||||
static var databaseQueueIDKey = unsafeBitCast(DatabaseQueue.self, UnsafePointer<Void>.self)
|
||||
lazy var databaseQueueID: DatabaseQueueID = unsafeBitCast(self, DatabaseQueueID.self)
|
||||
|
||||
public init(path: String = ":memory:", configuration: Configuration = Configuration()) throws {
|
||||
public convenience init(path: String, configuration: Configuration = Configuration()) throws {
|
||||
try self.init(database: Database(path: path, configuration: configuration))
|
||||
}
|
||||
|
||||
public convenience init(configuration: Configuration = Configuration()) {
|
||||
self.init(database: Database(configuration: configuration))
|
||||
}
|
||||
|
||||
init(database: Database) {
|
||||
queue = dispatch_queue_create("GRDB", nil)
|
||||
_database = try Database(path: path, configuration: configuration)
|
||||
_database = database
|
||||
dispatch_queue_set_specific(queue, DatabaseQueue.databaseQueueIDKey, databaseQueueID, nil)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user