Compare insertion performance with FMDB & SQLite.swift

This commit is contained in:
Gwendal Roué committed 2016-01-09 13:30:05 +01:00
1 parent 2483385c69
commit 9f0b7df490
14 files changed
+522 -438

No files matched your search

+3 -1
View File
@@ -18,7 +18,9 @@ class GRDBTestCase: XCTestCase {
super.setUp()
sqlQueries = []
databasePath = "/tmp/GRDB.sqlite"
let databaseFileName = "GRDBTestCase-\(NSProcessInfo.processInfo().globallyUniqueString).sqlite"
databasePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent(databaseFileName)
do { try NSFileManager.defaultManager().removeItemAtPath(databasePath) } catch { }
dbQueue = try! DatabaseQueue(path: databasePath, configuration: dbConfiguration)
}
@@ -1,102 +0,0 @@
import XCTest
class FMDBPerformanceTests: XCTestCase {
func testValueAtIndexPerformance() {
// Here we test the extraction of values by column index.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let dbQueue = FMDatabaseQueue(path: databasePath)
self.measureBlock {
dbQueue.inDatabase { db in
if let rs = db.executeQuery("SELECT * FROM items", withArgumentsInArray: nil) {
while rs.next() {
let _ = rs.longForColumnIndex(0)
let _ = rs.longForColumnIndex(1)
let _ = rs.longForColumnIndex(2)
let _ = rs.longForColumnIndex(3)
let _ = rs.longForColumnIndex(4)
let _ = rs.longForColumnIndex(5)
let _ = rs.longForColumnIndex(6)
let _ = rs.longForColumnIndex(7)
let _ = rs.longForColumnIndex(8)
let _ = rs.longForColumnIndex(9)
}
}
}
}
}
func testValueNamedPerformance() {
// Here we test the extraction of values by column name.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let dbQueue = FMDatabaseQueue(path: databasePath)
self.measureBlock {
dbQueue.inDatabase { db in
if let rs = db.executeQuery("SELECT * FROM items", withArgumentsInArray: nil) {
while rs.next() {
let _ = rs.longForColumn("i0")
let _ = rs.longForColumn("i1")
let _ = rs.longForColumn("i2")
let _ = rs.longForColumn("i3")
let _ = rs.longForColumn("i4")
let _ = rs.longForColumn("i5")
let _ = rs.longForColumn("i6")
let _ = rs.longForColumn("i7")
let _ = rs.longForColumn("i8")
let _ = rs.longForColumn("i9")
}
}
}
}
}
func testRecordPerformance() {
// Here we test the loading of an array of Records.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let dbQueue = FMDatabaseQueue(path: databasePath)
self.measureBlock {
var records = [PerformanceRecord]()
dbQueue.inDatabase { db in
if let rs = db.executeQuery("SELECT * FROM items", withArgumentsInArray: nil) {
while rs.next() {
let dictionary = rs.resultDictionary()
let record = PerformanceRecord(dictionary: dictionary)
records.append(record)
}
}
}
XCTAssertEqual(records[4].i2, 1)
XCTAssertEqual(records[4].i3, 0)
XCTAssertEqual(records[5].i2, 2)
XCTAssertEqual(records[5].i3, 1)
}
}
func testKeyValueCodingPerformance() {
// Here we test the loading of an array of KVC-based objects.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let dbQueue = FMDatabaseQueue(path: databasePath)
self.measureBlock {
var records = [PerformanceObjCRecord]()
dbQueue.inDatabase { db in
if let rs = db.executeQuery("SELECT * FROM items", withArgumentsInArray: nil) {
while rs.next() {
records.append(PerformanceObjCRecord(dictionary: rs.resultDictionary()))
}
}
}
XCTAssertEqual(records[4].i2!.intValue, 1)
XCTAssertEqual(records[4].i3!.intValue, 0)
XCTAssertEqual(records[5].i2!.intValue, 2)
XCTAssertEqual(records[5].i3!.intValue, 1)
}
}
}
@@ -0,0 +1,75 @@
import XCTest
import GRDB
import SQLite
/// Here we test the extraction of values by column name.
class FetchNamedValuesTests: XCTestCase {
func testFMDB() {
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let dbQueue = FMDatabaseQueue(path: databasePath)
self.measureBlock {
dbQueue.inDatabase { db in
if let rs = db.executeQuery("SELECT * FROM items", withArgumentsInArray: nil) {
while rs.next() {
let _ = rs.longForColumn("i0")
let _ = rs.longForColumn("i1")
let _ = rs.longForColumn("i2")
let _ = rs.longForColumn("i3")
let _ = rs.longForColumn("i4")
let _ = rs.longForColumn("i5")
let _ = rs.longForColumn("i6")
let _ = rs.longForColumn("i7")
let _ = rs.longForColumn("i8")
let _ = rs.longForColumn("i9")
}
}
}
}
}
func testGRDB() {
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let dbQueue = try! DatabaseQueue(path: databasePath)
measureBlock {
dbQueue.inDatabase { db in
for row in Row.fetch(db, "SELECT * FROM items") {
let _: Int = row.value(named: "i0")
let _: Int = row.value(named: "i1")
let _: Int = row.value(named: "i2")
let _: Int = row.value(named: "i3")
let _: Int = row.value(named: "i4")
let _: Int = row.value(named: "i5")
let _: Int = row.value(named: "i6")
let _: Int = row.value(named: "i7")
let _: Int = row.value(named: "i8")
let _: Int = row.value(named: "i9")
}
}
}
}
func testSQLiteSwift() {
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let db = try! Connection(databasePath)
// Column access by name requires query builder (unlike extraction of values by column index).
self.measureBlock {
for item in db.prepare(itemsTable) {
let _ = item[i0Column]
let _ = item[i1Column]
let _ = item[i2Column]
let _ = item[i3Column]
let _ = item[i4Column]
let _ = item[i5Column]
let _ = item[i6Column]
let _ = item[i7Column]
let _ = item[i8Column]
let _ = item[i9Column]
}
}
}
}
@@ -0,0 +1,76 @@
import XCTest
import GRDB
import SQLite
/// Here we test the extraction of values by column index.
class FetchPositionalValuesTests: XCTestCase {
func testFMDB() {
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let dbQueue = FMDatabaseQueue(path: databasePath)
self.measureBlock {
dbQueue.inDatabase { db in
if let rs = db.executeQuery("SELECT * FROM items", withArgumentsInArray: nil) {
while rs.next() {
let _ = rs.longForColumnIndex(0)
let _ = rs.longForColumnIndex(1)
let _ = rs.longForColumnIndex(2)
let _ = rs.longForColumnIndex(3)
let _ = rs.longForColumnIndex(4)
let _ = rs.longForColumnIndex(5)
let _ = rs.longForColumnIndex(6)
let _ = rs.longForColumnIndex(7)
let _ = rs.longForColumnIndex(8)
let _ = rs.longForColumnIndex(9)
}
}
}
}
}
func testGRDB() {
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let dbQueue = try! DatabaseQueue(path: databasePath)
measureBlock {
dbQueue.inDatabase { db in
for row in Row.fetch(db, "SELECT * FROM items") {
let _: Int = row.value(atIndex: 0)
let _: Int = row.value(atIndex: 1)
let _: Int = row.value(atIndex: 2)
let _: Int = row.value(atIndex: 3)
let _: Int = row.value(atIndex: 4)
let _: Int = row.value(atIndex: 5)
let _: Int = row.value(atIndex: 6)
let _: Int = row.value(atIndex: 7)
let _: Int = row.value(atIndex: 8)
let _: Int = row.value(atIndex: 9)
}
}
}
}
func testFetchValueAtIndexPerformance() {
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let db = try! Connection(databasePath)
self.measureBlock {
// Column access by index requires raw SQL (unlike extraction of values by column name).
for row in db.prepare("SELECT * FROM items") {
// Direct Int extraction is not supported.
let _ = Int(row[0] as! Int64)
let _ = Int(row[1] as! Int64)
let _ = Int(row[2] as! Int64)
let _ = Int(row[3] as! Int64)
let _ = Int(row[4] as! Int64)
let _ = Int(row[5] as! Int64)
let _ = Int(row[6] as! Int64)
let _ = Int(row[7] as! Int64)
let _ = Int(row[8] as! Int64)
let _ = Int(row[9] as! Int64)
}
}
}
}
@@ -0,0 +1,69 @@
import XCTest
import GRDB
import SQLite
/// Here we test the extraction of models from rows
class FetchRecordTests: XCTestCase {
func testFMDB() {
// Here we test the loading of an array of Records.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let dbQueue = FMDatabaseQueue(path: databasePath)
self.measureBlock {
var records = [Item]()
dbQueue.inDatabase { db in
if let rs = db.executeQuery("SELECT * FROM items", withArgumentsInArray: nil) {
while rs.next() {
let record = Item(dictionary: rs.resultDictionary())
records.append(record)
}
}
}
XCTAssertEqual(records[0].i0, 0)
XCTAssertEqual(records[1].i1, 1)
XCTAssertEqual(records[9999].i9, 9999)
}
}
func testGRDB() {
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let dbQueue = try! DatabaseQueue(path: databasePath)
measureBlock {
let records = dbQueue.inDatabase { db in
Item.fetchAll(db, "SELECT * FROM items")
}
XCTAssertEqual(records[0].i0, 0)
XCTAssertEqual(records[1].i1, 1)
XCTAssertEqual(records[9999].i9, 9999)
}
}
func testSQLiteSwift() {
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("PerformanceTests", ofType: "sqlite")!
let db = try! Connection(databasePath)
self.measureBlock {
var records = [Item]()
for row in db.prepare(itemsTable) {
let record = Item(
i0: row[i0Column],
i1: row[i1Column],
i2: row[i2Column],
i3: row[i3Column],
i4: row[i4Column],
i5: row[i5Column],
i6: row[i6Column],
i7: row[i7Column],
i8: row[i8Column],
i9: row[i9Column])
records.append(record)
}
XCTAssertEqual(records[0].i0, 0)
XCTAssertEqual(records[1].i1, 1)
XCTAssertEqual(records[9999].i9, 9999)
}
}
}
@@ -1,104 +1,28 @@
import XCTest
import GRDB
/// GRDB-specifc performance tests
class GRDBPerformanceTests: XCTestCase {
// This is not a test, but a function which generates the FetchPerformanceTests.sqlite resource.
func populateDatabase() {
let databasePath = "/tmp/FetchPerformanceTests.sqlite"
do {
let dbQueue = try! DatabaseQueue(path: databasePath)
func testInsertRecordPerformance() {
let databaseFileName = "GRDBPerformanceTests-\(NSProcessInfo.processInfo().globallyUniqueString).sqlite"
let databasePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent(databaseFileName)
let _ = try? NSFileManager.defaultManager().removeItemAtPath(databasePath)
defer { try! NSFileManager.defaultManager().removeItemAtPath(databasePath) }
let dbQueue = try! DatabaseQueue(path: databasePath)
try! dbQueue.inDatabase { db in
try db.execute("CREATE TABLE items (i0 INT, i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, i6 INT, i7 INT, i8 INT, i9 INT)")
}
measureBlock {
try! dbQueue.inTransaction { db in
try db.execute("CREATE TABLE items (i0 INT, i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, i6 INT, i7 INT, i8 INT, i9 INT)")
for i in 0..<100_000 {
try db.execute("INSERT INTO items (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) VALUES (?,?,?,?,?,?,?,?,?,?)", arguments: [i%1, i%2, i%3, i%4, i%5, i%6, i%7, i%8, i%9, i%10])
for i in 0..<10_000 {
let record = Item(i0: i, i1: i, i2: i, i3: i, i4: i, i5: i, i6: i, i7: i, i8: i, i9: i)
try record.insert(db)
}
return .Commit
}
}
}
func testValueAtIndexPerformance() {
// Here we test the extraction of values by column index.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let dbQueue = try! DatabaseQueue(path: databasePath)
self.measureBlock {
dbQueue.inDatabase { db in
for row in Row.fetch(db, "SELECT * FROM items") {
let _: Int = row.value(atIndex: 0)
let _: Int = row.value(atIndex: 1)
let _: Int = row.value(atIndex: 2)
let _: Int = row.value(atIndex: 3)
let _: Int = row.value(atIndex: 4)
let _: Int = row.value(atIndex: 5)
let _: Int = row.value(atIndex: 6)
let _: Int = row.value(atIndex: 7)
let _: Int = row.value(atIndex: 8)
let _: Int = row.value(atIndex: 9)
}
}
}
}
func testValueNamedPerformance() {
// Here we test the extraction of values by column name.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let dbQueue = try! DatabaseQueue(path: databasePath)
self.measureBlock {
dbQueue.inDatabase { db in
for row in Row.fetch(db, "SELECT * FROM items") {
let _: Int = row.value(named: "i0")
let _: Int = row.value(named: "i1")
let _: Int = row.value(named: "i2")
let _: Int = row.value(named: "i3")
let _: Int = row.value(named: "i4")
let _: Int = row.value(named: "i5")
let _: Int = row.value(named: "i6")
let _: Int = row.value(named: "i7")
let _: Int = row.value(named: "i8")
let _: Int = row.value(named: "i9")
}
}
}
}
func testRecordPerformance() {
// Here we test the loading of an array of Records.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let dbQueue = try! DatabaseQueue(path: databasePath)
self.measureBlock {
let records = dbQueue.inDatabase { db in
PerformanceRecord.fetchAll(db, "SELECT * FROM items")
}
XCTAssertEqual(records[4].i2, 1)
XCTAssertEqual(records[4].i3, 0)
XCTAssertEqual(records[5].i2, 2)
XCTAssertEqual(records[5].i3, 1)
}
}
func testKeyValueCodingPerformance() {
// Here we test the loading of an array of KVC-based objects.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let dbQueue = try! DatabaseQueue(path: databasePath)
self.measureBlock {
let records = dbQueue.inDatabase { db in
Row.fetch(db, "SELECT * FROM items").map { row in
PerformanceObjCRecord(dictionary: row.toNSDictionary())
}
}
XCTAssertEqual(records[4].i2!.intValue, 1)
XCTAssertEqual(records[4].i3!.intValue, 0)
XCTAssertEqual(records[5].i2!.intValue, 2)
XCTAssertEqual(records[5].i3!.intValue, 1)
}
}
}
@@ -0,0 +1,85 @@
import XCTest
import GRDB
import SQLite
// Here we insert rows, referencing statement arguments by name.
class InsertNamedValuesTests: XCTestCase {
func testFMDB() {
let databaseFileName = "GRDBPerformanceTests-\(NSProcessInfo.processInfo().globallyUniqueString).sqlite"
let databasePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent(databaseFileName)
let _ = try? NSFileManager.defaultManager().removeItemAtPath(databasePath)
defer { try! NSFileManager.defaultManager().removeItemAtPath(databasePath) }
let dbQueue = FMDatabaseQueue(path: databasePath)
dbQueue.inDatabase { db in
db.executeStatements("CREATE TABLE items (i0 INT, i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, i6 INT, i7 INT, i8 INT, i9 INT)")
}
measureBlock {
dbQueue.inTransaction { (db, rollback) -> Void in
for i in 0..<10_000 {
db.executeUpdate("INSERT INTO items (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) VALUES (:i0, :i1, :i2, :i3, :i4, :i5, :i6, :i7, :i8, :i9)", withParameterDictionary: ["i0": i, "i1": i, "i2": i, "i3": i, "i4": i, "i5": i, "i6": i, "i7": i, "i8": i, "i9": i])
}
}
}
}
func testGRDB() {
let databaseFileName = "GRDBPerformanceTests-\(NSProcessInfo.processInfo().globallyUniqueString).sqlite"
let databasePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent(databaseFileName)
let _ = try? NSFileManager.defaultManager().removeItemAtPath(databasePath)
defer { try! NSFileManager.defaultManager().removeItemAtPath(databasePath) }
let dbQueue = try! DatabaseQueue(path: databasePath)
try! dbQueue.inDatabase { db in
try db.execute("CREATE TABLE items (i0 INT, i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, i6 INT, i7 INT, i8 INT, i9 INT)")
}
measureBlock {
try! dbQueue.inTransaction { db in
for i in 0..<10_000 {
try db.execute("INSERT INTO items (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) VALUES (:i0, :i1, :i2, :i3, :i4, :i5, :i6, :i7, :i8, :i9)", arguments: ["i0": i, "i1": i, "i2": i, "i3": i, "i4": i, "i5": i, "i6": i, "i7": i, "i8": i, "i9": i])
}
return .Commit
}
}
}
func testSQLiteSwift() {
let databaseFileName = "GRDBPerformanceTests-\(NSProcessInfo.processInfo().globallyUniqueString).sqlite"
let databasePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent(databaseFileName)
let _ = try? NSFileManager.defaultManager().removeItemAtPath(databasePath)
defer { try! NSFileManager.defaultManager().removeItemAtPath(databasePath) }
let db = try! Connection(databasePath)
try! db.run(itemsTable.create { t in
t.column(i0Column)
t.column(i1Column)
t.column(i2Column)
t.column(i3Column)
t.column(i4Column)
t.column(i5Column)
t.column(i6Column)
t.column(i7Column)
t.column(i8Column)
t.column(i9Column)
})
measureBlock {
try! db.transaction {
for i in 0..<10_000 {
try db.run(itemsTable.insert(
i0Column <- i,
i1Column <- i,
i2Column <- i,
i3Column <- i,
i4Column <- i,
i5Column <- i,
i6Column <- i,
i7Column <- i,
i8Column <- i,
i9Column <- i))
}
}
}
}
}
@@ -0,0 +1,76 @@
import XCTest
import GRDB
import SQLite
// Here we insert rows, referencing statement arguments by index.
class InsertPositionalValuesTests: XCTestCase {
func testFMDB() {
let databaseFileName = "GRDBPerformanceTests-\(NSProcessInfo.processInfo().globallyUniqueString).sqlite"
let databasePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent(databaseFileName)
let _ = try? NSFileManager.defaultManager().removeItemAtPath(databasePath)
defer { try! NSFileManager.defaultManager().removeItemAtPath(databasePath) }
let dbQueue = FMDatabaseQueue(path: databasePath)
dbQueue.inDatabase { db in
db.executeStatements("CREATE TABLE items (i0 INT, i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, i6 INT, i7 INT, i8 INT, i9 INT)")
}
measureBlock {
dbQueue.inTransaction { (db, rollback) -> Void in
for i in 0..<10_000 {
db.executeUpdate("INSERT INTO items (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) VALUES (?,?,?,?,?,?,?,?,?,?)", withArgumentsInArray: [i, i, i, i, i, i, i, i, i, i])
}
}
}
}
func testGRDB() {
let databaseFileName = "GRDBPerformanceTests-\(NSProcessInfo.processInfo().globallyUniqueString).sqlite"
let databasePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent(databaseFileName)
let _ = try? NSFileManager.defaultManager().removeItemAtPath(databasePath)
defer { try! NSFileManager.defaultManager().removeItemAtPath(databasePath) }
let dbQueue = try! DatabaseQueue(path: databasePath)
try! dbQueue.inDatabase { db in
try db.execute("CREATE TABLE items (i0 INT, i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, i6 INT, i7 INT, i8 INT, i9 INT)")
}
measureBlock {
try! dbQueue.inTransaction { db in
for i in 0..<10_000 {
try db.execute("INSERT INTO items (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) VALUES (?,?,?,?,?,?,?,?,?,?)", arguments: [i, i, i, i, i, i, i, i, i, i])
}
return .Commit
}
}
}
func testSQLiteSwift() {
let databaseFileName = "GRDBPerformanceTests-\(NSProcessInfo.processInfo().globallyUniqueString).sqlite"
let databasePath = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent(databaseFileName)
let _ = try? NSFileManager.defaultManager().removeItemAtPath(databasePath)
defer { try! NSFileManager.defaultManager().removeItemAtPath(databasePath) }
let db = try! Connection(databasePath)
try! db.run(itemsTable.create { t in
t.column(i0Column)
t.column(i1Column)
t.column(i2Column)
t.column(i3Column)
t.column(i4Column)
t.column(i5Column)
t.column(i6Column)
t.column(i7Column)
t.column(i8Column)
t.column(i9Column)
})
measureBlock {
try! db.transaction {
for i in 0..<10_000 {
let stmt = db.prepare("INSERT INTO items (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) VALUES (?,?,?,?,?,?,?,?,?,?)")
try stmt.run(i, i, i, i, i, i, i, i, i, i)
}
}
}
}
}
@@ -1,68 +0,0 @@
import GRDB
class PerformanceRecord : Record {
var i0: Int?
var i1: Int?
var i2: Int?
var i3: Int?
var i4: Int?
var i5: Int?
var i6: Int?
var i7: Int?
var i8: Int?
var i9: Int?
// Record
required init(_ row: Row) {
i0 = row.value(named: "i0")
i1 = row.value(named: "i1")
i2 = row.value(named: "i2")
i3 = row.value(named: "i3")
i4 = row.value(named: "i4")
i5 = row.value(named: "i5")
i6 = row.value(named: "i6")
i7 = row.value(named: "i7")
i8 = row.value(named: "i8")
i9 = row.value(named: "i9")
super.init(row)
}
// FMDB
init(dictionary: [NSObject: AnyObject]) {
super.init()
if let n = dictionary["i0"] as? NSNumber { i0 = n.longValue }
if let n = dictionary["i1"] as? NSNumber { i1 = n.longValue }
if let n = dictionary["i2"] as? NSNumber { i2 = n.longValue }
if let n = dictionary["i3"] as? NSNumber { i3 = n.longValue }
if let n = dictionary["i4"] as? NSNumber { i4 = n.longValue }
if let n = dictionary["i5"] as? NSNumber { i5 = n.longValue }
if let n = dictionary["i6"] as? NSNumber { i6 = n.longValue }
if let n = dictionary["i7"] as? NSNumber { i7 = n.longValue }
if let n = dictionary["i8"] as? NSNumber { i8 = n.longValue }
if let n = dictionary["i9"] as? NSNumber { i9 = n.longValue }
}
}
class PerformanceObjCRecord : NSObject {
var i0: NSNumber?
var i1: NSNumber?
var i2: NSNumber?
var i3: NSNumber?
var i4: NSNumber?
var i5: NSNumber?
var i6: NSNumber?
var i7: NSNumber?
var i8: NSNumber?
var i9: NSNumber?
init(dictionary: NSDictionary) {
super.init()
for (key, value) in dictionary {
setValue(value, forKey: key as! String)
}
}
}
Binary file not shown.
@@ -0,0 +1,89 @@
import GRDB
import SQLite
// MARK:- SQLite
let itemsTable = Table("items")
let i0Column = Expression<Int>("i0")
let i1Column = Expression<Int>("i1")
let i2Column = Expression<Int>("i2")
let i3Column = Expression<Int>("i3")
let i4Column = Expression<Int>("i4")
let i5Column = Expression<Int>("i5")
let i6Column = Expression<Int>("i6")
let i7Column = Expression<Int>("i7")
let i8Column = Expression<Int>("i8")
let i9Column = Expression<Int>("i9")
// MARK:- GRDB
class Item : Record {
var i0: Int?
var i1: Int?
var i2: Int?
var i3: Int?
var i4: Int?
var i5: Int?
var i6: Int?
var i7: Int?
var i8: Int?
var i9: Int?
init(i0: Int?, i1: Int?, i2: Int?, i3: Int?, i4: Int?, i5: Int?, i6: Int?, i7: Int?, i8: Int?, i9: Int?) {
self.i0 = i0
self.i1 = i1
self.i2 = i2
self.i3 = i3
self.i4 = i4
self.i5 = i5
self.i6 = i6
self.i7 = i7
self.i8 = i8
self.i9 = i9
super.init()
}
override class func databaseTableName() -> String {
return "items"
}
required init(_ row: GRDB.Row) {
i0 = row.value(named: "i0")
i1 = row.value(named: "i1")
i2 = row.value(named: "i2")
i3 = row.value(named: "i3")
i4 = row.value(named: "i4")
i5 = row.value(named: "i5")
i6 = row.value(named: "i6")
i7 = row.value(named: "i7")
i8 = row.value(named: "i8")
i9 = row.value(named: "i9")
super.init(row)
}
override var persistentDictionary: [String: DatabaseValueConvertible?] {
return ["i0": i0, "i1": i1, "i2": i2, "i3": i3, "i4": i4, "i5": i5, "i6": i6, "i7": i7, "i8": i8, "i9": i9]
}
}
// MARK:- FMDB
extension Item {
convenience init(dictionary: [NSObject: AnyObject]) {
self.init(
i0: (dictionary["i0"] as! NSNumber).longValue,
i1: (dictionary["i1"] as! NSNumber).longValue,
i2: (dictionary["i2"] as! NSNumber).longValue,
i3: (dictionary["i3"] as! NSNumber).longValue,
i4: (dictionary["i4"] as! NSNumber).longValue,
i5: (dictionary["i5"] as! NSNumber).longValue,
i6: (dictionary["i6"] as! NSNumber).longValue,
i7: (dictionary["i7"] as! NSNumber).longValue,
i8: (dictionary["i8"] as! NSNumber).longValue,
i9: (dictionary["i9"] as! NSNumber).longValue)
}
}
@@ -1,150 +0,0 @@
import XCTest
import SQLite
class StephenCelisSQLitePerformanceTests: XCTestCase {
func testValueAtIndexPerformance() {
// Here we test the extraction of values by column index.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let db = try! Connection(databasePath)
self.measureBlock {
// Column access by index requires raw SQL (unlike extraction of values by column name).
for row in db.prepare("SELECT * FROM items") {
// Direct Int extraction is not supported.
let _ = Int(row[0] as! Int64)
let _ = Int(row[1] as! Int64)
let _ = Int(row[2] as! Int64)
let _ = Int(row[3] as! Int64)
let _ = Int(row[4] as! Int64)
let _ = Int(row[5] as! Int64)
let _ = Int(row[6] as! Int64)
let _ = Int(row[7] as! Int64)
let _ = Int(row[8] as! Int64)
let _ = Int(row[9] as! Int64)
}
}
}
func testValueNamedPerformance() {
// Here we test the extraction of values by column name.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let db = try! Connection(databasePath)
// Column access by name requires query builder (unlike extraction of values by column index).
let items = Table("items")
let i0 = Expression<Int>("i0")
let i1 = Expression<Int>("i1")
let i2 = Expression<Int>("i2")
let i3 = Expression<Int>("i3")
let i4 = Expression<Int>("i4")
let i5 = Expression<Int>("i5")
let i6 = Expression<Int>("i6")
let i7 = Expression<Int>("i7")
let i8 = Expression<Int>("i8")
let i9 = Expression<Int>("i9")
self.measureBlock {
for item in db.prepare(items) {
let _ = item[i0]
let _ = item[i1]
let _ = item[i2]
let _ = item[i3]
let _ = item[i4]
let _ = item[i5]
let _ = item[i6]
let _ = item[i7]
let _ = item[i8]
let _ = item[i9]
}
}
}
func testRecordPerformance() {
// Here we test the loading of an array of Records.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let db = try! Connection(databasePath)
// Column access by name requires query builder.
let items = Table("items")
let i0 = Expression<Int>("i0")
let i1 = Expression<Int>("i1")
let i2 = Expression<Int>("i2")
let i3 = Expression<Int>("i3")
let i4 = Expression<Int>("i4")
let i5 = Expression<Int>("i5")
let i6 = Expression<Int>("i6")
let i7 = Expression<Int>("i7")
let i8 = Expression<Int>("i8")
let i9 = Expression<Int>("i9")
self.measureBlock {
var records = [PerformanceRecord]()
for row in db.prepare(items) {
let dictionary = [
"i0": row[i0],
"i1": row[i1],
"i2": row[i2],
"i3": row[i3],
"i4": row[i4],
"i5": row[i5],
"i6": row[i6],
"i7": row[i7],
"i8": row[i8],
"i9": row[i9]] as [NSObject: AnyObject]
let record = PerformanceRecord(dictionary: dictionary)
records.append(record)
}
XCTAssertEqual(records[4].i2, 1)
XCTAssertEqual(records[4].i3, 0)
XCTAssertEqual(records[5].i2, 2)
XCTAssertEqual(records[5].i3, 1)
}
}
func testKeyValueCodingPerformance() {
// Here we test the loading of an array of KVC-based objects.
let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")!
let db = try! Connection(databasePath)
// Column access by name requires query builder.
let items = Table("items")
let i0 = Expression<Int>("i0")
let i1 = Expression<Int>("i1")
let i2 = Expression<Int>("i2")
let i3 = Expression<Int>("i3")
let i4 = Expression<Int>("i4")
let i5 = Expression<Int>("i5")
let i6 = Expression<Int>("i6")
let i7 = Expression<Int>("i7")
let i8 = Expression<Int>("i8")
let i9 = Expression<Int>("i9")
self.measureBlock {
var records = [PerformanceObjCRecord]()
for row in db.prepare(items) {
let dictionary = [
"i0": row[i0],
"i1": row[i1],
"i2": row[i2],
"i3": row[i3],
"i4": row[i4],
"i5": row[i5],
"i6": row[i6],
"i7": row[i7],
"i8": row[i8],
"i9": row[i9]] as [NSObject: AnyObject]
let record = PerformanceObjCRecord(dictionary: dictionary)
records.append(record)
}
XCTAssertEqual(records[4].i2!.intValue, 1)
XCTAssertEqual(records[4].i3!.intValue, 0)
XCTAssertEqual(records[5].i2!.intValue, 2)
XCTAssertEqual(records[5].i3!.intValue, 1)
}
}
}
+28 -18
View File
@@ -19,15 +19,12 @@
560C97E81C0E22D300BF8471 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 56BB86221BA988F2001F9168 /* FMResultSet.m */; };
560C97EC1C0E22D300BF8471 /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 56BB861F1BA988F2001F9168 /* FMDatabaseQueue.m */; };
560C97F21C0E22D300BF8471 /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = 56BB861D1BA988F2001F9168 /* FMDatabasePool.m */; };
560C98101C0E22D300BF8471 /* GRDBTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */; };
560C98121C0E22D300BF8471 /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56CA220F1BB414FE009A04C5 /* SQLite.framework */; };
560C98131C0E22D300BF8471 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 56BB86301BA98AB0001F9168 /* libsqlite3.tbd */; };
560C98141C0E22D300BF8471 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; };
560C98161C0E22D300BF8471 /* FetchPerformanceTests.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 56BB86111BA9886D001F9168 /* FetchPerformanceTests.sqlite */; };
560C98221C0E23BB00BF8471 /* FMDBPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CA221A1BB41533009A04C5 /* FMDBPerformanceTests.swift */; };
560C98161C0E22D300BF8471 /* PerformanceTests.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */; };
560C98231C0E23BB00BF8471 /* GRDBPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56BB86121BA9886D001F9168 /* GRDBPerformanceTests.swift */; };
560C98241C0E23BB00BF8471 /* PerformanceRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CA22211BB41565009A04C5 /* PerformanceRecord.swift */; };
560C98251C0E23BB00BF8471 /* StephenCelisSQLitePerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CA221B1BB41533009A04C5 /* StephenCelisSQLitePerformanceTests.swift */; };
560C98241C0E23BB00BF8471 /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CA22211BB41565009A04C5 /* PerformanceTests.swift */; };
5614DEF01BA9DA15003163B3 /* SQLiteStatementConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5614DEEF1BA9DA15003163B3 /* SQLiteStatementConvertible.swift */; };
5614DEF11BA9DA15003163B3 /* SQLiteStatementConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5614DEEF1BA9DA15003163B3 /* SQLiteStatementConvertible.swift */; };
5614DEF81BAA1B43003163B3 /* DatabaseValueConversionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A2381B1B9C74A90082EB20 /* DatabaseValueConversionTests.swift */; };
@@ -167,6 +164,11 @@
56CA22291BB41663009A04C5 /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56CA220B1BB414FE009A04C5 /* SQLite.framework */; };
56DE7B111C3D93ED00861EB8 /* StatementArgumentsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B101C3D93ED00861EB8 /* StatementArgumentsTests.swift */; };
56DE7B121C3D93ED00861EB8 /* StatementArgumentsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B101C3D93ED00861EB8 /* StatementArgumentsTests.swift */; };
56DE7B241C412F7E00861EB8 /* InsertPositionalValuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B231C412F7E00861EB8 /* InsertPositionalValuesTests.swift */; };
56DE7B261C412FDA00861EB8 /* InsertNamedValuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B251C412FDA00861EB8 /* InsertNamedValuesTests.swift */; };
56DE7B281C41302500861EB8 /* FetchNamedValuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B271C41302500861EB8 /* FetchNamedValuesTests.swift */; };
56DE7B2A1C4130AF00861EB8 /* FetchPositionalValuesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B291C4130AF00861EB8 /* FetchPositionalValuesTests.swift */; };
56DE7B2C1C41311900861EB8 /* FetchRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DE7B2B1C41311900861EB8 /* FetchRecordTests.swift */; };
56E5891F1BBA5D5400CC0140 /* NSURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E5891E1BBA5D5400CC0140 /* NSURL.swift */; };
56E589201BBA5D5400CC0140 /* NSURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E5891E1BBA5D5400CC0140 /* NSURL.swift */; };
56E5D7D41B4D3FEE00430942 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56E5D7CA1B4D3FED00430942 /* GRDB.framework */; };
@@ -372,7 +374,7 @@
56B7F4391BEB42D500E39BBF /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = "<group>"; };
56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDB.xcconfig; sourceTree = "<group>"; };
56B8F49B1B4E2F3600C24296 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
56BB86111BA9886D001F9168 /* FetchPerformanceTests.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = FetchPerformanceTests.sqlite; sourceTree = "<group>"; };
56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = PerformanceTests.sqlite; sourceTree = "<group>"; };
56BB86121BA9886D001F9168 /* GRDBPerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GRDBPerformanceTests.swift; sourceTree = "<group>"; };
56BB86181BA988F2001F9168 /* FMDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabase.h; sourceTree = "<group>"; };
56BB86191BA988F2001F9168 /* FMDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabase.m; sourceTree = "<group>"; };
@@ -391,12 +393,15 @@
56CA0D401BF5D8E20019C023 /* DatabaseValue+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DatabaseValue+Foundation.swift"; sourceTree = "<group>"; };
56CA21B91BB3FCF7009A04C5 /* NSDataTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDataTests.swift; sourceTree = "<group>"; };
56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SQLite.xcodeproj; path = SQLite.swift/SQLite.xcodeproj; sourceTree = "<group>"; };
56CA221A1BB41533009A04C5 /* FMDBPerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FMDBPerformanceTests.swift; sourceTree = "<group>"; };
56CA221B1BB41533009A04C5 /* StephenCelisSQLitePerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StephenCelisSQLitePerformanceTests.swift; sourceTree = "<group>"; };
56CA22211BB41565009A04C5 /* PerformanceRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PerformanceRecord.swift; sourceTree = "<group>"; };
56CA22211BB41565009A04C5 /* PerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PerformanceTests.swift; sourceTree = "<group>"; };
56CB92EC1BA453E500DFD5FC /* CrashTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrashTests.swift; sourceTree = "<group>"; };
56DBEC341C19A0020093A2EE /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
56DE7B101C3D93ED00861EB8 /* StatementArgumentsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementArgumentsTests.swift; sourceTree = "<group>"; };
56DE7B231C412F7E00861EB8 /* InsertPositionalValuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertPositionalValuesTests.swift; sourceTree = "<group>"; };
56DE7B251C412FDA00861EB8 /* InsertNamedValuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertNamedValuesTests.swift; sourceTree = "<group>"; };
56DE7B271C41302500861EB8 /* FetchNamedValuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchNamedValuesTests.swift; sourceTree = "<group>"; };
56DE7B291C4130AF00861EB8 /* FetchPositionalValuesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchPositionalValuesTests.swift; sourceTree = "<group>"; };
56DE7B2B1C41311900861EB8 /* FetchRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRecordTests.swift; sourceTree = "<group>"; };
56E1524B1B43FD5B00EE27AA /* TODO.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = TODO.md; sourceTree = "<group>"; };
56E5891E1BBA5D5400CC0140 /* NSURL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSURL.swift; sourceTree = "<group>"; };
56E5D7CA1B4D3FED00430942 /* GRDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDB.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -757,11 +762,14 @@
children = (
56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */,
56BB86171BA988F2001F9168 /* fmdb */,
56BB86111BA9886D001F9168 /* FetchPerformanceTests.sqlite */,
56CA221A1BB41533009A04C5 /* FMDBPerformanceTests.swift */,
56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */,
56BB86121BA9886D001F9168 /* GRDBPerformanceTests.swift */,
56CA22211BB41565009A04C5 /* PerformanceRecord.swift */,
56CA221B1BB41533009A04C5 /* StephenCelisSQLitePerformanceTests.swift */,
56CA22211BB41565009A04C5 /* PerformanceTests.swift */,
56DE7B291C4130AF00861EB8 /* FetchPositionalValuesTests.swift */,
56DE7B271C41302500861EB8 /* FetchNamedValuesTests.swift */,
56DE7B2B1C41311900861EB8 /* FetchRecordTests.swift */,
56DE7B251C412FDA00861EB8 /* InsertNamedValuesTests.swift */,
56DE7B231C412F7E00861EB8 /* InsertPositionalValuesTests.swift */,
);
path = Performance;
sourceTree = "<group>";
@@ -1177,7 +1185,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
560C98161C0E22D300BF8471 /* FetchPerformanceTests.sqlite in Resources */,
560C98161C0E22D300BF8471 /* PerformanceTests.sqlite in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1226,13 +1234,15 @@
560C97DA1C0E22D300BF8471 /* FMDatabase.m in Sources */,
560C98231C0E23BB00BF8471 /* GRDBPerformanceTests.swift in Sources */,
560C97DD1C0E22D300BF8471 /* FMDatabaseAdditions.m in Sources */,
56DE7B2C1C41311900861EB8 /* FetchRecordTests.swift in Sources */,
560C97E81C0E22D300BF8471 /* FMResultSet.m in Sources */,
560C98221C0E23BB00BF8471 /* FMDBPerformanceTests.swift in Sources */,
56DE7B281C41302500861EB8 /* FetchNamedValuesTests.swift in Sources */,
56DE7B241C412F7E00861EB8 /* InsertPositionalValuesTests.swift in Sources */,
560C97EC1C0E22D300BF8471 /* FMDatabaseQueue.m in Sources */,
560C97F21C0E22D300BF8471 /* FMDatabasePool.m in Sources */,
560C98251C0E23BB00BF8471 /* StephenCelisSQLitePerformanceTests.swift in Sources */,
560C98101C0E22D300BF8471 /* GRDBTestCase.swift in Sources */,
560C98241C0E23BB00BF8471 /* PerformanceRecord.swift in Sources */,
560C98241C0E23BB00BF8471 /* PerformanceTests.swift in Sources */,
56DE7B261C412FDA00861EB8 /* InsertNamedValuesTests.swift in Sources */,
56DE7B2A1C4130AF00861EB8 /* FetchPositionalValuesTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+6 -8
View File
@@ -519,6 +519,9 @@ public final class Database {
// =========================================================================
// MARK: - Database Informations
/// The database configuration
public let configuration: Configuration
/// Clears the database schema cache.
///
/// You may need to clear the cache if you modify the database schema
@@ -670,13 +673,6 @@ public final class Database {
public let sqliteConnection: SQLiteConnection
// =========================================================================
// MARK: - Configuration
/// The database configuration
public let configuration: Configuration
// =========================================================================
// MARK: - Initialization
@@ -696,7 +692,9 @@ public final class Database {
throw DatabaseError(code: code, message: String.fromCString(sqlite3_errmsg(sqliteConnection)))
}
setupTrace() // First, so that all queries, including initialization queries, are traced.
// Setup trace first, so that all queries, including initialization queries, are traced.
setupTrace()
try setupForeignKeys()
setupBusyMode()
setupTransactionHooks()