mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Merge branch 'MultipleTransactionObservers' of github.com:groue/GRDB.swift into FetchedRecordsController
Conflicts: GRDB/Core/Configuration.swift GRDB/Core/Database.swift
This commit is contained in:
commit
b0d60cc9da
30 files changed
+1162
-763
No files matched your search
@@ -1,6 +1,25 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
## 0.40.0
|
||||
|
||||
**New**
|
||||
|
||||
- Various [performance improvements](https://github.com/groue/GRDB.swift/wiki/Performance)
|
||||
- `Statement.unsafeSetArguments(_)` binds arguments in a prepared statement without checking if arguments fit.
|
||||
|
||||
|
||||
## 0.39.1
|
||||
|
||||
**New**
|
||||
|
||||
- Various [performance improvements](https://github.com/groue/GRDB.swift/wiki/Performance)
|
||||
|
||||
**Fixed**
|
||||
|
||||
- Fixed the change tracking of Record subclasses that mangle the case of column names.
|
||||
|
||||
|
||||
## 0.39.0
|
||||
|
||||
Released January 11, 2016
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="9525" systemVersion="15B42" minimumToolsVersion="Xcode 7.0">
|
||||
<entity name="Item" representedClassName="ManagedItem" syncable="YES">
|
||||
<entity name="Item" representedClassName="NSManagedObject" syncable="YES">
|
||||
<attribute name="i0" optional="YES" attributeType="Integer 64" syncable="YES"/>
|
||||
<attribute name="i1" optional="YES" attributeType="Integer 64" syncable="YES"/>
|
||||
<attribute name="i2" optional="YES" attributeType="Integer 64" syncable="YES"/>
|
||||
|
||||
@@ -19,18 +19,18 @@ 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?
|
||||
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?) {
|
||||
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
|
||||
|
||||
@@ -58,7 +58,11 @@ class SelectStatementTests : GRDBTestCase {
|
||||
let statement = try db.selectStatement("SELECT COUNT(*) FROM persons WHERE age < :age")
|
||||
// TODO: Remove this explicit type declaration required by rdar://22357375
|
||||
let ageDicts: [[String: DatabaseValueConvertible?]] = [["age": 20], ["age": 30], ["age": 40], ["age": 50]]
|
||||
let counts = ageDicts.map { Int.fetchOne(statement, arguments: StatementArguments($0))! }
|
||||
let counts = ageDicts.map { dic -> Int in
|
||||
// Make sure we don't trigger a failible initializer
|
||||
let arguments: StatementArguments = StatementArguments(dic)
|
||||
return Int.fetchOne(statement, arguments: arguments)!
|
||||
}
|
||||
XCTAssertEqual(counts, [1,2,2,3])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,48 @@ class StatementArgumentsTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testPositionalStatementArguments() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
let name = "Arthur"
|
||||
let age = 42
|
||||
let arguments = StatementArguments([name, age] as [DatabaseValueConvertible?])
|
||||
|
||||
let updateStatement = try db.updateStatement("INSERT INTO persons (firstName, age) VALUES (?, ?)")
|
||||
updateStatement.arguments = arguments
|
||||
try updateStatement.execute()
|
||||
|
||||
let selectStatement = try db.selectStatement("SELECT * FROM persons WHERE firstName = ? AND age = ?")
|
||||
selectStatement.arguments = arguments
|
||||
let row = Row.fetchOne(selectStatement)!
|
||||
|
||||
XCTAssertEqual(row.value(named: "firstName") as String, name)
|
||||
XCTAssertEqual(row.value(named: "age") as Int, age)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUnsafePositionalStatementArguments() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
let name = "Arthur"
|
||||
let age = 42
|
||||
let arguments = StatementArguments([name, age] as [DatabaseValueConvertible?])
|
||||
|
||||
let updateStatement = try db.updateStatement("INSERT INTO persons (firstName, age) VALUES (?, ?)")
|
||||
updateStatement.unsafeSetArguments(arguments)
|
||||
try updateStatement.execute()
|
||||
|
||||
let selectStatement = try db.selectStatement("SELECT * FROM persons WHERE firstName = ? AND age = ?")
|
||||
selectStatement.unsafeSetArguments(arguments)
|
||||
let row = Row.fetchOne(selectStatement)!
|
||||
|
||||
XCTAssertEqual(row.value(named: "firstName") as String, name)
|
||||
XCTAssertEqual(row.value(named: "age") as Int, age)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testNamedStatementArgumentsValidation() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
@@ -175,6 +217,48 @@ class StatementArgumentsTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testNamedStatementArguments() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
let name = "Arthur"
|
||||
let age = 42
|
||||
let arguments = StatementArguments(["name": name, "age": age] as [String: DatabaseValueConvertible?])
|
||||
|
||||
let updateStatement = try db.updateStatement("INSERT INTO persons (firstName, age) VALUES (:name, :age)")
|
||||
updateStatement.arguments = arguments
|
||||
try updateStatement.execute()
|
||||
|
||||
let selectStatement = try db.selectStatement("SELECT * FROM persons WHERE firstName = :name AND age = :age")
|
||||
selectStatement.arguments = arguments
|
||||
let row = Row.fetchOne(selectStatement)!
|
||||
|
||||
XCTAssertEqual(row.value(named: "firstName") as String, name)
|
||||
XCTAssertEqual(row.value(named: "age") as Int, age)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUnsafeNamedStatementArguments() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
let name = "Arthur"
|
||||
let age = 42
|
||||
let arguments = StatementArguments(["name": name, "age": age] as [String: DatabaseValueConvertible?])
|
||||
|
||||
let updateStatement = try db.updateStatement("INSERT INTO persons (firstName, age) VALUES (:name, :age)")
|
||||
updateStatement.unsafeSetArguments(arguments)
|
||||
try updateStatement.execute()
|
||||
|
||||
let selectStatement = try db.selectStatement("SELECT * FROM persons WHERE firstName = :name AND age = :age")
|
||||
selectStatement.unsafeSetArguments(arguments)
|
||||
let row = Row.fetchOne(selectStatement)!
|
||||
|
||||
XCTAssertEqual(row.value(named: "firstName") as String, name)
|
||||
XCTAssertEqual(row.value(named: "age") as Int, age)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testReusedNamedStatementArgumentsValidation() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
@@ -261,4 +345,48 @@ class StatementArgumentsTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func testReusedNamedStatementArguments() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
let name = "Arthur"
|
||||
let age = 42
|
||||
let arguments = StatementArguments(["name": name, "age": age] as [String: DatabaseValueConvertible?])
|
||||
|
||||
let updateStatement = try db.updateStatement("INSERT INTO persons (firstName, lastName, age) VALUES (:name, :name, :age)")
|
||||
updateStatement.arguments = arguments
|
||||
try updateStatement.execute()
|
||||
|
||||
let selectStatement = try db.selectStatement("SELECT * FROM persons WHERE firstName = :name AND lastName = :name AND age = :age")
|
||||
selectStatement.arguments = arguments
|
||||
let row = Row.fetchOne(selectStatement)!
|
||||
|
||||
XCTAssertEqual(row.value(named: "firstName") as String, name)
|
||||
XCTAssertEqual(row.value(named: "age") as Int, age)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testUnsafeReusedNamedStatementArguments() {
|
||||
assertNoError {
|
||||
try dbQueue.inDatabase { db in
|
||||
let name = "Arthur"
|
||||
let age = 42
|
||||
let arguments = StatementArguments(["name": name, "age": age] as [String: DatabaseValueConvertible?])
|
||||
|
||||
let updateStatement = try db.updateStatement("INSERT INTO persons (firstName, lastName, age) VALUES (:name, :name, :age)")
|
||||
updateStatement.unsafeSetArguments(arguments)
|
||||
try updateStatement.execute()
|
||||
|
||||
let selectStatement = try db.selectStatement("SELECT * FROM persons WHERE firstName = :name AND lastName = :name AND age = :age")
|
||||
selectStatement.unsafeSetArguments(arguments)
|
||||
let row = Row.fetchOne(selectStatement)!
|
||||
|
||||
XCTAssertEqual(row.value(named: "firstName") as String, name)
|
||||
XCTAssertEqual(row.value(named: "age") as Int, age)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,57 @@ class IntegerPropertyOnRealAffinityColumn : Record {
|
||||
}
|
||||
}
|
||||
|
||||
class PersonWithModifiedCaseColumns: Record {
|
||||
var id: Int64!
|
||||
var name: String!
|
||||
var age: Int?
|
||||
var creationDate: NSDate!
|
||||
|
||||
init(id: Int64? = nil, name: String? = nil, age: Int? = nil, creationDate: NSDate? = nil) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.age = age
|
||||
self.creationDate = creationDate
|
||||
super.init()
|
||||
}
|
||||
|
||||
// Record
|
||||
|
||||
override class func databaseTableName() -> String {
|
||||
return "persons"
|
||||
}
|
||||
|
||||
required init(_ row: Row) {
|
||||
id = row.value(named: "ID")
|
||||
age = row.value(named: "AGE")
|
||||
name = row.value(named: "NAME")
|
||||
creationDate = row.value(named: "CREATIONDATE")
|
||||
super.init(row)
|
||||
}
|
||||
|
||||
override var persistentDictionary: [String: DatabaseValueConvertible?] {
|
||||
return [
|
||||
"ID": id,
|
||||
"NAME": name,
|
||||
"AGE": age,
|
||||
"CREATIONDATE": creationDate,
|
||||
]
|
||||
}
|
||||
|
||||
override func insert(db: Database) throws {
|
||||
// This is implicitely tested with the NOT NULL constraint on creationDate
|
||||
if creationDate == nil {
|
||||
creationDate = NSDate()
|
||||
}
|
||||
|
||||
try super.insert(db)
|
||||
}
|
||||
|
||||
override func didInsertWithRowID(rowID: Int64, forColumn column: String?) {
|
||||
self.id = rowID
|
||||
}
|
||||
}
|
||||
|
||||
class RecordEditedTests: GRDBTestCase {
|
||||
|
||||
override func setUp() {
|
||||
@@ -60,6 +111,11 @@ class RecordEditedTests: GRDBTestCase {
|
||||
let person = Person.fetchOne(db, "SELECT * FROM persons")!
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
try PersonWithModifiedCaseColumns(name: "Arthur", age: 41).insert(db)
|
||||
let person = PersonWithModifiedCaseColumns.fetchOne(db, "SELECT * FROM persons")!
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +160,11 @@ class RecordEditedTests: GRDBTestCase {
|
||||
let person = Person.fetchOne(db, "SELECT *, 1 AS foo FROM persons")!
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
try PersonWithModifiedCaseColumns(name: "Arthur", age: 41).insert(db)
|
||||
let person = PersonWithModifiedCaseColumns.fetchOne(db, "SELECT *, 1 AS foo FROM persons")!
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +179,11 @@ class RecordEditedTests: GRDBTestCase {
|
||||
let person = Person.fetchOne(db, "SELECT name FROM persons")!
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
try PersonWithModifiedCaseColumns(name: "Arthur", age: 41).insert(db)
|
||||
let person = PersonWithModifiedCaseColumns.fetchOne(db, "SELECT name FROM persons")!
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +195,11 @@ class RecordEditedTests: GRDBTestCase {
|
||||
try person.insert(db)
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
try person.insert(db)
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +230,29 @@ class RecordEditedTests: GRDBTestCase {
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
do {
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur")
|
||||
try person.insert(db)
|
||||
XCTAssertTrue(person.name != nil)
|
||||
person.name = "Bobby" // non-nil vs. non-nil
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
}
|
||||
do {
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur")
|
||||
try person.insert(db)
|
||||
XCTAssertTrue(person.name != nil)
|
||||
person.name = nil // non-nil vs. nil
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
}
|
||||
do {
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur")
|
||||
try person.insert(db)
|
||||
XCTAssertTrue(person.age == nil)
|
||||
person.age = 41 // nil vs. non-nil
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +274,22 @@ class RecordEditedTests: GRDBTestCase {
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
do {
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur")
|
||||
try person.insert(db)
|
||||
XCTAssertTrue(person.name != nil)
|
||||
person.name = "Arthur" // non-nil vs. non-nil
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
do {
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur")
|
||||
try person.insert(db)
|
||||
XCTAssertTrue(person.age == nil)
|
||||
person.age = nil // nil vs. nil
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +303,13 @@ class RecordEditedTests: GRDBTestCase {
|
||||
try person.update(db)
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
try person.insert(db)
|
||||
person.name = "Bobby"
|
||||
try person.update(db)
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,6 +325,15 @@ class RecordEditedTests: GRDBTestCase {
|
||||
try person.save(db)
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
try person.save(db)
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
person.name = "Bobby"
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
try person.save(db)
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,6 +346,12 @@ class RecordEditedTests: GRDBTestCase {
|
||||
person.id = person.id + 1
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
try person.insert(db)
|
||||
person.id = person.id + 1
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,6 +372,25 @@ class RecordEditedTests: GRDBTestCase {
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
XCTAssertFalse(person.copy().hasPersistentChangedValues)
|
||||
|
||||
person.hasPersistentChangedValues = true
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
XCTAssertTrue(person.copy().hasPersistentChangedValues)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
|
||||
try person.insert(db)
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
XCTAssertFalse(person.copy().hasPersistentChangedValues)
|
||||
|
||||
person.name = "Barbara"
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
XCTAssertTrue(person.copy().hasPersistentChangedValues)
|
||||
|
||||
person.hasPersistentChangedValues = false
|
||||
XCTAssertFalse(person.hasPersistentChangedValues)
|
||||
XCTAssertFalse(person.copy().hasPersistentChangedValues)
|
||||
|
||||
person.hasPersistentChangedValues = true
|
||||
XCTAssertTrue(person.hasPersistentChangedValues)
|
||||
XCTAssertTrue(person.copy().hasPersistentChangedValues)
|
||||
@@ -299,6 +450,12 @@ class RecordEditedTests: GRDBTestCase {
|
||||
let changes = person.persistentChangedValues
|
||||
XCTAssertEqual(changes.count, 0)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
try PersonWithModifiedCaseColumns(name: "Arthur", age: 41).insert(db)
|
||||
let person = PersonWithModifiedCaseColumns.fetchOne(db, "SELECT * FROM persons")!
|
||||
let changes = person.persistentChangedValues
|
||||
XCTAssertEqual(changes.count, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,6 +483,24 @@ class RecordEditedTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
try PersonWithModifiedCaseColumns(name: "Arthur", age: 41).insert(db)
|
||||
let person = PersonWithModifiedCaseColumns.fetchOne(db, "SELECT name FROM persons")!
|
||||
let changes = person.persistentChangedValues
|
||||
XCTAssertEqual(changes.count, 3)
|
||||
for (column, old) in changes {
|
||||
switch column {
|
||||
case "ID":
|
||||
XCTAssertTrue(old == nil)
|
||||
case "AGE":
|
||||
XCTAssertTrue(old == nil)
|
||||
case "CREATIONDATE":
|
||||
XCTAssertTrue(old == nil)
|
||||
default:
|
||||
XCTFail("Unexpected column: \(column)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,6 +513,12 @@ class RecordEditedTests: GRDBTestCase {
|
||||
let changes = person.persistentChangedValues
|
||||
XCTAssertEqual(changes.count, 0)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
try person.insert(db)
|
||||
let changes = person.persistentChangedValues
|
||||
XCTAssertEqual(changes.count, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +548,28 @@ class RecordEditedTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: nil)
|
||||
try person.insert(db)
|
||||
|
||||
person.name = "Bobby" // non-nil -> non-nil
|
||||
person.age = 41 // nil -> non-nil
|
||||
person.creationDate = nil // non-nil -> nil
|
||||
let changes = person.persistentChangedValues
|
||||
XCTAssertEqual(changes.count, 3)
|
||||
for (column, old) in changes {
|
||||
switch column {
|
||||
case "NAME":
|
||||
XCTAssertEqual(old, "Arthur".databaseValue)
|
||||
case "AGE":
|
||||
XCTAssertEqual(old, DatabaseValue.Null)
|
||||
case "CREATIONDATE":
|
||||
XCTAssertTrue((old?.value() as NSDate?) != nil)
|
||||
default:
|
||||
XCTFail("Unexpected column: \(column)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,6 +583,13 @@ class RecordEditedTests: GRDBTestCase {
|
||||
try person.update(db)
|
||||
XCTAssertEqual(person.persistentChangedValues.count, 0)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
try person.insert(db)
|
||||
person.name = "Bobby"
|
||||
try person.update(db)
|
||||
XCTAssertEqual(person.persistentChangedValues.count, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,6 +615,25 @@ class RecordEditedTests: GRDBTestCase {
|
||||
try person.save(db)
|
||||
XCTAssertEqual(person.persistentChangedValues.count, 0)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
try person.save(db)
|
||||
XCTAssertEqual(person.persistentChangedValues.count, 0)
|
||||
|
||||
person.name = "Bobby"
|
||||
let changes = person.persistentChangedValues
|
||||
XCTAssertEqual(changes.count, 1)
|
||||
for (column, old) in changes {
|
||||
switch column {
|
||||
case "NAME":
|
||||
XCTAssertEqual(old, "Arthur".databaseValue)
|
||||
default:
|
||||
XCTFail("Unexpected column: \(column)")
|
||||
}
|
||||
}
|
||||
try person.save(db)
|
||||
XCTAssertEqual(person.persistentChangedValues.count, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,6 +655,21 @@ class RecordEditedTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
try person.insert(db)
|
||||
person.id = person.id + 1
|
||||
let changes = person.persistentChangedValues
|
||||
XCTAssertEqual(changes.count, 1)
|
||||
for (column, old) in changes {
|
||||
switch column {
|
||||
case "ID":
|
||||
XCTAssertEqual(old, (person.id - 1).databaseValue)
|
||||
default:
|
||||
XCTFail("Unexpected column: \(column)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,6 +690,25 @@ class RecordEditedTests: GRDBTestCase {
|
||||
XCTAssertEqual(person.persistentChangedValues.count, 0)
|
||||
XCTAssertEqual(person.copy().persistentChangedValues.count, 0)
|
||||
|
||||
person.hasPersistentChangedValues = true
|
||||
XCTAssertTrue(person.persistentChangedValues.count > 0) // TODO: compare actual changes
|
||||
XCTAssertEqual(person.persistentChangedValues.count, person.copy().persistentChangedValues.count)
|
||||
}
|
||||
try dbQueue.inDatabase { db in
|
||||
let person = PersonWithModifiedCaseColumns(name: "Arthur", age: 41)
|
||||
|
||||
try person.insert(db)
|
||||
XCTAssertEqual(person.persistentChangedValues.count, 0)
|
||||
XCTAssertEqual(person.copy().persistentChangedValues.count, 0)
|
||||
|
||||
person.name = "Barbara"
|
||||
XCTAssertTrue(person.persistentChangedValues.count > 0) // TODO: compare actual changes
|
||||
XCTAssertEqual(person.persistentChangedValues.count, person.copy().persistentChangedValues.count)
|
||||
|
||||
person.hasPersistentChangedValues = false
|
||||
XCTAssertEqual(person.persistentChangedValues.count, 0)
|
||||
XCTAssertEqual(person.copy().persistentChangedValues.count, 0)
|
||||
|
||||
person.hasPersistentChangedValues = true
|
||||
XCTAssertTrue(person.persistentChangedValues.count > 0) // TODO: compare actual changes
|
||||
XCTAssertEqual(person.persistentChangedValues.count, person.copy().persistentChangedValues.count)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'GRDB.swift'
|
||||
s.version = '0.39.0'
|
||||
s.version = '0.40.0'
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.summary = 'Versatile SQLite toolkit for Swift.'
|
||||
s.homepage = 'https://github.com/groue/GRDB.swift'
|
||||
|
||||
@@ -783,6 +783,7 @@
|
||||
children = (
|
||||
56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */,
|
||||
56DE7B361C42BBBB00861EB8 /* PerformanceCoreDataTests.sqlite */,
|
||||
56DE7B2D1C42B23B00861EB8 /* PerformanceModel.xcdatamodeld */,
|
||||
56DE7B271C41302500861EB8 /* FetchNamedValuesTests.swift */,
|
||||
56DE7B291C4130AF00861EB8 /* FetchPositionalValuesTests.swift */,
|
||||
56DE7B2B1C41311900861EB8 /* FetchRecordTests.swift */,
|
||||
@@ -792,7 +793,6 @@
|
||||
56CA22211BB41565009A04C5 /* PerformanceTests.swift */,
|
||||
56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */,
|
||||
56BB86171BA988F2001F9168 /* fmdb */,
|
||||
56DE7B2D1C42B23B00861EB8 /* PerformanceModel.xcdatamodeld */,
|
||||
);
|
||||
path = Performance;
|
||||
sourceTree = "<group>";
|
||||
|
||||
@@ -65,9 +65,6 @@
|
||||
<Test
|
||||
Identifier = "DatabaseCoderTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "DatabaseErrorFromStatementCreationTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "DatabaseErrorTests">
|
||||
</Test>
|
||||
@@ -101,9 +98,6 @@
|
||||
<Test
|
||||
Identifier = "DictionaryRowTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "FMDBPerformanceTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "FetchedRecordsControllerTests/testEmptyFetchedRecordsAfterPerformFetch()">
|
||||
</Test>
|
||||
@@ -128,9 +122,6 @@
|
||||
<Test
|
||||
Identifier = "FunctionTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GRDBPerformanceTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "GRDBTestCase">
|
||||
</Test>
|
||||
@@ -222,7 +213,7 @@
|
||||
Identifier = "StatementArgumentsFoundationTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "StephenCelisSQLitePerformanceTests">
|
||||
Identifier = "StatementArgumentsTests">
|
||||
</Test>
|
||||
<Test
|
||||
Identifier = "TransactionObserverTests">
|
||||
|
||||
@@ -14,10 +14,8 @@ public struct Configuration {
|
||||
|
||||
// MARK: - Transactions
|
||||
|
||||
/// The transaction kind used by Database.inTransaction().
|
||||
///
|
||||
/// Default is `.Immediate`.
|
||||
public var defaultTransactionKind: TransactionKind
|
||||
/// The default kind of transaction.
|
||||
public var defaultTransactionKind: TransactionKind = .Immediate
|
||||
|
||||
|
||||
// MARK: - Concurrency
|
||||
|
||||
+514
-557
File diff suppressed because it is too large.
Load diff
@@ -47,46 +47,9 @@ public struct DatabaseValue : Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Creating DatabaseValue
|
||||
|
||||
/// The NULL DatabaseValue.
|
||||
public static let Null = DatabaseValue(storage: .Null)
|
||||
|
||||
/// Returns a DatabaseValue storing an Int64.
|
||||
init(_ int64: Swift.Int64) {
|
||||
storage = .Int64(int64)
|
||||
}
|
||||
|
||||
/// Returns a DatabaseValue storing a Double.
|
||||
init(_ double: Swift.Double) {
|
||||
storage = .Double(double)
|
||||
}
|
||||
|
||||
/// Returns a DatabaseValue storing a String.
|
||||
init(_ string: Swift.String) {
|
||||
storage = .String(string)
|
||||
}
|
||||
|
||||
/// Returns a DatabaseValue storing NSData.
|
||||
///
|
||||
/// SQLite cant' store zero-length blobs: if data has zero length, the
|
||||
/// result is NULL.
|
||||
init(_ data: NSData) {
|
||||
if data.length == 0 {
|
||||
// SQLite cant' store zero-length blobs.
|
||||
storage = .Null
|
||||
} else {
|
||||
storage = .Blob(data)
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy initializer
|
||||
init(_ databaseValue: DatabaseValue) {
|
||||
// This initializer is used by DatabaseValue.init?(object: AnyObject)
|
||||
self = databaseValue
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Extracting Value
|
||||
|
||||
@@ -167,6 +130,7 @@ public struct DatabaseValue : Hashable {
|
||||
self.storage = storage
|
||||
}
|
||||
|
||||
// SQLite column value
|
||||
init(sqliteStatement: SQLiteStatement, index: Int) {
|
||||
switch sqlite3_column_type(sqliteStatement, Int32(index)) {
|
||||
case SQLITE_NULL:
|
||||
@@ -177,7 +141,7 @@ public struct DatabaseValue : Hashable {
|
||||
storage = .Double(sqlite3_column_double(sqliteStatement, Int32(index)))
|
||||
case SQLITE_TEXT:
|
||||
let cString = UnsafePointer<Int8>(sqlite3_column_text(sqliteStatement, Int32(index)))
|
||||
storage = .String(Swift.String.fromCString(cString)!)
|
||||
storage = .String(String.fromCString(cString)!)
|
||||
case SQLITE_BLOB:
|
||||
let bytes = sqlite3_column_blob(sqliteStatement, Int32(index))
|
||||
let length = sqlite3_column_bytes(sqliteStatement, Int32(index))
|
||||
@@ -187,6 +151,7 @@ public struct DatabaseValue : Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
// SQLite function argument
|
||||
init(sqliteValue: SQLiteValue) {
|
||||
switch sqlite3_value_type(sqliteValue) {
|
||||
case SQLITE_NULL:
|
||||
|
||||
@@ -210,8 +210,8 @@ public extension MutableDatabasePersistable {
|
||||
let dataMapper = DataMapper(db, self)
|
||||
let changes = try dataMapper.insertStatement().execute()
|
||||
if let rowID = changes.insertedRowID {
|
||||
if case .Managed(let columnName) = dataMapper.primaryKey {
|
||||
didInsertWithRowID(rowID, forColumn: columnName)
|
||||
if case .RowID(let column) = dataMapper.primaryKey {
|
||||
didInsertWithRowID(rowID, forColumn: column)
|
||||
} else {
|
||||
didInsertWithRowID(rowID, forColumn: nil)
|
||||
}
|
||||
@@ -386,8 +386,8 @@ public extension DatabasePersistable {
|
||||
let dataMapper = DataMapper(db, self)
|
||||
let changes = try dataMapper.insertStatement().execute()
|
||||
if let rowID = changes.insertedRowID {
|
||||
if case .Managed(let columnName) = dataMapper.primaryKey {
|
||||
didInsertWithRowID(rowID, forColumn: columnName)
|
||||
if case .RowID(let column) = dataMapper.primaryKey {
|
||||
didInsertWithRowID(rowID, forColumn: column)
|
||||
} else {
|
||||
didInsertWithRowID(rowID, forColumn: nil)
|
||||
}
|
||||
@@ -425,10 +425,11 @@ public extension DatabasePersistable {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// MARK: - DataMapper
|
||||
|
||||
/// DataMapper takes care of DatabasePersistable CRUD
|
||||
private class DataMapper {
|
||||
final class DataMapper {
|
||||
|
||||
/// The database
|
||||
let db: Database
|
||||
@@ -458,7 +459,17 @@ private class DataMapper {
|
||||
let persistentDictionary = self.persistentDictionary
|
||||
var dictionary: [String: DatabaseValueConvertible?] = [:]
|
||||
for column in columns {
|
||||
dictionary[column] = persistentDictionary[column]
|
||||
if let value = persistentDictionary[column] {
|
||||
dictionary[column] = value
|
||||
} else {
|
||||
dictionary[column] = nil
|
||||
let lowercaseColumn = column.lowercaseString
|
||||
for (persistentColumn, value) in persistentDictionary {
|
||||
if persistentColumn.lowercaseString == lowercaseColumn {
|
||||
dictionary[column] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictionary
|
||||
}()
|
||||
@@ -506,13 +517,12 @@ private class DataMapper {
|
||||
// MARK: - Initializer
|
||||
|
||||
init(_ db: Database, _ persistable: MutableDatabasePersistable) {
|
||||
let databaseTableName = persistable.dynamicType.databaseTableName()
|
||||
|
||||
// Fail early if database table does not exist.
|
||||
let databaseTableName = persistable.dynamicType.databaseTableName()
|
||||
guard let primaryKey = db.primaryKey(databaseTableName) else {
|
||||
fatalError("no such table: \(databaseTableName)")
|
||||
}
|
||||
|
||||
|
||||
// Fail early if persistentDictionary is empty
|
||||
let persistentDictionary = persistable.persistentDictionary
|
||||
precondition(persistentDictionary.count > 0, "\(persistable.dynamicType).persistentDictionary: invalid empty dictionary")
|
||||
|
||||
+22
-10
@@ -88,9 +88,11 @@ public final class Row: CollectionType {
|
||||
/// - returns: An optional *Value*.
|
||||
public func value<Value: DatabaseValueConvertible>(atIndex index: Int) -> Value? {
|
||||
precondition(index >= 0 && index < count, "row index out of range")
|
||||
return impl
|
||||
.databaseValue(atIndex: index)
|
||||
.value()
|
||||
return unsafeValue(atIndex: index)
|
||||
}
|
||||
|
||||
private func unsafeValue<Value: DatabaseValueConvertible>(atIndex index: Int) -> Value? {
|
||||
return impl.databaseValue(atIndex: index).value()
|
||||
}
|
||||
|
||||
/// Returns the value at given index, converted to the requested type.
|
||||
@@ -119,6 +121,10 @@ public final class Row: CollectionType {
|
||||
/// - returns: An optional *Value*.
|
||||
public func value<Value: protocol<DatabaseValueConvertible, SQLiteStatementConvertible>>(atIndex index: Int) -> Value? {
|
||||
precondition(index >= 0 && index < count, "row index out of range")
|
||||
return unsafeValue(atIndex: index)
|
||||
}
|
||||
|
||||
private func unsafeValue<Value: protocol<DatabaseValueConvertible, SQLiteStatementConvertible>>(atIndex index: Int) -> Value? {
|
||||
let sqliteStatement = self.sqliteStatement
|
||||
if sqliteStatement != nil {
|
||||
// Metal row
|
||||
@@ -154,9 +160,11 @@ public final class Row: CollectionType {
|
||||
/// - returns: A *Value*.
|
||||
public func value<Value: DatabaseValueConvertible>(atIndex index: Int) -> Value {
|
||||
precondition(index >= 0 && index < count, "row index out of range")
|
||||
return impl
|
||||
.databaseValue(atIndex: index)
|
||||
.value()
|
||||
return unsafeValue(atIndex: index)
|
||||
}
|
||||
|
||||
private func unsafeValue<Value: DatabaseValueConvertible>(atIndex index: Int) -> Value {
|
||||
return impl.databaseValue(atIndex: index).value()
|
||||
}
|
||||
|
||||
/// Returns the value at given index, converted to the requested type.
|
||||
@@ -185,6 +193,10 @@ public final class Row: CollectionType {
|
||||
/// - returns: A *Value*.
|
||||
public func value<Value: protocol<DatabaseValueConvertible, SQLiteStatementConvertible>>(atIndex index: Int) -> Value {
|
||||
precondition(index >= 0 && index < count, "row index out of range")
|
||||
return unsafeValue(atIndex: index)
|
||||
}
|
||||
|
||||
private func unsafeValue<Value: protocol<DatabaseValueConvertible, SQLiteStatementConvertible>>(atIndex index: Int) -> Value {
|
||||
let sqliteStatement = self.sqliteStatement
|
||||
if sqliteStatement != nil {
|
||||
// Metal row
|
||||
@@ -244,7 +256,7 @@ public final class Row: CollectionType {
|
||||
guard let index = impl.indexForColumn(named: columnName) else {
|
||||
return nil
|
||||
}
|
||||
return value(atIndex: index)
|
||||
return unsafeValue(atIndex: index)
|
||||
}
|
||||
|
||||
/// Returns the value at given column, converted to the requested type.
|
||||
@@ -273,7 +285,7 @@ public final class Row: CollectionType {
|
||||
guard let index = impl.indexForColumn(named: columnName) else {
|
||||
return nil
|
||||
}
|
||||
return value(atIndex: index)
|
||||
return unsafeValue(atIndex: index)
|
||||
}
|
||||
|
||||
/// Returns the value at given column, converted to the requested type.
|
||||
@@ -299,7 +311,7 @@ public final class Row: CollectionType {
|
||||
guard let index = impl.indexForColumn(named: columnName) else {
|
||||
fatalError("no such column: \(columnName)")
|
||||
}
|
||||
return value(atIndex: index)
|
||||
return unsafeValue(atIndex: index)
|
||||
}
|
||||
|
||||
/// Returns the value at given column, converted to the requested type.
|
||||
@@ -330,7 +342,7 @@ public final class Row: CollectionType {
|
||||
guard let index = impl.indexForColumn(named: columnName) else {
|
||||
fatalError("no such column: \(columnName)")
|
||||
}
|
||||
return value(atIndex: index)
|
||||
return unsafeValue(atIndex: index)
|
||||
}
|
||||
|
||||
/// Returns the optional `NSData` at given index.
|
||||
|
||||
+59
-59
@@ -13,12 +13,6 @@ public class Statement {
|
||||
/// The SQL query
|
||||
public let sql: String
|
||||
|
||||
/// The statement arguments
|
||||
public var arguments: StatementArguments {
|
||||
get { return _arguments }
|
||||
set { try! setArgumentsWithValidation(newValue) }
|
||||
}
|
||||
|
||||
|
||||
// MARK: Not public
|
||||
|
||||
@@ -97,8 +91,14 @@ public class Statement {
|
||||
}
|
||||
}()
|
||||
|
||||
/// The statement arguments.
|
||||
public var arguments: StatementArguments {
|
||||
get { return _arguments }
|
||||
set { try! setArgumentsWithValidation(newValue) }
|
||||
}
|
||||
|
||||
/// Set arguments without any validation. Trades safety for performance.
|
||||
func unsafeSetArguments(arguments: StatementArguments) {
|
||||
public func unsafeSetArguments(arguments: StatementArguments) {
|
||||
_arguments = arguments
|
||||
argumentsNeedValidation = false
|
||||
|
||||
@@ -107,15 +107,14 @@ public class Statement {
|
||||
clearBindings()
|
||||
|
||||
switch arguments.kind {
|
||||
case .Array(let array):
|
||||
for (index, value) in array.enumerate() {
|
||||
case .Values(let values):
|
||||
for (index, value) in values.enumerate() {
|
||||
try! bindDatabaseValue(value?.databaseValue ?? .Null, atIndex: Int32(index + 1))
|
||||
}
|
||||
break
|
||||
case .Dictionary(let dictionary):
|
||||
// TODO: test
|
||||
case .NamedValues(let namedValues):
|
||||
for (index, argumentName) in sqliteArgumentNames.enumerate() {
|
||||
if let argumentName = argumentName, let value = dictionary[argumentName] {
|
||||
if let argumentName = argumentName, let value = namedValues[argumentName] {
|
||||
try! bindDatabaseValue(value?.databaseValue ?? .Null, atIndex: Int32(index + 1))
|
||||
}
|
||||
}
|
||||
@@ -179,10 +178,10 @@ public class Statement {
|
||||
// If one of the values is nil, then we have a missing argument.
|
||||
let keyValueBindings: [(String?, DatabaseValue?)] = {
|
||||
switch arguments.kind {
|
||||
case .Array(let array):
|
||||
case .Values(let values):
|
||||
var keyValueBindings: [(String?, DatabaseValue?)] = []
|
||||
var argumentNameGen = sqliteArgumentNames.generate()
|
||||
var valuesGen = array.map { $0?.databaseValue ?? .Null }.generate()
|
||||
var valuesGen = values.map { $0?.databaseValue ?? .Null }.generate()
|
||||
var argumentNameOpt = argumentNameGen.next()
|
||||
var valueOpt = valuesGen.next()
|
||||
outer: while true {
|
||||
@@ -203,10 +202,10 @@ public class Statement {
|
||||
}
|
||||
return keyValueBindings
|
||||
|
||||
case .Dictionary(let dictionary):
|
||||
case .NamedValues(let namedValues):
|
||||
return sqliteArgumentNames.map { argumentName in
|
||||
if let argumentName = argumentName {
|
||||
if let value = dictionary[argumentName] {
|
||||
if let value = namedValues[argumentName] {
|
||||
return (argumentName, value?.databaseValue ?? .Null)
|
||||
} else {
|
||||
return (argumentName, nil)
|
||||
@@ -292,21 +291,19 @@ public final class SelectStatement : Statement {
|
||||
|
||||
/// The column index, case insensitive.
|
||||
func indexForColumn(named name: String) -> Int? {
|
||||
return lowercaseColumnIndexes[name] ?? lowercaseColumnIndexes[name.lowercaseString]
|
||||
}
|
||||
|
||||
/// Support for indexForColumn(named:)
|
||||
private lazy var lowercaseColumnIndexes: [String: Int] = {
|
||||
var indexes = [String: Int]()
|
||||
let count = self.columnCount
|
||||
// Reverse so that we return indexes for the leftmost columns.
|
||||
// SELECT 1 AS a, 2 AS a -> lowercaseColumnIndexes["a”] = 0
|
||||
for (index, columnName) in self.columnNames.reverse().enumerate() {
|
||||
indexes[columnName.lowercaseString] = count - index - 1
|
||||
// This is faster than dictionary lookup
|
||||
for (index, column) in columnNames.enumerate() {
|
||||
if column == name {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return indexes
|
||||
}()
|
||||
|
||||
for (index, column) in columnNames.enumerate() {
|
||||
if column.lowercaseString == name.lowercaseString {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
/// A sequence of elements fetched from the database.
|
||||
@@ -480,37 +477,36 @@ public struct StatementArguments {
|
||||
|
||||
/// Initializes arguments from a sequence of optional values.
|
||||
///
|
||||
/// let values: [String?] = ["foo", "bar", nil]
|
||||
/// let values: [DatabaseValueConvertible?] = ["foo", 1, nil]
|
||||
/// db.execute("INSERT ... (?,?,?)", arguments: StatementArguments(values))
|
||||
///
|
||||
/// - parameter sequence: A sequence of optional values that adopt the
|
||||
/// DatabaseValueConvertible protocol.
|
||||
/// - parameter sequence: A sequence of DatabaseValueConvertible values.
|
||||
/// - returns: A StatementArguments.
|
||||
public init<Sequence: SequenceType where Sequence.Generator.Element == Optional<DatabaseValueConvertible>>(_ sequence: Sequence) {
|
||||
kind = .Array(Array(sequence))
|
||||
public init<Sequence: SequenceType where Sequence.Generator.Element == DatabaseValueConvertible?>(_ sequence: Sequence) {
|
||||
kind = .Values(Array(sequence))
|
||||
}
|
||||
|
||||
|
||||
// MARK: Named Arguments
|
||||
|
||||
/// Initializes arguments from a dictionary of optional values.
|
||||
/// Initializes arguments from a sequence of (key, value) pairs, such as
|
||||
/// a dictionary.
|
||||
///
|
||||
/// let values: [String: String?] = ["firstName": nil, "lastName": "Miller"]
|
||||
/// let values: [String: DatabaseValueConvertible?] = ["firstName": nil, "lastName": "Miller"]
|
||||
/// db.execute("INSERT ... (:firstName, :lastName)", arguments: StatementArguments(values))
|
||||
///
|
||||
/// - parameter dictionary: A dictionary of optional values that adopt the
|
||||
/// DatabaseValueConvertible protocol.
|
||||
/// - parameter sequence: A sequence of (key, value) pairs
|
||||
/// - returns: A StatementArguments.
|
||||
public init(_ dictionary: [String: DatabaseValueConvertible?]) {
|
||||
kind = .Dictionary(dictionary)
|
||||
public init<Sequence: SequenceType where Sequence.Generator.Element == (String, DatabaseValueConvertible?)>(_ sequence: Sequence) {
|
||||
kind = .NamedValues(Dictionary(sequence))
|
||||
}
|
||||
|
||||
public var isEmpty: Bool {
|
||||
switch kind {
|
||||
case .Array(let array):
|
||||
return array.isEmpty
|
||||
case .Dictionary(let dictionary):
|
||||
return dictionary.isEmpty
|
||||
case .Values(let values):
|
||||
return values.isEmpty
|
||||
case .NamedValues(let namedValues):
|
||||
return namedValues.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,15 +514,11 @@ public struct StatementArguments {
|
||||
// MARK: Not Public
|
||||
|
||||
enum Kind {
|
||||
case Array([DatabaseValueConvertible?])
|
||||
case Dictionary([String: DatabaseValueConvertible?])
|
||||
case Values([DatabaseValueConvertible?])
|
||||
case NamedValues(Dictionary<String, DatabaseValueConvertible?>)
|
||||
}
|
||||
|
||||
let kind: Kind
|
||||
|
||||
private init(kind: Kind) {
|
||||
self.kind = kind
|
||||
}
|
||||
}
|
||||
|
||||
extension StatementArguments : ArrayLiteralConvertible {
|
||||
@@ -543,11 +535,7 @@ extension StatementArguments : DictionaryLiteralConvertible {
|
||||
///
|
||||
/// db.selectRows("SELECT ...", arguments: ["name": "Arthur", "age": 41])
|
||||
public init(dictionaryLiteral elements: (String, DatabaseValueConvertible?)...) {
|
||||
var dictionary = [String: DatabaseValueConvertible?]()
|
||||
for (key, value) in elements {
|
||||
dictionary[key] = value
|
||||
}
|
||||
self.init(dictionary)
|
||||
self.init(elements)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,7 +543,7 @@ extension StatementArguments : CustomStringConvertible {
|
||||
/// A textual representation of `self`.
|
||||
public var description: String {
|
||||
switch kind {
|
||||
case .Array(let values):
|
||||
case .Values(let values):
|
||||
return "["
|
||||
+ values
|
||||
.map { value in
|
||||
@@ -568,9 +556,9 @@ extension StatementArguments : CustomStringConvertible {
|
||||
.joinWithSeparator(", ")
|
||||
+ "]"
|
||||
|
||||
case .Dictionary(let dictionary):
|
||||
case .NamedValues(let namedValues):
|
||||
return "["
|
||||
+ dictionary.map { (key, value) in
|
||||
+ namedValues.map { (key, value) in
|
||||
if let value = value {
|
||||
return "\(key):\(String(reflecting: value))"
|
||||
} else {
|
||||
@@ -584,6 +572,18 @@ extension StatementArguments : CustomStringConvertible {
|
||||
}
|
||||
|
||||
|
||||
extension Dictionary {
|
||||
|
||||
/// Creates a dictionary with the keys and values in the given sequence.
|
||||
init<Sequence: SequenceType where Sequence.Generator.Element == Generator.Element>(_ sequence: Sequence) {
|
||||
self.init(minimumCapacity: sequence.underestimateCount())
|
||||
for (key, value) in sequence {
|
||||
self[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SQLite identifier quoting
|
||||
|
||||
extension String {
|
||||
|
||||
@@ -5,7 +5,7 @@ extension CGFloat : DatabaseValueConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(Double(self))
|
||||
return Double(self).databaseValue
|
||||
}
|
||||
|
||||
/// Returns a value initialized from *databaseValue*, if possible.
|
||||
|
||||
@@ -22,7 +22,7 @@ public struct DatabaseCoder: DatabaseValueConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(NSKeyedArchiver.archivedDataWithRootObject(object))
|
||||
return NSKeyedArchiver.archivedDataWithRootObject(object).databaseValue
|
||||
}
|
||||
|
||||
/// Returns a DatabaseCoder if *databaseValue* contains an archived object.
|
||||
|
||||
@@ -95,7 +95,7 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
|
||||
timeString = nil
|
||||
}
|
||||
|
||||
return DatabaseValue([dateString, timeString].flatMap { $0 }.joinWithSeparator(" "))
|
||||
return [dateString, timeString].flatMap { $0 }.joinWithSeparator(" ").databaseValue
|
||||
}
|
||||
|
||||
/// Returns a DatabaseDateComponents if *databaseValue* contains a
|
||||
|
||||
@@ -13,7 +13,7 @@ extension DatabaseValue {
|
||||
guard let convertible = object as? DatabaseValueConvertible else {
|
||||
return nil
|
||||
}
|
||||
self.init(convertible.databaseValue)
|
||||
self.init(storage: convertible.databaseValue.storage)
|
||||
}
|
||||
|
||||
/// Converts a DatabaseValue to AnyObject.
|
||||
|
||||
@@ -4,7 +4,12 @@ import Foundation
|
||||
extension NSData : DatabaseValueConvertible {
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(self)
|
||||
if length == 0 {
|
||||
// SQLite cant' store zero-length blobs.
|
||||
return .Null
|
||||
} else {
|
||||
return DatabaseValue(storage: .Blob(self))
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an NSData initialized from *databaseValue*, if it contains
|
||||
|
||||
@@ -6,7 +6,7 @@ extension NSDate : DatabaseValueConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(storageDateFormatter.stringFromDate(self))
|
||||
return storageDateFormatter.stringFromDate(self).databaseValue
|
||||
}
|
||||
|
||||
/// Returns an NSDate initialized from *databaseValue*, if possible.
|
||||
|
||||
@@ -5,7 +5,7 @@ extension NSString: DatabaseValueConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(self as String)
|
||||
return (self as String).databaseValue
|
||||
}
|
||||
|
||||
/// Returns an NSString initialized from *databaseValue*, if possible.
|
||||
|
||||
@@ -6,7 +6,7 @@ extension NSURL : DatabaseValueConvertible {
|
||||
/// Returns a value that can be stored in the database.
|
||||
/// (the URL's absoluteString).
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(absoluteString)
|
||||
return absoluteString.databaseValue
|
||||
}
|
||||
|
||||
/// Returns an NSURL initialized from *databaseValue*, if possible.
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.39.0</string>
|
||||
<string>0.40.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
+60
-19
@@ -134,16 +134,8 @@ public class Record : RowConvertible, DatabaseTableMapping, DatabasePersistable
|
||||
/// false does not prevent it from turning true on subsequent modifications
|
||||
/// of the record.
|
||||
public var hasPersistentChangedValues: Bool {
|
||||
get {
|
||||
return generatePersistentChangedValues().next() != nil
|
||||
}
|
||||
set {
|
||||
if newValue {
|
||||
referenceRow = nil
|
||||
} else {
|
||||
referenceRow = Row(persistentDictionary)
|
||||
}
|
||||
}
|
||||
get { return generatePersistentChangedValues().next() != nil }
|
||||
set { referenceRow = newValue ? nil : Row(persistentDictionary) }
|
||||
}
|
||||
|
||||
/// A dictionary of changes that have not been saved.
|
||||
@@ -156,11 +148,7 @@ public class Record : RowConvertible, DatabaseTableMapping, DatabasePersistable
|
||||
///
|
||||
/// See `hasPersistentChangedValues` for more information.
|
||||
public var persistentChangedValues: [String: DatabaseValue?] {
|
||||
var changes: [String: DatabaseValue?] = [:]
|
||||
for (column: column, old: old) in generatePersistentChangedValues() {
|
||||
changes[column] = old
|
||||
}
|
||||
return changes
|
||||
return Dictionary(generatePersistentChangedValues())
|
||||
}
|
||||
|
||||
// A change generator that is used by both hasPersistentChangedValues and
|
||||
@@ -205,8 +193,43 @@ public class Record : RowConvertible, DatabaseTableMapping, DatabasePersistable
|
||||
/// - parameter db: A Database.
|
||||
/// - throws: A DatabaseError whenever a SQLite error occurs.
|
||||
public func insert(db: Database) throws {
|
||||
try performInsert(db)
|
||||
hasPersistentChangedValues = false
|
||||
// The simplest code would be:
|
||||
//
|
||||
// try performInsert(db)
|
||||
// hasPersistentChangedValues = false
|
||||
//
|
||||
// But this triggers two calls to persistentDictionary, and this is both
|
||||
// costly, and ambiguous. Costly because persistentDictionary is slow.
|
||||
// Ambiguous because persistentDictionary may return a different value.
|
||||
//
|
||||
// So let's provide our custom implementation of insert, which uses the
|
||||
// same persistentDictionary for both insertion, and change tracking.
|
||||
|
||||
let dataMapper = DataMapper(db, self)
|
||||
var persistentDictionary = dataMapper.persistentDictionary
|
||||
let changes = try dataMapper.insertStatement().execute()
|
||||
if let rowID = changes.insertedRowID {
|
||||
if case .RowID(let column) = dataMapper.primaryKey {
|
||||
// Update persistentDictionary with inserted id
|
||||
if persistentDictionary[column] != nil {
|
||||
persistentDictionary[column] = rowID
|
||||
} else {
|
||||
let lowercaseColumn = column.lowercaseString
|
||||
for persistentColumn in persistentDictionary.keys {
|
||||
if lowercaseColumn == persistentColumn.lowercaseString {
|
||||
persistentDictionary[persistentColumn] = rowID
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
didInsertWithRowID(rowID, forColumn: column)
|
||||
} else {
|
||||
didInsertWithRowID(rowID, forColumn: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// Set hasPersistentChangedValues to false
|
||||
referenceRow = Row(persistentDictionary)
|
||||
}
|
||||
|
||||
/// Executes an UPDATE statement.
|
||||
@@ -222,8 +245,26 @@ public class Record : RowConvertible, DatabaseTableMapping, DatabasePersistable
|
||||
/// PersistenceError.NotFound is thrown if the primary key does not match
|
||||
/// any row in the database and record could not be updated.
|
||||
public func update(db: Database) throws {
|
||||
try performUpdate(db)
|
||||
hasPersistentChangedValues = false
|
||||
// The simplest code would be:
|
||||
//
|
||||
// try performUpdate(db)
|
||||
// hasPersistentChangedValues = false
|
||||
//
|
||||
// But this triggers two calls to persistentDictionary, and this is both
|
||||
// costly, and ambiguous. Costly because persistentDictionary is slow.
|
||||
// Ambiguous because persistentDictionary may return a different value.
|
||||
//
|
||||
// So let's provide our custom implementation of insert, which uses the
|
||||
// same persistentDictionary for both update, and change tracking.
|
||||
|
||||
let dataMapper = DataMapper(db, self)
|
||||
let changes = try dataMapper.updateStatement().execute()
|
||||
if changes.changedRowCount == 0 {
|
||||
throw PersistenceError.NotFound(self)
|
||||
}
|
||||
|
||||
// Set hasPersistentChangedValues to false
|
||||
referenceRow = Row(dataMapper.persistentDictionary)
|
||||
}
|
||||
|
||||
/// Executes an INSERT or an UPDATE statement so that `self` is saved in
|
||||
|
||||
@@ -25,7 +25,7 @@ extension DatabaseIntRepresentable {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(Int64(rawValue))
|
||||
return rawValue.databaseValue
|
||||
}
|
||||
|
||||
/// Returns a value initialized from *databaseValue*, if possible.
|
||||
@@ -68,7 +68,7 @@ extension DatabaseInt32Representable {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(Int64(rawValue))
|
||||
return rawValue.databaseValue
|
||||
}
|
||||
|
||||
/// Returns a value initialized from *databaseValue*, if possible.
|
||||
@@ -111,7 +111,7 @@ extension DatabaseInt64Representable {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(rawValue)
|
||||
return rawValue.databaseValue
|
||||
}
|
||||
|
||||
/// Returns a value initialized from *databaseValue*, if possible.
|
||||
@@ -154,7 +154,7 @@ extension DatabaseStringRepresentable {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(rawValue)
|
||||
return rawValue.databaseValue
|
||||
}
|
||||
|
||||
/// Returns a value initialized from *databaseValue*, if possible.
|
||||
|
||||
@@ -11,7 +11,7 @@ extension Bool: DatabaseValueConvertible, SQLiteStatementConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(Int64(self ? 1 : 0))
|
||||
return (self ? 1 : 0).databaseValue
|
||||
}
|
||||
|
||||
/// Returns a Bool initialized from *databaseValue*, if possible.
|
||||
@@ -99,7 +99,7 @@ extension Int: DatabaseValueConvertible, SQLiteStatementConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(Int64(self))
|
||||
return Int64(self).databaseValue
|
||||
}
|
||||
|
||||
/// Returns an Int initialized from *databaseValue*, if possible.
|
||||
@@ -131,7 +131,7 @@ extension Int32: DatabaseValueConvertible, SQLiteStatementConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(Int64(self))
|
||||
return Int64(self).databaseValue
|
||||
}
|
||||
|
||||
/// Returns an Int32 initialized from *databaseValue*, if possible.
|
||||
@@ -163,7 +163,7 @@ extension Int64: DatabaseValueConvertible, SQLiteStatementConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(self)
|
||||
return DatabaseValue(storage: .Int64(self))
|
||||
}
|
||||
|
||||
/// Returns an Int64 initialized from *databaseValue*, if possible.
|
||||
@@ -195,7 +195,7 @@ extension Double: DatabaseValueConvertible, SQLiteStatementConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(self)
|
||||
return DatabaseValue(storage: .Double(self))
|
||||
}
|
||||
|
||||
/// Returns a Double initialized from *databaseValue*, if possible.
|
||||
@@ -227,7 +227,7 @@ extension Float: DatabaseValueConvertible, SQLiteStatementConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(Double(self))
|
||||
return Double(self).databaseValue
|
||||
}
|
||||
|
||||
/// Returns a Float initialized from *databaseValue*, if possible.
|
||||
@@ -260,7 +260,7 @@ extension String: DatabaseValueConvertible, SQLiteStatementConvertible {
|
||||
|
||||
/// Returns a value that can be stored in the database.
|
||||
public var databaseValue: DatabaseValue {
|
||||
return DatabaseValue(self)
|
||||
return DatabaseValue(storage: .String(self))
|
||||
}
|
||||
|
||||
/// Returns a String initialized from *databaseValue*, if possible.
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
// To run this playground, select and build the GRDBOSX scheme.
|
||||
//
|
||||
// This sample code shows how to synchronize a database table with a JSON
|
||||
// payload with as few SQL queries as possible. In particular, useless UPDATE
|
||||
// statement are avoided.
|
||||
// This sample code shows how to use GRDB to synchronize a database table
|
||||
// with a JSON payload. We use as few SQL queries as possible:
|
||||
//
|
||||
// - Only one SELECT query.
|
||||
// - One query per insert, delete, and update.
|
||||
// - Useless UPDATE statements are avoided.
|
||||
|
||||
import Foundation
|
||||
import GRDB
|
||||
|
||||
|
||||
// Create the databsae
|
||||
// Open an in-memory database that logs all its SQL statements
|
||||
|
||||
var configuration = Configuration()
|
||||
configuration.trace = LogSQL
|
||||
let dbQueue = DatabaseQueue(configuration: configuration) // Memory database
|
||||
configuration.trace = { print($0) }
|
||||
let dbQueue = DatabaseQueue(configuration: configuration)
|
||||
|
||||
|
||||
// Create a database table
|
||||
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
@@ -22,9 +29,9 @@ try dbQueue.inDatabase { db in
|
||||
}
|
||||
|
||||
|
||||
// Person is a subclass of Record.
|
||||
// Define the Person subclass of GRDB's Record.
|
||||
//
|
||||
// We'll use the change tracking granted by the Record class to avoid useless
|
||||
// Record provides change tracking that helps avoiding useless
|
||||
// UPDATE statements.
|
||||
class Person : Record {
|
||||
var id: Int64?
|
||||
@@ -62,7 +69,7 @@ func synchronizePersonsWithJSON(jsonString: String, inDatabase db: Database) thr
|
||||
let jsonData = jsonString.dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
let json = try NSJSONSerialization.JSONObjectWithData(jsonData, options: []) as! NSDictionary
|
||||
|
||||
// A function that extracts an ID from a JSON person.
|
||||
// A support function that extracts an ID from a JSON person.
|
||||
func jsonPersonId(jsonPerson: NSDictionary) -> Int64 {
|
||||
return (jsonPerson["id"] as! NSNumber).longLongValue
|
||||
}
|
||||
@@ -72,11 +79,11 @@ func synchronizePersonsWithJSON(jsonString: String, inDatabase db: Database) thr
|
||||
return jsonPersonId($0) < jsonPersonId($1)
|
||||
}
|
||||
|
||||
// Load database persons, sorted by id.
|
||||
// Sort database persons by id:
|
||||
let persons = Person.fetchAll(db, "SELECT * FROM persons ORDER BY id")
|
||||
|
||||
// Now that both lists are sorted by id, we can compare them with
|
||||
// the sortedMerge() function.
|
||||
// Now that both lists are sorted by id, we can compare them with
|
||||
// the sortedMerge() function (see https://gist.github.com/groue/7e8510849ded36f7d770).
|
||||
//
|
||||
// We'll delete, insert or update persons, depending on their presence
|
||||
// in either lists.
|
||||
@@ -88,15 +95,15 @@ func synchronizePersonsWithJSON(jsonString: String, inDatabase db: Database) thr
|
||||
{
|
||||
switch mergeStep {
|
||||
case .Left(let person):
|
||||
// Database person without matching JSON person:
|
||||
// Delete database person without matching JSON person:
|
||||
try person.delete(db)
|
||||
case .Right(let jsonPerson):
|
||||
// JSON person without matching database person:
|
||||
let row = Row(dictionary: jsonPerson)!
|
||||
// Insert JSON person without matching database person:
|
||||
let row = Row(jsonPerson)! // Granted JSON keys are database columns
|
||||
let person = Person(row)
|
||||
try person.insert(db)
|
||||
case .Common(let person, let jsonPerson):
|
||||
// Matching database and JSON persons:
|
||||
// Update database person with its JSON counterpart:
|
||||
person.updateFromJSON(jsonPerson)
|
||||
if person.hasPersistentChangedValues {
|
||||
try person.update(db)
|
||||
|
||||
@@ -5,7 +5,7 @@ GRDB.swift is an [SQLite](https://www.sqlite.org) toolkit for Swift 2.
|
||||
|
||||
It ships with a low-level database API, plus application-level tools.
|
||||
|
||||
**January 11, 2016: GRDB.swift 0.39.0 is out** - [Release notes](CHANGELOG.md). Follow [@groue](http://twitter.com/groue) on Twitter for release announcements and usage tips.
|
||||
**January 14, 2016: GRDB.swift 0.40.0 is out** - [Release notes](CHANGELOG.md). Follow [@groue](http://twitter.com/groue) on Twitter for release announcements and usage tips.
|
||||
|
||||
**Requirements**: iOS 7.0+ / OSX 10.9+, Xcode 7+
|
||||
|
||||
@@ -41,7 +41,7 @@ Features
|
||||
Documentation
|
||||
=============
|
||||
|
||||
- **[GRDB Reference](http://cocoadocs.org/docsets/GRDB.swift/0.39.0/index.html)** (on cocoadocs.org)
|
||||
- **[GRDB Reference](http://cocoadocs.org/docsets/GRDB.swift/0.40.0/index.html)** (on cocoadocs.org)
|
||||
|
||||
- **[Installation](#installation)**
|
||||
|
||||
@@ -97,7 +97,7 @@ To use GRDB.swift with Cocoapods, specify in your Podfile:
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
use_frameworks!
|
||||
|
||||
pod 'GRDB.swift', '~> 0.39.0'
|
||||
pod 'GRDB.swift', '~> 0.40.0'
|
||||
```
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ pod 'GRDB.swift', '~> 0.39.0'
|
||||
To use GRDB.swift with Carthage, specify in your Cartfile:
|
||||
|
||||
```
|
||||
github "groue/GRDB.swift" ~> 0.39.0
|
||||
github "groue/GRDB.swift" ~> 0.40.0
|
||||
```
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ let dbQueue = try DatabaseQueue(
|
||||
configuration: config)
|
||||
```
|
||||
|
||||
See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.39.0/Structs/Configuration.html) and [Concurrency](#concurrency) for more details.
|
||||
See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.40.0/Structs/Configuration.html) and [Concurrency](#concurrency) for more details.
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user