mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Merge branch 'master' of https://github.com/groue/GRDB.swift into FetchedRecordsController
Conflicts: DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj DemoApps/GRDBDemoiOS/GRDBDemoiOS/AppDelegate.swift DemoApps/GRDBDemoiOS/GRDBDemoiOS/MasterViewController.swift GRDB.xcodeproj/project.pbxproj Tests/Performance/fmdb
This commit is contained in:
commit
042163eb58
136 files changed
+5418
-1602
No files matched your search
+4
-4
@@ -1,6 +1,6 @@
|
||||
[submodule "GRDB Tests/Performance/fmdb"]
|
||||
path = GRDB Tests/Performance/fmdb
|
||||
[submodule "Tests/Performance/fmdb"]
|
||||
path = Tests/Performance/fmdb
|
||||
url = https://github.com/ccgus/fmdb.git
|
||||
[submodule "GRDB Tests/Performance/SQLite.swift"]
|
||||
path = GRDB Tests/Performance/SQLite.swift
|
||||
[submodule "Tests/Performance/SQLite.swift"]
|
||||
path = Tests/Performance/SQLite.swift
|
||||
url = https://github.com/stephencelis/SQLite.swift.git
|
||||
+21
-3
@@ -1,6 +1,24 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
## 0.42.0
|
||||
|
||||
Released January 28, 2016
|
||||
|
||||
**New**
|
||||
|
||||
- The query interface lets you write pure Swift instead of SQL ([documentation](https://github.com/groue/GRDB.swift/#the-query-interface)):
|
||||
|
||||
```swift
|
||||
let wines = Wine.filter(origin == "Burgundy").order(price).fetchAll(db)
|
||||
```
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
- `DatabasePersistable` and `MutableDatabasePersistable` protocols have been renamed `Persistable` and `MutablePersistable` ([documentation](https://github.com/groue/GRDB.swift/#persistable-protocol))
|
||||
- `DatabaseTableMapping` protocol has been renamed `TableMapping` ([documentation](https://github.com/groue/GRDB.swift/#tablemapping-protocol))
|
||||
|
||||
|
||||
## 0.41.0
|
||||
|
||||
Released January 17, 2016
|
||||
@@ -137,7 +155,7 @@ Released December 28, 2015
|
||||
**Breaking Changes**
|
||||
|
||||
- Methods that return prepared statements can now throw errors ([documentation](https://github.com/groue/GRDB.swift#prepared-statements)).
|
||||
- `Row(dictionary:)` has been renamed `Row(_:)` ([documentation](https://github.com/groue/GRDB.swift#convenience-rows)).
|
||||
- `Row(dictionary:)` has been renamed `Row(_:)`.
|
||||
- `RowConvertible.awakeFromFetch()` now takes a database argument ([documentation](https://github.com/groue/GRDB.swift#rowconvertible-protocol)).
|
||||
|
||||
|
||||
@@ -155,7 +173,7 @@ Methods names that did not match [Swift 3 API Design Guidelines](https://swift.o
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
Record ([documentation](https://github.com/groue/GRDB.swift#record)):
|
||||
Record ([documentation](https://github.com/groue/GRDB.swift#record-class)):
|
||||
|
||||
- `Record.storedDatabaseDictionary` has been renamed `persistentDictionary`.
|
||||
- `Record.reload()` has been removed. You have to provide your own implementation, should you need reloading.
|
||||
@@ -171,7 +189,7 @@ Row:
|
||||
|
||||
DatabasePersistable:
|
||||
|
||||
- `DatabasePersistable.storedDatabaseDictionary` has been renamed `persistentDictionary` ([documentation](https://github.com/groue/GRDB.swift#databasepersistable-protocol)).
|
||||
- `DatabasePersistable.storedDatabaseDictionary` has been renamed `persistentDictionary` ([documentation](https://github.com/groue/GRDB.swift#persistable-protocol)).
|
||||
|
||||
DatabaseValue:
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
The Design of GRDB.swift
|
||||
========================
|
||||
|
||||
More than caveats or defects, there are a few glitches, or surprises in the GRDB.swift API. We try to explain them here. The interested readers can take them as Swift challenges!
|
||||
|
||||
|
||||
### Why must we provide query arguments in an Array, when Swift provides variadic method parameters?
|
||||
|
||||
I admit that the array argument below looks odd:
|
||||
|
||||
```swift
|
||||
Int.fetch(db,
|
||||
"SELECT COUNT(*) FROM persons WHERE name = ?",
|
||||
arguments: ["Arthur"])
|
||||
```
|
||||
|
||||
Well, GRDB provides three fetching methods for each fetchable type:
|
||||
|
||||
```swift
|
||||
// Row
|
||||
Row.fetch(db, "SELECT ...", arguments: ...) // DatabaseSequence<Row>
|
||||
Row.fetchAll(db, "SELECT ...", arguments: ...) // [Row]
|
||||
Row.fetchOne(db, "SELECT ...", arguments: ...) // Row?
|
||||
|
||||
// DatabaseValueConvertible
|
||||
String.fetch(db, "SELECT ...", arguments: ...) // DatabaseSequence<String>
|
||||
String.fetchAll(db, "SELECT ...", arguments: ...) // [String]
|
||||
String.fetchOne(db, "SELECT ...", arguments: ...) // String?
|
||||
|
||||
// Record (via RowConvertible)
|
||||
Person.fetch(db, "SELECT ...", arguments: ...) // DatabaseSequence<Person>
|
||||
Person.fetchAll(db, "SELECT ...", arguments: ...) // [Person]
|
||||
Person.fetchOne(db, "SELECT ...", arguments: ...) // Person?
|
||||
```
|
||||
|
||||
The `arguments` parameter type is StatementArguments, which is both ArrayLiteralConvertible and DictionaryLiteralConvertible, so that you can write both:
|
||||
|
||||
```swift
|
||||
Int.fetch(db,
|
||||
"SELECT COUNT(*) FROM persons WHERE name = ?",
|
||||
arguments: ["Arthur"])
|
||||
Int.fetch(db,
|
||||
"SELECT COUNT(*) FROM persons WHERE name = :name",
|
||||
arguments: ["name": "Arthur"])
|
||||
```
|
||||
|
||||
Without StatementArguments, that number would be six (three for Array and three for Dictionary), or even nine (three more for variadic parameters). I prefer limiting the API footprint: three methods per fetchable type is just quite fine.
|
||||
|
||||
Moreover, one of my pet peeves with SQLite is that it is a pain to write an SQL query with the `IN` operator. SQLite won't natively feed a single `?` placeholder with an array of values, and this forces users to build their own `IN(?,?,?,...)` SQL snippets:
|
||||
|
||||
```swift
|
||||
// Let's load persons whose name is in names:
|
||||
let names = ["Arthur", "Barbara"]
|
||||
let questionMarks = Array(count: names.count, repeatedValue: "?").joinWithSeparator(",") // OMG Swift come on
|
||||
let sql = "SELECT * FROM persons WHERE name IN (\(questionMarks))"
|
||||
let persons = Person.fetchAll(db, sql, arguments: StatementArguments(names))
|
||||
```
|
||||
|
||||
I wish that in a future version of GRDB we can write instead:
|
||||
|
||||
```swift
|
||||
Person.fetchAll(db,
|
||||
"SELECT * FROM persons WHERE name IN (?)",
|
||||
arguments: [["Arthur", "Barbara"]]) // one array argument
|
||||
Person.fetchAll(db,
|
||||
"SELECT * FROM persons WHERE name = ? OR name = ?",
|
||||
arguments: ["Arthur", "Barbara"]) // two string arguments
|
||||
```
|
||||
|
||||
This will require to distinguish arrays of values from arrays of arrays of values.
|
||||
@@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
56300B8A1C564EC8005A543B /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B891C564EC8005A543B /* Database.swift */; };
|
||||
56900E421BBFF7D500B815B5 /* PersonEditionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56900E411BBFF7D500B815B5 /* PersonEditionViewController.swift */; };
|
||||
56B8F4581B4E22B200C24296 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B8F4571B4E22B200C24296 /* AppDelegate.swift */; };
|
||||
56B8F45A1B4E22B200C24296 /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B8F4591B4E22B200C24296 /* MasterViewController.swift */; };
|
||||
@@ -102,6 +103,7 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
56300B891C564EC8005A543B /* Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Database.swift; sourceTree = "<group>"; };
|
||||
56900E411BBFF7D500B815B5 /* PersonEditionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersonEditionViewController.swift; sourceTree = "<group>"; };
|
||||
56B8F4541B4E22B200C24296 /* GRDBDemoiOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GRDBDemoiOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
56B8F4571B4E22B200C24296 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
@@ -204,6 +206,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56B8F4571B4E22B200C24296 /* AppDelegate.swift */,
|
||||
56300B891C564EC8005A543B /* Database.swift */,
|
||||
56900E3E1BBFF2E900B815B5 /* Controllers */,
|
||||
56900E3F1BBFF2F200B815B5 /* Models */,
|
||||
56900E3C1BBFF2C400B815B5 /* Resources */,
|
||||
@@ -338,6 +341,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56300B8A1C564EC8005A543B /* Database.swift in Sources */,
|
||||
56B8F45C1B4E22B200C24296 /* DetailViewController.swift in Sources */,
|
||||
56B8F45A1B4E22B200C24296 /* MasterViewController.swift in Sources */,
|
||||
56B8F4991B4E23AA00C24296 /* Person.swift in Sources */,
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import UIKit
|
||||
import GRDB
|
||||
|
||||
// The shared database queue, stored in a global.
|
||||
// It is created in AppDelegate.application(_:didFinishLaunchingWithOptions:)
|
||||
var dbQueue: DatabaseQueue!
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
|
||||
@@ -11,56 +6,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
|
||||
// Connect to the database
|
||||
|
||||
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! as NSString
|
||||
let databasePath = documentsPath.stringByAppendingPathComponent("db.sqlite")
|
||||
dbQueue = try! DatabaseQueue(path: databasePath)
|
||||
|
||||
|
||||
// Use DatabaseMigrator to setup the database
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"firstName TEXT, " +
|
||||
"lastName TEXT ," +
|
||||
"visible BOOLEAN DEFAULT TRUE ," +
|
||||
"position INTEGER " +
|
||||
")")
|
||||
}
|
||||
migrator.registerMigration("addPersons") { db in
|
||||
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
|
||||
try Person(firstName: "Barbra", lastName: "Streisand").insert(db)
|
||||
try Person(firstName: "Cinderella").insert(db)
|
||||
try Person(firstName: "John", lastName: "Appleseed").insert(db)
|
||||
try Person(firstName: "Kate", lastName: "Bell").insert(db)
|
||||
try Person(firstName: "Anna", lastName: "Haro").insert(db)
|
||||
try Person(firstName: "Daniel", lastName: "Higgins").insert(db)
|
||||
try Person(firstName: "David", lastName: "Taylor").insert(db)
|
||||
try Person(firstName: "Hank", lastName: "Zakroff").insert(db)
|
||||
try Person(firstName: "Steve", lastName: "Jobs").insert(db)
|
||||
try Person(firstName: "Bill", lastName: "Gates").insert(db)
|
||||
try Person(firstName: "Zlatan", lastName: "Ibrahimovic").insert(db)
|
||||
try Person(firstName: "Barack", lastName: "Obama").insert(db)
|
||||
try Person(firstName: "François", lastName: "Hollande").insert(db)
|
||||
try Person(firstName: "Britney", lastName: "Spears").insert(db)
|
||||
try Person(firstName: "Andre", lastName: "Agassi").insert(db)
|
||||
try Person(firstName: "Roger", lastName: "Federer").insert(db)
|
||||
try Person(firstName: "Rafael", lastName: "Nadal").insert(db)
|
||||
try Person(firstName: "Gael", lastName: "Monfils").insert(db)
|
||||
try Person(firstName: "Jo Wilfried", lastName: "Tsonga").insert(db)
|
||||
try Person(firstName: "Serena", lastName: "Williams").insert(db)
|
||||
try Person(firstName: "Venus", lastName: "Williams").insert(db)
|
||||
try Person(firstName: "Amélie", lastName: "Poulain").insert(db)
|
||||
}
|
||||
try! migrator.migrate(dbQueue)
|
||||
|
||||
|
||||
// Setup view controllers
|
||||
// Set up database
|
||||
setupDatabase()
|
||||
|
||||
// Set up view controllers
|
||||
let splitViewController = self.window!.rootViewController as! UISplitViewController
|
||||
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
|
||||
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
|
||||
@@ -82,4 +31,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import GRDB
|
||||
|
||||
// The columns for the GRDB Query Interface
|
||||
//
|
||||
// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
|
||||
struct Col {
|
||||
static let id = SQLColumn("id")
|
||||
static let firstName = SQLColumn("firstName")
|
||||
static let lastName = SQLColumn("lastName")
|
||||
}
|
||||
|
||||
|
||||
// The shared database queue, stored in a global.
|
||||
// It is initialized in setupDatabase()
|
||||
|
||||
var dbQueue: DatabaseQueue!
|
||||
|
||||
func setupDatabase() {
|
||||
|
||||
// Connect to the database
|
||||
//
|
||||
// See https://github.com/groue/GRDB.swift/#database-queues
|
||||
|
||||
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! as NSString
|
||||
let databasePath = documentsPath.stringByAppendingPathComponent("db.sqlite")
|
||||
dbQueue = try! DatabaseQueue(path: databasePath)
|
||||
|
||||
|
||||
// SQLite does not support Unicode: let's add a custom collation which will
|
||||
// allow us to sort persons by name.
|
||||
//
|
||||
// See https://github.com/groue/GRDB.swift/#string-comparison
|
||||
|
||||
let collation = DatabaseCollation("localized_case_insensitive") { (lhs, rhs) in
|
||||
return (lhs as NSString).localizedCaseInsensitiveCompare(rhs)
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
db.addCollation(collation)
|
||||
}
|
||||
|
||||
|
||||
// Use DatabaseMigrator to setup the database
|
||||
//
|
||||
// See https://github.com/groue/GRDB.swift/#migrations
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"firstName TEXT, " +
|
||||
"lastName TEXT ," +
|
||||
"visible BOOLEAN DEFAULT TRUE ," +
|
||||
"position INTEGER " +
|
||||
")")
|
||||
}
|
||||
migrator.registerMigration("addPersons") { db in
|
||||
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
|
||||
try Person(firstName: "Barbra", lastName: "Streisand").insert(db)
|
||||
try Person(firstName: "Cinderella").insert(db)
|
||||
try Person(firstName: "John", lastName: "Appleseed").insert(db)
|
||||
try Person(firstName: "Kate", lastName: "Bell").insert(db)
|
||||
try Person(firstName: "Anna", lastName: "Haro").insert(db)
|
||||
try Person(firstName: "Daniel", lastName: "Higgins").insert(db)
|
||||
try Person(firstName: "David", lastName: "Taylor").insert(db)
|
||||
try Person(firstName: "Hank", lastName: "Zakroff").insert(db)
|
||||
try Person(firstName: "Steve", lastName: "Jobs").insert(db)
|
||||
try Person(firstName: "Bill", lastName: "Gates").insert(db)
|
||||
try Person(firstName: "Zlatan", lastName: "Ibrahimovic").insert(db)
|
||||
try Person(firstName: "Barack", lastName: "Obama").insert(db)
|
||||
try Person(firstName: "François", lastName: "Hollande").insert(db)
|
||||
try Person(firstName: "Britney", lastName: "Spears").insert(db)
|
||||
try Person(firstName: "Andre", lastName: "Agassi").insert(db)
|
||||
try Person(firstName: "Roger", lastName: "Federer").insert(db)
|
||||
try Person(firstName: "Rafael", lastName: "Nadal").insert(db)
|
||||
try Person(firstName: "Gael", lastName: "Monfils").insert(db)
|
||||
try Person(firstName: "Jo Wilfried", lastName: "Tsonga").insert(db)
|
||||
try Person(firstName: "Serena", lastName: "Williams").insert(db)
|
||||
try Person(firstName: "Venus", lastName: "Williams").insert(db)
|
||||
try Person(firstName: "Amélie", lastName: "Poulain").insert(db)
|
||||
}
|
||||
try! migrator.migrate(dbQueue)
|
||||
}
|
||||
@@ -5,7 +5,7 @@ class Person : Record {
|
||||
var firstName: String?
|
||||
var lastName: String?
|
||||
var fullName: String {
|
||||
return [firstName, lastName].flatMap { $0 }.joinWithSeparator(" ")
|
||||
return [firstName, lastName].flatMap { $0 }.filter { !$0.isEmpty }.joinWithSeparator(" ")
|
||||
}
|
||||
var visible: Bool = true
|
||||
var position: Int64 = 0
|
||||
|
||||
@@ -15,36 +15,42 @@
|
||||
562FF9EC1BCE903D00759400 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 562FF9EB1BCE903D00759400 /* libsqlite3.tbd */; };
|
||||
562FF9EF1BCE912C00759400 /* PersonEditionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562FF9EE1BCE912C00759400 /* PersonEditionViewController.swift */; };
|
||||
562FF9F21BCE914E00759400 /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = 562FF9F11BCE914E00759400 /* Person.swift */; };
|
||||
563445081C4A8060003D3DC6 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563445071C4A8060003D3DC6 /* Utils.swift */; };
|
||||
56FCB3691C21210B00305D10 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3421C21210B00305D10 /* Configuration.swift */; };
|
||||
56FCB36A1C21210B00305D10 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3431C21210B00305D10 /* Database.swift */; };
|
||||
56FCB36C1C21210B00305D10 /* DatabaseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3451C21210B00305D10 /* DatabaseError.swift */; };
|
||||
56FCB36D1C21210B00305D10 /* DatabaseQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3461C21210B00305D10 /* DatabaseQueue.swift */; };
|
||||
56FCB36E1C21210B00305D10 /* DatabaseValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3471C21210B00305D10 /* DatabaseValue.swift */; };
|
||||
56FCB36F1C21210B00305D10 /* DatabasePersistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3491C21210B00305D10 /* DatabasePersistable.swift */; };
|
||||
56FCB3701C21210B00305D10 /* DatabaseTableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB34A1C21210B00305D10 /* DatabaseTableMapping.swift */; };
|
||||
56FCB3711C21210B00305D10 /* DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB34B1C21210B00305D10 /* DatabaseValueConvertible.swift */; };
|
||||
56FCB3721C21210B00305D10 /* RowConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB34C1C21210B00305D10 /* RowConvertible.swift */; };
|
||||
56FCB3731C21210B00305D10 /* SQLiteStatementConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB34D1C21210B00305D10 /* SQLiteStatementConvertible.swift */; };
|
||||
56FCB3741C21210B00305D10 /* Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB34E1C21210B00305D10 /* Row.swift */; };
|
||||
56FCB3761C21210B00305D10 /* Statement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3501C21210B00305D10 /* Statement.swift */; };
|
||||
56FCB3791C21210B00305D10 /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3541C21210B00305D10 /* CGFloat.swift */; };
|
||||
56FCB37A1C21210B00305D10 /* DatabaseCoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3561C21210B00305D10 /* DatabaseCoder.swift */; };
|
||||
56FCB37B1C21210B00305D10 /* DatabaseDateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3571C21210B00305D10 /* DatabaseDateComponents.swift */; };
|
||||
56FCB37C1C21210B00305D10 /* DatabaseValue+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3581C21210B00305D10 /* DatabaseValue+Foundation.swift */; };
|
||||
56FCB37D1C21210B00305D10 /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3591C21210B00305D10 /* NSData.swift */; };
|
||||
56FCB37E1C21210B00305D10 /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB35A1C21210B00305D10 /* NSDate.swift */; };
|
||||
56FCB37F1C21210B00305D10 /* NSNull.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB35B1C21210B00305D10 /* NSNull.swift */; };
|
||||
56FCB3801C21210B00305D10 /* NSNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB35C1C21210B00305D10 /* NSNumber.swift */; };
|
||||
56FCB3811C21210B00305D10 /* NSString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB35D1C21210B00305D10 /* NSString.swift */; };
|
||||
56FCB3821C21210B00305D10 /* NSURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB35E1C21210B00305D10 /* NSURL.swift */; };
|
||||
56FCB3831C21210B00305D10 /* Row+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB35F1C21210B00305D10 /* Row+Foundation.swift */; };
|
||||
56FCB3841C21210B00305D10 /* StatementArguments+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3601C21210B00305D10 /* StatementArguments+Foundation.swift */; };
|
||||
56FCB3851C21210B00305D10 /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3621C21210B00305D10 /* DatabaseMigrator.swift */; };
|
||||
56FCB3861C21210B00305D10 /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3631C21210B00305D10 /* Migration.swift */; };
|
||||
56FCB3871C21210B00305D10 /* Record.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3651C21210B00305D10 /* Record.swift */; };
|
||||
56FCB3881C21210B00305D10 /* RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3671C21210B00305D10 /* RawRepresentable.swift */; };
|
||||
56FCB3891C21210B00305D10 /* StandardLibraryTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FCB3681C21210B00305D10 /* StandardLibraryTypes.swift */; };
|
||||
566A20F31C58A4B300C5A218 /* AppDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20F21C58A4B300C5A218 /* AppDatabase.swift */; };
|
||||
566A21271C58A54F00C5A218 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20F61C58A54F00C5A218 /* Configuration.swift */; };
|
||||
566A21281C58A54F00C5A218 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20F71C58A54F00C5A218 /* Database.swift */; };
|
||||
566A21291C58A54F00C5A218 /* DatabaseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20F81C58A54F00C5A218 /* DatabaseError.swift */; };
|
||||
566A212A1C58A54F00C5A218 /* DatabaseQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20F91C58A54F00C5A218 /* DatabaseQueue.swift */; };
|
||||
566A212B1C58A54F00C5A218 /* DatabaseValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20FA1C58A54F00C5A218 /* DatabaseValue.swift */; };
|
||||
566A212C1C58A54F00C5A218 /* DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20FC1C58A54F00C5A218 /* DatabaseValueConvertible.swift */; };
|
||||
566A212D1C58A54F00C5A218 /* Persistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20FD1C58A54F00C5A218 /* Persistable.swift */; };
|
||||
566A212E1C58A54F00C5A218 /* RowConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20FE1C58A54F00C5A218 /* RowConvertible.swift */; };
|
||||
566A212F1C58A54F00C5A218 /* SQLiteStatementConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A20FF1C58A54F00C5A218 /* SQLiteStatementConvertible.swift */; };
|
||||
566A21301C58A54F00C5A218 /* TableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21001C58A54F00C5A218 /* TableMapping.swift */; };
|
||||
566A21311C58A54F00C5A218 /* Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21011C58A54F00C5A218 /* Row.swift */; };
|
||||
566A21321C58A54F00C5A218 /* Statement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21021C58A54F00C5A218 /* Statement.swift */; };
|
||||
566A21331C58A54F00C5A218 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21031C58A54F00C5A218 /* Utils.swift */; };
|
||||
566A21341C58A54F00C5A218 /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21051C58A54F00C5A218 /* CGFloat.swift */; };
|
||||
566A21351C58A54F00C5A218 /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21071C58A54F00C5A218 /* FetchRequest.swift */; };
|
||||
566A21361C58A54F00C5A218 /* Collation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21091C58A54F00C5A218 /* Collation.swift */; };
|
||||
566A21371C58A54F00C5A218 /* Function.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A210A1C58A54F00C5A218 /* Function.swift */; };
|
||||
566A21381C58A54F00C5A218 /* Operator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A210B1C58A54F00C5A218 /* Operator.swift */; };
|
||||
566A21391C58A54F00C5A218 /* SQLQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A210C1C58A54F00C5A218 /* SQLQuery.swift */; };
|
||||
566A213A1C58A54F00C5A218 /* DatabaseCoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A210E1C58A54F00C5A218 /* DatabaseCoder.swift */; };
|
||||
566A213B1C58A54F00C5A218 /* DatabaseDateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A210F1C58A54F00C5A218 /* DatabaseDateComponents.swift */; };
|
||||
566A213C1C58A54F00C5A218 /* DatabaseValue+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21101C58A54F00C5A218 /* DatabaseValue+Foundation.swift */; };
|
||||
566A213D1C58A54F00C5A218 /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21111C58A54F00C5A218 /* NSData.swift */; };
|
||||
566A213E1C58A54F00C5A218 /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21121C58A54F00C5A218 /* NSDate.swift */; };
|
||||
566A213F1C58A54F00C5A218 /* NSNull.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21131C58A54F00C5A218 /* NSNull.swift */; };
|
||||
566A21401C58A54F00C5A218 /* NSNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21141C58A54F00C5A218 /* NSNumber.swift */; };
|
||||
566A21411C58A54F00C5A218 /* NSString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21151C58A54F00C5A218 /* NSString.swift */; };
|
||||
566A21421C58A54F00C5A218 /* NSURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21161C58A54F00C5A218 /* NSURL.swift */; };
|
||||
566A21431C58A54F00C5A218 /* Row+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21171C58A54F00C5A218 /* Row+Foundation.swift */; };
|
||||
566A21441C58A54F00C5A218 /* StatementArguments+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21181C58A54F00C5A218 /* StatementArguments+Foundation.swift */; };
|
||||
566A21471C58A54F00C5A218 /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A211E1C58A54F00C5A218 /* DatabaseMigrator.swift */; };
|
||||
566A21481C58A54F00C5A218 /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A211F1C58A54F00C5A218 /* Migration.swift */; };
|
||||
566A214A1C58A54F00C5A218 /* Record.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21231C58A54F00C5A218 /* Record.swift */; };
|
||||
566A214B1C58A54F00C5A218 /* RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21251C58A54F00C5A218 /* RawRepresentable.swift */; };
|
||||
566A214C1C58A54F00C5A218 /* StandardLibraryTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A21261C58A54F00C5A218 /* StandardLibraryTypes.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -59,36 +65,42 @@
|
||||
562FF9EE1BCE912C00759400 /* PersonEditionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersonEditionViewController.swift; sourceTree = "<group>"; };
|
||||
562FF9F11BCE914E00759400 /* Person.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Person.swift; sourceTree = "<group>"; };
|
||||
562FF9F41BCE930C00759400 /* GRDBDemoiOS7-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GRDBDemoiOS7-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
563445071C4A8060003D3DC6 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
|
||||
56FCB3421C21210B00305D10 /* Configuration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
|
||||
56FCB3431C21210B00305D10 /* Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Database.swift; sourceTree = "<group>"; };
|
||||
56FCB3451C21210B00305D10 /* DatabaseError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseError.swift; sourceTree = "<group>"; };
|
||||
56FCB3461C21210B00305D10 /* DatabaseQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseQueue.swift; sourceTree = "<group>"; };
|
||||
56FCB3471C21210B00305D10 /* DatabaseValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValue.swift; sourceTree = "<group>"; };
|
||||
56FCB3491C21210B00305D10 /* DatabasePersistable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePersistable.swift; sourceTree = "<group>"; };
|
||||
56FCB34A1C21210B00305D10 /* DatabaseTableMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTableMapping.swift; sourceTree = "<group>"; };
|
||||
56FCB34B1C21210B00305D10 /* DatabaseValueConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConvertible.swift; sourceTree = "<group>"; };
|
||||
56FCB34C1C21210B00305D10 /* RowConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowConvertible.swift; sourceTree = "<group>"; };
|
||||
56FCB34D1C21210B00305D10 /* SQLiteStatementConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLiteStatementConvertible.swift; sourceTree = "<group>"; };
|
||||
56FCB34E1C21210B00305D10 /* Row.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Row.swift; sourceTree = "<group>"; };
|
||||
56FCB3501C21210B00305D10 /* Statement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Statement.swift; sourceTree = "<group>"; };
|
||||
56FCB3541C21210B00305D10 /* CGFloat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloat.swift; sourceTree = "<group>"; };
|
||||
56FCB3561C21210B00305D10 /* DatabaseCoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCoder.swift; sourceTree = "<group>"; };
|
||||
56FCB3571C21210B00305D10 /* DatabaseDateComponents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseDateComponents.swift; sourceTree = "<group>"; };
|
||||
56FCB3581C21210B00305D10 /* DatabaseValue+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DatabaseValue+Foundation.swift"; sourceTree = "<group>"; };
|
||||
56FCB3591C21210B00305D10 /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = "<group>"; };
|
||||
56FCB35A1C21210B00305D10 /* NSDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDate.swift; sourceTree = "<group>"; };
|
||||
56FCB35B1C21210B00305D10 /* NSNull.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSNull.swift; sourceTree = "<group>"; };
|
||||
56FCB35C1C21210B00305D10 /* NSNumber.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSNumber.swift; sourceTree = "<group>"; };
|
||||
56FCB35D1C21210B00305D10 /* NSString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSString.swift; sourceTree = "<group>"; };
|
||||
56FCB35E1C21210B00305D10 /* NSURL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSURL.swift; sourceTree = "<group>"; };
|
||||
56FCB35F1C21210B00305D10 /* Row+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+Foundation.swift"; sourceTree = "<group>"; };
|
||||
56FCB3601C21210B00305D10 /* StatementArguments+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatementArguments+Foundation.swift"; sourceTree = "<group>"; };
|
||||
56FCB3621C21210B00305D10 /* DatabaseMigrator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseMigrator.swift; sourceTree = "<group>"; };
|
||||
56FCB3631C21210B00305D10 /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = "<group>"; };
|
||||
56FCB3651C21210B00305D10 /* Record.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Record.swift; sourceTree = "<group>"; };
|
||||
56FCB3671C21210B00305D10 /* RawRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RawRepresentable.swift; sourceTree = "<group>"; };
|
||||
56FCB3681C21210B00305D10 /* StandardLibraryTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StandardLibraryTypes.swift; sourceTree = "<group>"; };
|
||||
566A20F21C58A4B300C5A218 /* AppDatabase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDatabase.swift; sourceTree = "<group>"; };
|
||||
566A20F61C58A54F00C5A218 /* Configuration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
|
||||
566A20F71C58A54F00C5A218 /* Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Database.swift; sourceTree = "<group>"; };
|
||||
566A20F81C58A54F00C5A218 /* DatabaseError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseError.swift; sourceTree = "<group>"; };
|
||||
566A20F91C58A54F00C5A218 /* DatabaseQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseQueue.swift; sourceTree = "<group>"; };
|
||||
566A20FA1C58A54F00C5A218 /* DatabaseValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValue.swift; sourceTree = "<group>"; };
|
||||
566A20FC1C58A54F00C5A218 /* DatabaseValueConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConvertible.swift; sourceTree = "<group>"; };
|
||||
566A20FD1C58A54F00C5A218 /* Persistable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Persistable.swift; sourceTree = "<group>"; };
|
||||
566A20FE1C58A54F00C5A218 /* RowConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowConvertible.swift; sourceTree = "<group>"; };
|
||||
566A20FF1C58A54F00C5A218 /* SQLiteStatementConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLiteStatementConvertible.swift; sourceTree = "<group>"; };
|
||||
566A21001C58A54F00C5A218 /* TableMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableMapping.swift; sourceTree = "<group>"; };
|
||||
566A21011C58A54F00C5A218 /* Row.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Row.swift; sourceTree = "<group>"; };
|
||||
566A21021C58A54F00C5A218 /* Statement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Statement.swift; sourceTree = "<group>"; };
|
||||
566A21031C58A54F00C5A218 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
|
||||
566A21051C58A54F00C5A218 /* CGFloat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloat.swift; sourceTree = "<group>"; };
|
||||
566A21071C58A54F00C5A218 /* FetchRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRequest.swift; sourceTree = "<group>"; };
|
||||
566A21091C58A54F00C5A218 /* Collation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Collation.swift; sourceTree = "<group>"; };
|
||||
566A210A1C58A54F00C5A218 /* Function.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Function.swift; sourceTree = "<group>"; };
|
||||
566A210B1C58A54F00C5A218 /* Operator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operator.swift; sourceTree = "<group>"; };
|
||||
566A210C1C58A54F00C5A218 /* SQLQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLQuery.swift; sourceTree = "<group>"; };
|
||||
566A210E1C58A54F00C5A218 /* DatabaseCoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCoder.swift; sourceTree = "<group>"; };
|
||||
566A210F1C58A54F00C5A218 /* DatabaseDateComponents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseDateComponents.swift; sourceTree = "<group>"; };
|
||||
566A21101C58A54F00C5A218 /* DatabaseValue+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DatabaseValue+Foundation.swift"; sourceTree = "<group>"; };
|
||||
566A21111C58A54F00C5A218 /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = "<group>"; };
|
||||
566A21121C58A54F00C5A218 /* NSDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDate.swift; sourceTree = "<group>"; };
|
||||
566A21131C58A54F00C5A218 /* NSNull.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSNull.swift; sourceTree = "<group>"; };
|
||||
566A21141C58A54F00C5A218 /* NSNumber.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSNumber.swift; sourceTree = "<group>"; };
|
||||
566A21151C58A54F00C5A218 /* NSString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSString.swift; sourceTree = "<group>"; };
|
||||
566A21161C58A54F00C5A218 /* NSURL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSURL.swift; sourceTree = "<group>"; };
|
||||
566A21171C58A54F00C5A218 /* Row+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+Foundation.swift"; sourceTree = "<group>"; };
|
||||
566A21181C58A54F00C5A218 /* StatementArguments+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatementArguments+Foundation.swift"; sourceTree = "<group>"; };
|
||||
566A211E1C58A54F00C5A218 /* DatabaseMigrator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseMigrator.swift; sourceTree = "<group>"; };
|
||||
566A211F1C58A54F00C5A218 /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = "<group>"; };
|
||||
566A21231C58A54F00C5A218 /* Record.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Record.swift; sourceTree = "<group>"; };
|
||||
566A21251C58A54F00C5A218 /* RawRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RawRepresentable.swift; sourceTree = "<group>"; };
|
||||
566A21261C58A54F00C5A218 /* StandardLibraryTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StandardLibraryTypes.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -123,6 +135,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
562FF9941BCE8FA400759400 /* AppDelegate.swift */,
|
||||
566A20F21C58A4B300C5A218 /* AppDatabase.swift */,
|
||||
562FF9F01BCE913900759400 /* Controllers */,
|
||||
562FF9F31BCE915B00759400 /* Models */,
|
||||
562FF9A61BCE8FB000759400 /* Resources */,
|
||||
@@ -151,25 +164,11 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
562FF9A81BCE900100759400 /* GRDB */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56FCB3411C21210B00305D10 /* Core */,
|
||||
56FCB3531C21210B00305D10 /* CoreGraphics */,
|
||||
56FCB3551C21210B00305D10 /* Foundation */,
|
||||
56FCB3611C21210B00305D10 /* Migrations */,
|
||||
56FCB3641C21210B00305D10 /* Record */,
|
||||
56FCB3661C21210B00305D10 /* Swift */,
|
||||
);
|
||||
name = GRDB;
|
||||
path = ../../GRDB;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
562FF9ED1BCE904D00759400 /* Libraries */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
562FF9EB1BCE903D00759400 /* libsqlite3.tbd */,
|
||||
562FF9A81BCE900100759400 /* GRDB */,
|
||||
566A20F41C58A54F00C5A218 /* GRDB */,
|
||||
);
|
||||
name = Libraries;
|
||||
sourceTree = "<group>";
|
||||
@@ -191,82 +190,117 @@
|
||||
name = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56FCB3411C21210B00305D10 /* Core */ = {
|
||||
566A20F41C58A54F00C5A218 /* GRDB */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56FCB3421C21210B00305D10 /* Configuration.swift */,
|
||||
56FCB3431C21210B00305D10 /* Database.swift */,
|
||||
56FCB3451C21210B00305D10 /* DatabaseError.swift */,
|
||||
56FCB3461C21210B00305D10 /* DatabaseQueue.swift */,
|
||||
56FCB3471C21210B00305D10 /* DatabaseValue.swift */,
|
||||
56FCB3481C21210B00305D10 /* Protocols */,
|
||||
56FCB34E1C21210B00305D10 /* Row.swift */,
|
||||
56FCB3501C21210B00305D10 /* Statement.swift */,
|
||||
563445071C4A8060003D3DC6 /* Utils.swift */,
|
||||
566A20F51C58A54F00C5A218 /* Core */,
|
||||
566A21041C58A54F00C5A218 /* CoreGraphics */,
|
||||
566A21061C58A54F00C5A218 /* FetchRequest */,
|
||||
566A210D1C58A54F00C5A218 /* Foundation */,
|
||||
566A211D1C58A54F00C5A218 /* Migrations */,
|
||||
566A21221C58A54F00C5A218 /* Record */,
|
||||
566A21241C58A54F00C5A218 /* Swift */,
|
||||
);
|
||||
name = GRDB;
|
||||
path = ../../../GRDB;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
566A20F51C58A54F00C5A218 /* Core */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
566A20F61C58A54F00C5A218 /* Configuration.swift */,
|
||||
566A20F71C58A54F00C5A218 /* Database.swift */,
|
||||
566A20F81C58A54F00C5A218 /* DatabaseError.swift */,
|
||||
566A20F91C58A54F00C5A218 /* DatabaseQueue.swift */,
|
||||
566A20FA1C58A54F00C5A218 /* DatabaseValue.swift */,
|
||||
566A20FB1C58A54F00C5A218 /* Protocols */,
|
||||
566A21011C58A54F00C5A218 /* Row.swift */,
|
||||
566A21021C58A54F00C5A218 /* Statement.swift */,
|
||||
566A21031C58A54F00C5A218 /* Utils.swift */,
|
||||
);
|
||||
path = Core;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56FCB3481C21210B00305D10 /* Protocols */ = {
|
||||
566A20FB1C58A54F00C5A218 /* Protocols */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56FCB3491C21210B00305D10 /* DatabasePersistable.swift */,
|
||||
56FCB34A1C21210B00305D10 /* DatabaseTableMapping.swift */,
|
||||
56FCB34B1C21210B00305D10 /* DatabaseValueConvertible.swift */,
|
||||
56FCB34C1C21210B00305D10 /* RowConvertible.swift */,
|
||||
56FCB34D1C21210B00305D10 /* SQLiteStatementConvertible.swift */,
|
||||
566A20FC1C58A54F00C5A218 /* DatabaseValueConvertible.swift */,
|
||||
566A20FD1C58A54F00C5A218 /* Persistable.swift */,
|
||||
566A20FE1C58A54F00C5A218 /* RowConvertible.swift */,
|
||||
566A20FF1C58A54F00C5A218 /* SQLiteStatementConvertible.swift */,
|
||||
566A21001C58A54F00C5A218 /* TableMapping.swift */,
|
||||
);
|
||||
path = Protocols;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56FCB3531C21210B00305D10 /* CoreGraphics */ = {
|
||||
566A21041C58A54F00C5A218 /* CoreGraphics */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56FCB3541C21210B00305D10 /* CGFloat.swift */,
|
||||
566A21051C58A54F00C5A218 /* CGFloat.swift */,
|
||||
);
|
||||
path = CoreGraphics;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56FCB3551C21210B00305D10 /* Foundation */ = {
|
||||
566A21061C58A54F00C5A218 /* FetchRequest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56FCB3561C21210B00305D10 /* DatabaseCoder.swift */,
|
||||
56FCB3571C21210B00305D10 /* DatabaseDateComponents.swift */,
|
||||
56FCB3581C21210B00305D10 /* DatabaseValue+Foundation.swift */,
|
||||
56FCB3591C21210B00305D10 /* NSData.swift */,
|
||||
56FCB35A1C21210B00305D10 /* NSDate.swift */,
|
||||
56FCB35B1C21210B00305D10 /* NSNull.swift */,
|
||||
56FCB35C1C21210B00305D10 /* NSNumber.swift */,
|
||||
56FCB35D1C21210B00305D10 /* NSString.swift */,
|
||||
56FCB35E1C21210B00305D10 /* NSURL.swift */,
|
||||
56FCB35F1C21210B00305D10 /* Row+Foundation.swift */,
|
||||
56FCB3601C21210B00305D10 /* StatementArguments+Foundation.swift */,
|
||||
566A21071C58A54F00C5A218 /* FetchRequest.swift */,
|
||||
566A21081C58A54F00C5A218 /* SQLSupport */,
|
||||
);
|
||||
path = FetchRequest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
566A21081C58A54F00C5A218 /* SQLSupport */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
566A21091C58A54F00C5A218 /* Collation.swift */,
|
||||
566A210A1C58A54F00C5A218 /* Function.swift */,
|
||||
566A210B1C58A54F00C5A218 /* Operator.swift */,
|
||||
566A210C1C58A54F00C5A218 /* SQLQuery.swift */,
|
||||
);
|
||||
path = SQLSupport;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
566A210D1C58A54F00C5A218 /* Foundation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
566A210E1C58A54F00C5A218 /* DatabaseCoder.swift */,
|
||||
566A210F1C58A54F00C5A218 /* DatabaseDateComponents.swift */,
|
||||
566A21101C58A54F00C5A218 /* DatabaseValue+Foundation.swift */,
|
||||
566A21111C58A54F00C5A218 /* NSData.swift */,
|
||||
566A21121C58A54F00C5A218 /* NSDate.swift */,
|
||||
566A21131C58A54F00C5A218 /* NSNull.swift */,
|
||||
566A21141C58A54F00C5A218 /* NSNumber.swift */,
|
||||
566A21151C58A54F00C5A218 /* NSString.swift */,
|
||||
566A21161C58A54F00C5A218 /* NSURL.swift */,
|
||||
566A21171C58A54F00C5A218 /* Row+Foundation.swift */,
|
||||
566A21181C58A54F00C5A218 /* StatementArguments+Foundation.swift */,
|
||||
);
|
||||
path = Foundation;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56FCB3611C21210B00305D10 /* Migrations */ = {
|
||||
566A211D1C58A54F00C5A218 /* Migrations */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56FCB3621C21210B00305D10 /* DatabaseMigrator.swift */,
|
||||
56FCB3631C21210B00305D10 /* Migration.swift */,
|
||||
566A211E1C58A54F00C5A218 /* DatabaseMigrator.swift */,
|
||||
566A211F1C58A54F00C5A218 /* Migration.swift */,
|
||||
);
|
||||
path = Migrations;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56FCB3641C21210B00305D10 /* Record */ = {
|
||||
566A21221C58A54F00C5A218 /* Record */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56FCB3651C21210B00305D10 /* Record.swift */,
|
||||
566A21231C58A54F00C5A218 /* Record.swift */,
|
||||
);
|
||||
path = Record;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56FCB3661C21210B00305D10 /* Swift */ = {
|
||||
566A21241C58A54F00C5A218 /* Swift */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56FCB3671C21210B00305D10 /* RawRepresentable.swift */,
|
||||
56FCB3681C21210B00305D10 /* StandardLibraryTypes.swift */,
|
||||
566A21251C58A54F00C5A218 /* RawRepresentable.swift */,
|
||||
566A21261C58A54F00C5A218 /* StandardLibraryTypes.swift */,
|
||||
);
|
||||
path = Swift;
|
||||
sourceTree = "<group>";
|
||||
@@ -341,40 +375,46 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56FCB3821C21210B00305D10 /* NSURL.swift in Sources */,
|
||||
56FCB3881C21210B00305D10 /* RawRepresentable.swift in Sources */,
|
||||
56FCB3841C21210B00305D10 /* StatementArguments+Foundation.swift in Sources */,
|
||||
56FCB37A1C21210B00305D10 /* DatabaseCoder.swift in Sources */,
|
||||
56FCB3891C21210B00305D10 /* StandardLibraryTypes.swift in Sources */,
|
||||
56FCB3731C21210B00305D10 /* SQLiteStatementConvertible.swift in Sources */,
|
||||
56FCB37F1C21210B00305D10 /* NSNull.swift in Sources */,
|
||||
56FCB37D1C21210B00305D10 /* NSData.swift in Sources */,
|
||||
56FCB36A1C21210B00305D10 /* Database.swift in Sources */,
|
||||
563445081C4A8060003D3DC6 /* Utils.swift in Sources */,
|
||||
56FCB37C1C21210B00305D10 /* DatabaseValue+Foundation.swift in Sources */,
|
||||
566A21381C58A54F00C5A218 /* Operator.swift in Sources */,
|
||||
566A21411C58A54F00C5A218 /* NSString.swift in Sources */,
|
||||
566A21401C58A54F00C5A218 /* NSNumber.swift in Sources */,
|
||||
566A21351C58A54F00C5A218 /* FetchRequest.swift in Sources */,
|
||||
566A21271C58A54F00C5A218 /* Configuration.swift in Sources */,
|
||||
562FF9EF1BCE912C00759400 /* PersonEditionViewController.swift in Sources */,
|
||||
56FCB3831C21210B00305D10 /* Row+Foundation.swift in Sources */,
|
||||
56FCB3711C21210B00305D10 /* DatabaseValueConvertible.swift in Sources */,
|
||||
56FCB3691C21210B00305D10 /* Configuration.swift in Sources */,
|
||||
56FCB3851C21210B00305D10 /* DatabaseMigrator.swift in Sources */,
|
||||
56FCB37E1C21210B00305D10 /* NSDate.swift in Sources */,
|
||||
562FF9971BCE8FA400759400 /* PersonsViewController.swift in Sources */,
|
||||
56FCB36E1C21210B00305D10 /* DatabaseValue.swift in Sources */,
|
||||
56FCB3791C21210B00305D10 /* CGFloat.swift in Sources */,
|
||||
56FCB3801C21210B00305D10 /* NSNumber.swift in Sources */,
|
||||
566A214B1C58A54F00C5A218 /* RawRepresentable.swift in Sources */,
|
||||
562FF9F21BCE914E00759400 /* Person.swift in Sources */,
|
||||
56FCB3701C21210B00305D10 /* DatabaseTableMapping.swift in Sources */,
|
||||
56FCB3861C21210B00305D10 /* Migration.swift in Sources */,
|
||||
56FCB3761C21210B00305D10 /* Statement.swift in Sources */,
|
||||
56FCB36C1C21210B00305D10 /* DatabaseError.swift in Sources */,
|
||||
56FCB3811C21210B00305D10 /* NSString.swift in Sources */,
|
||||
56FCB36F1C21210B00305D10 /* DatabasePersistable.swift in Sources */,
|
||||
566A212B1C58A54F00C5A218 /* DatabaseValue.swift in Sources */,
|
||||
562FF9951BCE8FA400759400 /* AppDelegate.swift in Sources */,
|
||||
56FCB3741C21210B00305D10 /* Row.swift in Sources */,
|
||||
56FCB36D1C21210B00305D10 /* DatabaseQueue.swift in Sources */,
|
||||
56FCB37B1C21210B00305D10 /* DatabaseDateComponents.swift in Sources */,
|
||||
56FCB3871C21210B00305D10 /* Record.swift in Sources */,
|
||||
56FCB3721C21210B00305D10 /* RowConvertible.swift in Sources */,
|
||||
566A213C1C58A54F00C5A218 /* DatabaseValue+Foundation.swift in Sources */,
|
||||
566A212D1C58A54F00C5A218 /* Persistable.swift in Sources */,
|
||||
566A21421C58A54F00C5A218 /* NSURL.swift in Sources */,
|
||||
566A21441C58A54F00C5A218 /* StatementArguments+Foundation.swift in Sources */,
|
||||
566A212E1C58A54F00C5A218 /* RowConvertible.swift in Sources */,
|
||||
566A21481C58A54F00C5A218 /* Migration.swift in Sources */,
|
||||
566A21291C58A54F00C5A218 /* DatabaseError.swift in Sources */,
|
||||
566A21281C58A54F00C5A218 /* Database.swift in Sources */,
|
||||
566A212C1C58A54F00C5A218 /* DatabaseValueConvertible.swift in Sources */,
|
||||
566A21331C58A54F00C5A218 /* Utils.swift in Sources */,
|
||||
566A214A1C58A54F00C5A218 /* Record.swift in Sources */,
|
||||
566A21321C58A54F00C5A218 /* Statement.swift in Sources */,
|
||||
566A21391C58A54F00C5A218 /* SQLQuery.swift in Sources */,
|
||||
566A21301C58A54F00C5A218 /* TableMapping.swift in Sources */,
|
||||
566A21431C58A54F00C5A218 /* Row+Foundation.swift in Sources */,
|
||||
566A214C1C58A54F00C5A218 /* StandardLibraryTypes.swift in Sources */,
|
||||
566A21341C58A54F00C5A218 /* CGFloat.swift in Sources */,
|
||||
566A21361C58A54F00C5A218 /* Collation.swift in Sources */,
|
||||
566A21311C58A54F00C5A218 /* Row.swift in Sources */,
|
||||
566A212A1C58A54F00C5A218 /* DatabaseQueue.swift in Sources */,
|
||||
566A213E1C58A54F00C5A218 /* NSDate.swift in Sources */,
|
||||
566A212F1C58A54F00C5A218 /* SQLiteStatementConvertible.swift in Sources */,
|
||||
566A20F31C58A4B300C5A218 /* AppDatabase.swift in Sources */,
|
||||
566A213F1C58A54F00C5A218 /* NSNull.swift in Sources */,
|
||||
566A213A1C58A54F00C5A218 /* DatabaseCoder.swift in Sources */,
|
||||
566A213B1C58A54F00C5A218 /* DatabaseDateComponents.swift in Sources */,
|
||||
566A213D1C58A54F00C5A218 /* NSData.swift in Sources */,
|
||||
566A21371C58A54F00C5A218 /* Function.swift in Sources */,
|
||||
566A21471C58A54F00C5A218 /* DatabaseMigrator.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import Foundation
|
||||
|
||||
|
||||
// The columns for the GRDB Query Interface
|
||||
//
|
||||
// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
|
||||
struct Col {
|
||||
static let id = SQLColumn("id")
|
||||
static let firstName = SQLColumn("firstName")
|
||||
static let lastName = SQLColumn("lastName")
|
||||
}
|
||||
|
||||
|
||||
// The shared database queue, stored in a global.
|
||||
// It is initialized in setupDatabase()
|
||||
|
||||
var dbQueue: DatabaseQueue!
|
||||
|
||||
func setupDatabase() {
|
||||
|
||||
// Connect to the database
|
||||
//
|
||||
// See https://github.com/groue/GRDB.swift/#database-queues
|
||||
|
||||
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! as NSString
|
||||
let databasePath = documentsPath.stringByAppendingPathComponent("db.sqlite")
|
||||
dbQueue = try! DatabaseQueue(path: databasePath)
|
||||
|
||||
|
||||
// SQLite does not support Unicode: let's add a custom collation which will
|
||||
// allow us to sort persons by name.
|
||||
//
|
||||
// See https://github.com/groue/GRDB.swift/#string-comparison
|
||||
|
||||
let collation = DatabaseCollation("localized_case_insensitive") { (lhs, rhs) in
|
||||
return (lhs as NSString).localizedCaseInsensitiveCompare(rhs)
|
||||
}
|
||||
|
||||
dbQueue.inDatabase { db in
|
||||
db.addCollation(collation)
|
||||
}
|
||||
|
||||
|
||||
// Use DatabaseMigrator to setup the database
|
||||
//
|
||||
// See https://github.com/groue/GRDB.swift/#migrations
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"firstName TEXT COLLATE localized_case_insensitive, " +
|
||||
"lastName TEXT COLLATE localized_case_insensitive" +
|
||||
")")
|
||||
}
|
||||
migrator.registerMigration("addPersons") { db in
|
||||
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
|
||||
try Person(firstName: "Barbra", lastName: "Streisand").insert(db)
|
||||
try Person(firstName: "Cinderella").insert(db)
|
||||
}
|
||||
try! migrator.migrate(dbQueue)
|
||||
}
|
||||
@@ -1,42 +1,12 @@
|
||||
import UIKit
|
||||
|
||||
// The shared database queue, stored in a global.
|
||||
// It is created in AppDelegate.application(_:didFinishLaunchingWithOptions:)
|
||||
var dbQueue: DatabaseQueue!
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
|
||||
// Connect to the database
|
||||
|
||||
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! as NSString
|
||||
let databasePath = documentsPath.stringByAppendingPathComponent("db.sqlite")
|
||||
dbQueue = try! DatabaseQueue(path: databasePath)
|
||||
|
||||
|
||||
// Use DatabaseMigrator to setup the database
|
||||
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"firstName TEXT, " +
|
||||
"lastName TEXT " +
|
||||
")")
|
||||
}
|
||||
migrator.registerMigration("addPersons") { db in
|
||||
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
|
||||
try Person(firstName: "Barbra", lastName: "Streisand").insert(db)
|
||||
try Person(firstName: "Cinderella").insert(db)
|
||||
}
|
||||
try! migrator.migrate(dbQueue)
|
||||
|
||||
|
||||
setupDatabase()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ class Person : Record {
|
||||
var firstName: String?
|
||||
var lastName: String?
|
||||
var fullName: String {
|
||||
return [firstName, lastName].flatMap { $0 }.joinWithSeparator(" ")
|
||||
return [firstName, lastName].flatMap { $0 }.filter { !$0.isEmpty }.joinWithSeparator(" ")
|
||||
}
|
||||
|
||||
init(firstName: String? = nil, lastName: String? = nil) {
|
||||
|
||||
@@ -14,7 +14,7 @@ class PersonsViewController: UITableViewController {
|
||||
|
||||
func reloadPersons() {
|
||||
persons = dbQueue.inDatabase { db in
|
||||
Person.fetchAll(db, "SELECT * FROM persons ORDER BY LOWER(firstName), LOWER(lastName)")
|
||||
Person.order(Col.firstName, Col.lastName).fetchAll(db)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ class PersonsViewController: UITableViewController {
|
||||
|
||||
let person = persons[indexPath.row]
|
||||
cell.textLabel!.text = person.fullName
|
||||
cell.selectionStyle = .None
|
||||
return cell
|
||||
}
|
||||
|
||||
@@ -75,6 +76,10 @@ class PersonsViewController: UITableViewController {
|
||||
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
|
||||
tableView.deselectRowAtIndexPath(indexPath, animated: true)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Submodule GRDB Tests/Performance/SQLite.swift deleted from 5638f1f791.
Submodule GRDB Tests/Performance/fmdb deleted from ed8362d846.
+2
-2
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'GRDB.swift'
|
||||
s.version = '0.41.0'
|
||||
s.version = '0.42.0'
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.summary = 'Versatile SQLite toolkit for Swift.'
|
||||
s.homepage = 'https://github.com/groue/GRDB.swift'
|
||||
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.9'
|
||||
s.requires_arc = true
|
||||
s.module_map = 'GRDB/module.modulemap'
|
||||
s.module_map = 'Support/module.modulemap'
|
||||
s.framework = 'Foundation'
|
||||
s.library = 'sqlite3'
|
||||
end
|
||||
+160
-134
@@ -12,8 +12,8 @@
|
||||
5606AF911C0ED37000D20487 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 56BB86301BA98AB0001F9168 /* libsqlite3.tbd */; };
|
||||
5607EFD31BB8254800605DE3 /* TransactionObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */; };
|
||||
5607EFD41BB827FD00605DE3 /* TransactionObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */; };
|
||||
560B3FAC1C19E01000C58EC7 /* DatabasePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560B3FAB1C19E01000C58EC7 /* DatabasePersistableTests.swift */; };
|
||||
560B3FAD1C19E01000C58EC7 /* DatabasePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560B3FAB1C19E01000C58EC7 /* DatabasePersistableTests.swift */; };
|
||||
560B3FAC1C19E01000C58EC7 /* PersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560B3FAB1C19E01000C58EC7 /* PersistableTests.swift */; };
|
||||
560B3FAD1C19E01000C58EC7 /* PersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560B3FAB1C19E01000C58EC7 /* PersistableTests.swift */; };
|
||||
560C97C71BFD0B8400BF8471 /* FunctionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560C97C61BFD0B8400BF8471 /* FunctionTests.swift */; };
|
||||
560C97C81BFD0B8400BF8471 /* FunctionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560C97C61BFD0B8400BF8471 /* FunctionTests.swift */; };
|
||||
560C97DA1C0E22D300BF8471 /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 56BB86191BA988F2001F9168 /* FMDatabase.m */; };
|
||||
@@ -30,18 +30,38 @@
|
||||
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 */; };
|
||||
56300B5F1C53C38F005A543B /* FetchRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B5D1C53C38F005A543B /* FetchRequestTests.swift */; };
|
||||
56300B611C53C42C005A543B /* RowConvertible+FetchRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B601C53C42C005A543B /* RowConvertible+FetchRequestTests.swift */; };
|
||||
56300B621C53C42C005A543B /* RowConvertible+FetchRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B601C53C42C005A543B /* RowConvertible+FetchRequestTests.swift */; };
|
||||
56300B661C53C8A7005A543B /* FetchRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B5D1C53C38F005A543B /* FetchRequestTests.swift */; };
|
||||
56300B681C53D25E005A543B /* SQLSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B671C53D25E005A543B /* SQLSupportTests.swift */; };
|
||||
56300B691C53D25E005A543B /* SQLSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B671C53D25E005A543B /* SQLSupportTests.swift */; };
|
||||
56300B6B1C53D3E8005A543B /* TableMapping+FetchRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6A1C53D3E8005A543B /* TableMapping+FetchRequestTests.swift */; };
|
||||
56300B6C1C53D3E8005A543B /* TableMapping+FetchRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6A1C53D3E8005A543B /* TableMapping+FetchRequestTests.swift */; };
|
||||
56300B781C53F592005A543B /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6F1C53F592005A543B /* FetchRequest.swift */; };
|
||||
56300B791C53F592005A543B /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6F1C53F592005A543B /* FetchRequest.swift */; };
|
||||
56300B7C1C53F592005A543B /* Collation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B721C53F592005A543B /* Collation.swift */; };
|
||||
56300B7D1C53F592005A543B /* Collation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B721C53F592005A543B /* Collation.swift */; };
|
||||
56300B7E1C53F592005A543B /* Function.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B731C53F592005A543B /* Function.swift */; };
|
||||
56300B7F1C53F592005A543B /* Function.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B731C53F592005A543B /* Function.swift */; };
|
||||
56300B801C53F592005A543B /* Operator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B741C53F592005A543B /* Operator.swift */; };
|
||||
56300B811C53F592005A543B /* Operator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B741C53F592005A543B /* Operator.swift */; };
|
||||
56300B821C53F592005A543B /* SQLQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B751C53F592005A543B /* SQLQuery.swift */; };
|
||||
56300B831C53F592005A543B /* SQLQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B751C53F592005A543B /* SQLQuery.swift */; };
|
||||
56300B851C54DC95005A543B /* Record+FetchRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B841C54DC95005A543B /* Record+FetchRequestTests.swift */; };
|
||||
56300B861C54DC95005A543B /* Record+FetchRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B841C54DC95005A543B /* Record+FetchRequestTests.swift */; };
|
||||
563445051C4A7FD7003D3DC6 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563445041C4A7FD7003D3DC6 /* Utils.swift */; };
|
||||
563445061C4A7FD7003D3DC6 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563445041C4A7FD7003D3DC6 /* Utils.swift */; };
|
||||
56437C841C180EDB007D6DB3 /* DatabasePersistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56437C831C180EDB007D6DB3 /* DatabasePersistable.swift */; };
|
||||
56437C851C180EDB007D6DB3 /* DatabasePersistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56437C831C180EDB007D6DB3 /* DatabasePersistable.swift */; };
|
||||
56437C841C180EDB007D6DB3 /* Persistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56437C831C180EDB007D6DB3 /* Persistable.swift */; };
|
||||
56437C851C180EDB007D6DB3 /* Persistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56437C831C180EDB007D6DB3 /* Persistable.swift */; };
|
||||
564A50C71BFF4B7F00B3A3A2 /* CollationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */; };
|
||||
564A50C81BFF4B7F00B3A3A2 /* CollationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */; };
|
||||
56553C101C3E906C00522B5C /* GRDBTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */; };
|
||||
56553C121C3E906C00522B5C /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 56BB86301BA98AB0001F9168 /* libsqlite3.tbd */; };
|
||||
56553C131C3E906C00522B5C /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; };
|
||||
56553C1A1C3E91BC00522B5C /* CrashTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CB92EC1BA453E500DFD5FC /* CrashTests.swift */; };
|
||||
5658420E1C1A1C820099FE88 /* MutableDatabasePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5658420D1C1A1C820099FE88 /* MutableDatabasePersistableTests.swift */; };
|
||||
5658420F1C1A1C820099FE88 /* MutableDatabasePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5658420D1C1A1C820099FE88 /* MutableDatabasePersistableTests.swift */; };
|
||||
5658420E1C1A1C820099FE88 /* MutablePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5658420D1C1A1C820099FE88 /* MutablePersistableTests.swift */; };
|
||||
5658420F1C1A1C820099FE88 /* MutablePersistableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5658420D1C1A1C820099FE88 /* MutablePersistableTests.swift */; };
|
||||
565B0FEF1BBC7D980098DE03 /* RowConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565B0FEE1BBC7D980098DE03 /* RowConvertibleTests.swift */; };
|
||||
565B0FF01BBC7D980098DE03 /* RowConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565B0FEE1BBC7D980098DE03 /* RowConvertibleTests.swift */; };
|
||||
565D5D681BBC604000DC9BD4 /* Row+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565D5D671BBC604000DC9BD4 /* Row+Foundation.swift */; };
|
||||
@@ -128,8 +148,8 @@
|
||||
56A2388C1B9C75030082EB20 /* Statement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238781B9C75030082EB20 /* Statement.swift */; };
|
||||
56A238931B9C750B0082EB20 /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238921B9C750B0082EB20 /* DatabaseMigrator.swift */; };
|
||||
56A238941B9C750B0082EB20 /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238921B9C750B0082EB20 /* DatabaseMigrator.swift */; };
|
||||
56A238991B9C752B0082EB20 /* DatabaseTableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238961B9C752B0082EB20 /* DatabaseTableMapping.swift */; };
|
||||
56A2389A1B9C752B0082EB20 /* DatabaseTableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238961B9C752B0082EB20 /* DatabaseTableMapping.swift */; };
|
||||
56A238991B9C752B0082EB20 /* TableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238961B9C752B0082EB20 /* TableMapping.swift */; };
|
||||
56A2389A1B9C752B0082EB20 /* TableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238961B9C752B0082EB20 /* TableMapping.swift */; };
|
||||
56A2389B1B9C752B0082EB20 /* DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238971B9C752B0082EB20 /* DatabaseValueConvertible.swift */; };
|
||||
56A2389C1B9C752B0082EB20 /* DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238971B9C752B0082EB20 /* DatabaseValueConvertible.swift */; };
|
||||
56A2389D1B9C752B0082EB20 /* RowConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238981B9C752B0082EB20 /* RowConvertible.swift */; };
|
||||
@@ -211,7 +231,7 @@
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = DC7253AB1B52ADEB009B38B1;
|
||||
remoteGlobalIDString = EE247B3B1C3F3ED000AE3E12;
|
||||
remoteInfo = "SQLite Mac";
|
||||
};
|
||||
560C97D31C0E22D300BF8471 /* PBXContainerItemProxy */ = {
|
||||
@@ -235,13 +255,6 @@
|
||||
remoteGlobalIDString = DC2B29E21B26F718001C60EA;
|
||||
remoteInfo = "SQLite iOS";
|
||||
};
|
||||
56CA220C1BB414FE009A04C5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = DC2B29EC1B26F718001C60EA;
|
||||
remoteInfo = "SQLite iOS Tests";
|
||||
};
|
||||
56CA220E1BB414FE009A04C5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
@@ -249,46 +262,11 @@
|
||||
remoteGlobalIDString = DC7253AC1B52ADEB009B38B1;
|
||||
remoteInfo = "SQLite Mac";
|
||||
};
|
||||
56CA22101BB414FE009A04C5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = DC7253B51B52ADEC009B38B1;
|
||||
remoteInfo = "SQLite Mac Tests";
|
||||
};
|
||||
56CA22121BB414FE009A04C5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = DCE7BB7A1B7434F90040D364;
|
||||
remoteInfo = "SQLiteCipher iOS";
|
||||
};
|
||||
56CA22141BB414FE009A04C5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = DCE7BB831B7434F90040D364;
|
||||
remoteInfo = "SQLiteCipher iOS Tests";
|
||||
};
|
||||
56CA22161BB414FE009A04C5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = DCE7BBB01B7438610040D364;
|
||||
remoteInfo = "SQLiteCipher Mac";
|
||||
};
|
||||
56CA22181BB414FE009A04C5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = DCE7BBB91B7438620040D364;
|
||||
remoteInfo = "SQLiteCipher Mac Tests";
|
||||
};
|
||||
56CA22271BB4165C009A04C5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = DC2B29E11B26F718001C60EA;
|
||||
remoteGlobalIDString = EE247AD21C3F04ED00AE3E12;
|
||||
remoteInfo = "SQLite iOS";
|
||||
};
|
||||
56E5D7D51B4D3FEE00430942 /* PBXContainerItemProxy */ = {
|
||||
@@ -305,22 +283,46 @@
|
||||
remoteGlobalIDString = DC3773F219C8CBB3004FCF85;
|
||||
remoteInfo = GRDBOSX;
|
||||
};
|
||||
56E667C91C5A422500D48792 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = EE247ADD1C3F04ED00AE3E12;
|
||||
remoteInfo = "SQLiteTests iOS";
|
||||
};
|
||||
56E667CB1C5A422500D48792 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 56CA21FE1BB414FE009A04C5 /* SQLite.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = EE247B451C3F3ED000AE3E12;
|
||||
remoteInfo = "SQLiteTests Mac";
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
317194B31C230DDD002E3BDA /* FetchedResultsControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedResultsControllerTests.swift; sourceTree = "<group>"; };
|
||||
31AEFE3E1C185E63003DB703 /* FetchedResultsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FetchedResultsController.swift; path = Record/FetchedResultsController.swift; sourceTree = "<group>"; };
|
||||
5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionObserverTests.swift; sourceTree = "<group>"; };
|
||||
560B3FAB1C19E01000C58EC7 /* DatabasePersistableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePersistableTests.swift; sourceTree = "<group>"; };
|
||||
560B3FAB1C19E01000C58EC7 /* PersistableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersistableTests.swift; sourceTree = "<group>"; };
|
||||
560C97C61BFD0B8400BF8471 /* FunctionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FunctionTests.swift; sourceTree = "<group>"; };
|
||||
560C981A1C0E22D300BF8471 /* GRDBOSXPerformanceTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXPerformanceTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5614DEEF1BA9DA15003163B3 /* SQLiteStatementConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLiteStatementConvertible.swift; sourceTree = "<group>"; };
|
||||
5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GRDBTestCase.swift; sourceTree = "<group>"; };
|
||||
56300B5D1C53C38F005A543B /* FetchRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRequestTests.swift; sourceTree = "<group>"; };
|
||||
56300B601C53C42C005A543B /* RowConvertible+FetchRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "RowConvertible+FetchRequestTests.swift"; sourceTree = "<group>"; };
|
||||
56300B671C53D25E005A543B /* SQLSupportTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLSupportTests.swift; sourceTree = "<group>"; };
|
||||
56300B6A1C53D3E8005A543B /* TableMapping+FetchRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableMapping+FetchRequestTests.swift"; sourceTree = "<group>"; };
|
||||
56300B6F1C53F592005A543B /* FetchRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRequest.swift; sourceTree = "<group>"; };
|
||||
56300B721C53F592005A543B /* Collation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Collation.swift; sourceTree = "<group>"; };
|
||||
56300B731C53F592005A543B /* Function.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Function.swift; sourceTree = "<group>"; };
|
||||
56300B741C53F592005A543B /* Operator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operator.swift; sourceTree = "<group>"; };
|
||||
56300B751C53F592005A543B /* SQLQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLQuery.swift; sourceTree = "<group>"; };
|
||||
56300B841C54DC95005A543B /* Record+FetchRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Record+FetchRequestTests.swift"; sourceTree = "<group>"; };
|
||||
563445041C4A7FD7003D3DC6 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
|
||||
56437C831C180EDB007D6DB3 /* DatabasePersistable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePersistable.swift; sourceTree = "<group>"; };
|
||||
56437C831C180EDB007D6DB3 /* Persistable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Persistable.swift; sourceTree = "<group>"; };
|
||||
564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollationTests.swift; sourceTree = "<group>"; };
|
||||
56553C181C3E906C00522B5C /* GRDBOSXCrashTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXCrashTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5658420D1C1A1C820099FE88 /* MutableDatabasePersistableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MutableDatabasePersistableTests.swift; sourceTree = "<group>"; };
|
||||
5658420D1C1A1C820099FE88 /* MutablePersistableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MutablePersistableTests.swift; sourceTree = "<group>"; };
|
||||
565B0FEE1BBC7D980098DE03 /* RowConvertibleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowConvertibleTests.swift; sourceTree = "<group>"; };
|
||||
565D5D671BBC604000DC9BD4 /* Row+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+Foundation.swift"; sourceTree = "<group>"; };
|
||||
565D5D701BBC694D00DC9BD4 /* Row+FoundationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+FoundationTests.swift"; sourceTree = "<group>"; };
|
||||
@@ -365,7 +367,7 @@
|
||||
56A238761B9C75030082EB20 /* Row.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Row.swift; sourceTree = "<group>"; };
|
||||
56A238781B9C75030082EB20 /* Statement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Statement.swift; sourceTree = "<group>"; };
|
||||
56A238921B9C750B0082EB20 /* DatabaseMigrator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseMigrator.swift; sourceTree = "<group>"; };
|
||||
56A238961B9C752B0082EB20 /* DatabaseTableMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTableMapping.swift; sourceTree = "<group>"; };
|
||||
56A238961B9C752B0082EB20 /* TableMapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableMapping.swift; sourceTree = "<group>"; };
|
||||
56A238971B9C752B0082EB20 /* DatabaseValueConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConvertible.swift; sourceTree = "<group>"; };
|
||||
56A238981B9C752B0082EB20 /* RowConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowConvertible.swift; sourceTree = "<group>"; };
|
||||
56A238A11B9C753B0082EB20 /* Record.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Record.swift; sourceTree = "<group>"; };
|
||||
@@ -428,9 +430,9 @@
|
||||
56FC78641BBAEB8C00CA1285 /* MappingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MappingTests.swift; sourceTree = "<group>"; };
|
||||
56FC78651BBAEB8C00CA1285 /* ManagedDataControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedDataControllerTests.swift; sourceTree = "<group>"; };
|
||||
56FDECE11BB32DFD009AD709 /* MetalRowTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetalRowTests.swift; sourceTree = "<group>"; };
|
||||
DC2393C61ABE35F8003FF113 /* GRDB-Bridging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GRDB-Bridging.h"; sourceTree = "<group>"; };
|
||||
DC2393C61ABE35F8003FF113 /* GRDB-Bridging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GRDB-Bridging.h"; path = "../GRDB/GRDB-Bridging.h"; sourceTree = "<group>"; };
|
||||
DC3773F319C8CBB3004FCF85 /* GRDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDB.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
DC3773F719C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../GRDB/Info.plist; sourceTree = "<group>"; };
|
||||
DC3773F719C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
DC3773F819C8CBB3004FCF85 /* GRDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GRDB.h; path = ../GRDB/GRDB.h; sourceTree = "<group>"; };
|
||||
DC37740419C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
DC37744219C8DC91004FCF85 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
|
||||
@@ -511,13 +513,13 @@
|
||||
path = TransactionObserver;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
560B3FA41C19DFF800C58EC7 /* DatabasePersistable */ = {
|
||||
560B3FA41C19DFF800C58EC7 /* Persistable */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
560B3FAB1C19E01000C58EC7 /* DatabasePersistableTests.swift */,
|
||||
5658420D1C1A1C820099FE88 /* MutableDatabasePersistableTests.swift */,
|
||||
560B3FAB1C19E01000C58EC7 /* PersistableTests.swift */,
|
||||
5658420D1C1A1C820099FE88 /* MutablePersistableTests.swift */,
|
||||
);
|
||||
path = DatabasePersistable;
|
||||
path = Persistable;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
560C97BF1BFD0B5B00BF8471 /* Function */ = {
|
||||
@@ -537,6 +539,38 @@
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56300B5C1C53C38F005A543B /* FetchRequest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56300B5D1C53C38F005A543B /* FetchRequestTests.swift */,
|
||||
56300B841C54DC95005A543B /* Record+FetchRequestTests.swift */,
|
||||
56300B601C53C42C005A543B /* RowConvertible+FetchRequestTests.swift */,
|
||||
56300B671C53D25E005A543B /* SQLSupportTests.swift */,
|
||||
56300B6A1C53D3E8005A543B /* TableMapping+FetchRequestTests.swift */,
|
||||
);
|
||||
path = FetchRequest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56300B6D1C53F592005A543B /* FetchRequest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56300B6F1C53F592005A543B /* FetchRequest.swift */,
|
||||
56300B711C53F592005A543B /* SQLSupport */,
|
||||
);
|
||||
path = FetchRequest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
56300B711C53F592005A543B /* SQLSupport */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56300B721C53F592005A543B /* Collation.swift */,
|
||||
56300B731C53F592005A543B /* Function.swift */,
|
||||
56300B741C53F592005A543B /* Operator.swift */,
|
||||
56300B751C53F592005A543B /* SQLQuery.swift */,
|
||||
);
|
||||
path = SQLSupport;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
564A50BF1BFF4B6E00B3A3A2 /* Collation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -559,6 +593,7 @@
|
||||
56CB92EC1BA453E500DFD5FC /* CrashTests.swift */,
|
||||
56A238111B9C74A90082EB20 /* Core */,
|
||||
56B7F4281BE149F600E39BBF /* CoreGraphics */,
|
||||
56300B5C1C53C38F005A543B /* FetchRequest */,
|
||||
56F0B98C1B6001C600A2F135 /* Foundation */,
|
||||
56A238231B9C74A90082EB20 /* Migrations */,
|
||||
56A238251B9C74A90082EB20 /* Record */,
|
||||
@@ -601,7 +636,7 @@
|
||||
56AC8CCC1BA3F267009E4319 /* Concurrency */,
|
||||
56A238121B9C74A90082EB20 /* Database */,
|
||||
56A238151B9C74A90082EB20 /* DatabaseError */,
|
||||
560B3FA41C19DFF800C58EC7 /* DatabasePersistable */,
|
||||
560B3FA41C19DFF800C58EC7 /* Persistable */,
|
||||
56A238171B9C74A90082EB20 /* DatabaseValue */,
|
||||
56A238191B9C74A90082EB20 /* DatabaseValueConvertible */,
|
||||
560C97BF1BFD0B5B00BF8471 /* Function */,
|
||||
@@ -712,7 +747,6 @@
|
||||
56A2386F1B9C75030082EB20 /* Core */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56A238951B9C752B0082EB20 /* Protocols */,
|
||||
56A238701B9C75030082EB20 /* Configuration.swift */,
|
||||
56A238711B9C75030082EB20 /* Database.swift */,
|
||||
56A238731B9C75030082EB20 /* DatabaseError.swift */,
|
||||
@@ -721,6 +755,7 @@
|
||||
56A238761B9C75030082EB20 /* Row.swift */,
|
||||
56A238781B9C75030082EB20 /* Statement.swift */,
|
||||
563445041C4A7FD7003D3DC6 /* Utils.swift */,
|
||||
56A238951B9C752B0082EB20 /* Protocols */,
|
||||
);
|
||||
path = Core;
|
||||
sourceTree = "<group>";
|
||||
@@ -737,11 +772,11 @@
|
||||
56A238951B9C752B0082EB20 /* Protocols */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56437C831C180EDB007D6DB3 /* DatabasePersistable.swift */,
|
||||
56A238961B9C752B0082EB20 /* DatabaseTableMapping.swift */,
|
||||
56A238971B9C752B0082EB20 /* DatabaseValueConvertible.swift */,
|
||||
56437C831C180EDB007D6DB3 /* Persistable.swift */,
|
||||
56A238981B9C752B0082EB20 /* RowConvertible.swift */,
|
||||
5614DEEF1BA9DA15003163B3 /* SQLiteStatementConvertible.swift */,
|
||||
56A238961B9C752B0082EB20 /* TableMapping.swift */,
|
||||
);
|
||||
path = Protocols;
|
||||
sourceTree = "<group>";
|
||||
@@ -821,13 +856,9 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
56CA220B1BB414FE009A04C5 /* SQLite.framework */,
|
||||
56CA220D1BB414FE009A04C5 /* SQLite iOS Tests.xctest */,
|
||||
56E667CA1C5A422500D48792 /* SQLiteTests iOS.xctest */,
|
||||
56CA220F1BB414FE009A04C5 /* SQLite.framework */,
|
||||
56CA22111BB414FE009A04C5 /* SQLite Mac Tests.xctest */,
|
||||
56CA22131BB414FE009A04C5 /* SQLiteCipher.framework */,
|
||||
56CA22151BB414FE009A04C5 /* SQLiteCipher iOS Tests.xctest */,
|
||||
56CA22171BB414FE009A04C5 /* SQLiteCipher.framework */,
|
||||
56CA22191BB414FE009A04C5 /* SQLiteCipher Mac Tests.xctest */,
|
||||
56E667CC1C5A422500D48792 /* SQLiteTests Mac.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -879,7 +910,7 @@
|
||||
path = Experimental;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
DC10500F19C904DD00D8CA30 /* GRDB Tests */ = {
|
||||
DC10500F19C904DD00D8CA30 /* Tests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5623E0901B4AFACC00B20B7F /* GRDBTestCase.swift */,
|
||||
@@ -890,7 +921,7 @@
|
||||
DC37740319C8CBB3004FCF85 /* Supporting Files */,
|
||||
5614DEEE1BA9D6F9003163B3 /* Frameworks */,
|
||||
);
|
||||
path = "GRDB Tests";
|
||||
path = Tests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
DC3773E919C8CBB3004FCF85 = {
|
||||
@@ -900,7 +931,7 @@
|
||||
DC37744719C8F50B004FCF85 /* README.md */,
|
||||
56E1524B1B43FD5B00EE27AA /* TODO.md */,
|
||||
DC37742D19C8CC90004FCF85 /* GRDB */,
|
||||
DC10500F19C904DD00D8CA30 /* GRDB Tests */,
|
||||
DC10500F19C904DD00D8CA30 /* Tests */,
|
||||
DC3773F419C8CBB3004FCF85 /* Products */,
|
||||
);
|
||||
indentWidth = 4;
|
||||
@@ -928,7 +959,6 @@
|
||||
56BB862D1BA98933001F9168 /* GRDBPerformanceTests-Bridging.h */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
path = "../GRDB Tests";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
DC37742D19C8CC90004FCF85 /* GRDB */ = {
|
||||
@@ -937,6 +967,7 @@
|
||||
56A2386F1B9C75030082EB20 /* Core */,
|
||||
56B7F4251BE148FE00E39BBF /* CoreGraphics */,
|
||||
315013941C21BCE600951DE3 /* FetchedResultsController */,
|
||||
56300B6D1C53F592005A543B /* FetchRequest */,
|
||||
56A238001B9C6A1E0082EB20 /* Foundation */,
|
||||
56A238911B9C750B0082EB20 /* Migrations */,
|
||||
56A2389F1B9C753B0082EB20 /* Record */,
|
||||
@@ -958,6 +989,7 @@
|
||||
DC3773F719C8CBB3004FCF85 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
path = ../Support;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
@@ -1155,13 +1187,6 @@
|
||||
remoteRef = 56CA220A1BB414FE009A04C5 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
56CA220D1BB414FE009A04C5 /* SQLite iOS Tests.xctest */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.cfbundle;
|
||||
path = "SQLite iOS Tests.xctest";
|
||||
remoteRef = 56CA220C1BB414FE009A04C5 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
56CA220F1BB414FE009A04C5 /* SQLite.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
@@ -1169,39 +1194,18 @@
|
||||
remoteRef = 56CA220E1BB414FE009A04C5 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
56CA22111BB414FE009A04C5 /* SQLite Mac Tests.xctest */ = {
|
||||
56E667CA1C5A422500D48792 /* SQLiteTests iOS.xctest */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.cfbundle;
|
||||
path = "SQLite Mac Tests.xctest";
|
||||
remoteRef = 56CA22101BB414FE009A04C5 /* PBXContainerItemProxy */;
|
||||
path = "SQLiteTests iOS.xctest";
|
||||
remoteRef = 56E667C91C5A422500D48792 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
56CA22131BB414FE009A04C5 /* SQLiteCipher.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
path = SQLiteCipher.framework;
|
||||
remoteRef = 56CA22121BB414FE009A04C5 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
56CA22151BB414FE009A04C5 /* SQLiteCipher iOS Tests.xctest */ = {
|
||||
56E667CC1C5A422500D48792 /* SQLiteTests Mac.xctest */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.cfbundle;
|
||||
path = "SQLiteCipher iOS Tests.xctest";
|
||||
remoteRef = 56CA22141BB414FE009A04C5 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
56CA22171BB414FE009A04C5 /* SQLiteCipher.framework */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.framework;
|
||||
path = SQLiteCipher.framework;
|
||||
remoteRef = 56CA22161BB414FE009A04C5 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
56CA22191BB414FE009A04C5 /* SQLiteCipher Mac Tests.xctest */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = wrapper.cfbundle;
|
||||
path = "SQLiteCipher Mac Tests.xctest";
|
||||
remoteRef = 56CA22181BB414FE009A04C5 /* PBXContainerItemProxy */;
|
||||
path = "SQLiteTests Mac.xctest";
|
||||
remoteRef = 56E667CB1C5A422500D48792 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
/* End PBXReferenceProxy section */
|
||||
@@ -1287,7 +1291,8 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56437C851C180EDB007D6DB3 /* DatabasePersistable.swift in Sources */,
|
||||
56300B791C53F592005A543B /* FetchRequest.swift in Sources */,
|
||||
56437C851C180EDB007D6DB3 /* Persistable.swift in Sources */,
|
||||
56E589201BBA5D5400CC0140 /* NSURL.swift in Sources */,
|
||||
56A2380A1B9C6DD20082EB20 /* StandardLibraryTypes.swift in Sources */,
|
||||
5614DEF11BA9DA15003163B3 /* SQLiteStatementConvertible.swift in Sources */,
|
||||
@@ -1295,8 +1300,10 @@
|
||||
563445061C4A7FD7003D3DC6 /* Utils.swift in Sources */,
|
||||
56A238941B9C750B0082EB20 /* DatabaseMigrator.swift in Sources */,
|
||||
56A238AB1B9C7E540082EB20 /* StatementArguments+Foundation.swift in Sources */,
|
||||
56300B7F1C53F592005A543B /* Function.swift in Sources */,
|
||||
56A2389E1B9C752B0082EB20 /* RowConvertible.swift in Sources */,
|
||||
56A238031B9C6A650082EB20 /* DatabaseDateComponents.swift in Sources */,
|
||||
56300B7D1C53F592005A543B /* Collation.swift in Sources */,
|
||||
56A238A51B9C753B0082EB20 /* Record.swift in Sources */,
|
||||
56A238101B9C74460082EB20 /* RawRepresentable.swift in Sources */,
|
||||
56A238061B9C6D670082EB20 /* NSDate.swift in Sources */,
|
||||
@@ -1308,15 +1315,17 @@
|
||||
56B7F4271BE1491700E39BBF /* CGFloat.swift in Sources */,
|
||||
56A2388C1B9C75030082EB20 /* Statement.swift in Sources */,
|
||||
56B7F43B1BEB42D500E39BBF /* Migration.swift in Sources */,
|
||||
56300B811C53F592005A543B /* Operator.swift in Sources */,
|
||||
56A2389C1B9C752B0082EB20 /* DatabaseValueConvertible.swift in Sources */,
|
||||
565D5D691BBC604000DC9BD4 /* Row+Foundation.swift in Sources */,
|
||||
31AEFE421C185E63003DB703 /* FetchedResultsController.swift in Sources */,
|
||||
56A238AE1B9C90090082EB20 /* NSNull.swift in Sources */,
|
||||
56A2389A1B9C752B0082EB20 /* DatabaseTableMapping.swift in Sources */,
|
||||
56A2389A1B9C752B0082EB20 /* TableMapping.swift in Sources */,
|
||||
56A238881B9C75030082EB20 /* Row.swift in Sources */,
|
||||
56A238841B9C75030082EB20 /* DatabaseQueue.swift in Sources */,
|
||||
56A238821B9C75030082EB20 /* DatabaseError.swift in Sources */,
|
||||
56B7F4351BE4BF1600E39BBF /* DatabaseCoder.swift in Sources */,
|
||||
56300B831C53F592005A543B /* SQLQuery.swift in Sources */,
|
||||
56A238861B9C75030082EB20 /* DatabaseValue.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1326,6 +1335,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56A238601B9C74A90082EB20 /* RecordDescriptionTests.swift in Sources */,
|
||||
56300B861C54DC95005A543B /* Record+FetchRequestTests.swift in Sources */,
|
||||
56A238561B9C74A90082EB20 /* PrimaryKeyNoneTests.swift in Sources */,
|
||||
56A238501B9C74A90082EB20 /* MinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
56AC8CCF1BA3F2AD009E4319 /* ConcurrencyTests.swift in Sources */,
|
||||
@@ -1334,6 +1344,7 @@
|
||||
56B7F4381BE4C11200E39BBF /* DatabaseCoderTests.swift in Sources */,
|
||||
564A50C81BFF4B7F00B3A3A2 /* CollationTests.swift in Sources */,
|
||||
56E8CE111BB4FE5B00828BEC /* SQLiteStatementConvertibleFetchTests.swift in Sources */,
|
||||
56300B691C53D25E005A543B /* SQLSupportTests.swift in Sources */,
|
||||
56A2384A1B9C74A90082EB20 /* SelectStatementTests.swift in Sources */,
|
||||
56A2384C1B9C74A90082EB20 /* UpdateStatementTests.swift in Sources */,
|
||||
56A2384E1B9C74A90082EB20 /* DatabaseMigratorTests.swift in Sources */,
|
||||
@@ -1346,11 +1357,12 @@
|
||||
56FDECE31BB32DFD009AD709 /* MetalRowTests.swift in Sources */,
|
||||
56DE7B121C3D93ED00861EB8 /* StatementArgumentsTests.swift in Sources */,
|
||||
56A238681B9C74A90082EB20 /* RecordInitializersTests.swift in Sources */,
|
||||
56300B621C53C42C005A543B /* RowConvertible+FetchRequestTests.swift in Sources */,
|
||||
56EB0AB31BCD787300A3DC55 /* NSDataMemoryTests.swift in Sources */,
|
||||
56A2385E1B9C74A90082EB20 /* RecordCopyTests.swift in Sources */,
|
||||
56FC78691BBAEB8C00CA1285 /* ManagedDataControllerTests.swift in Sources */,
|
||||
56A238421B9C74A90082EB20 /* DatabaseValueConversionTests.swift in Sources */,
|
||||
5658420F1C1A1C820099FE88 /* MutableDatabasePersistableTests.swift in Sources */,
|
||||
5658420F1C1A1C820099FE88 /* MutablePersistableTests.swift in Sources */,
|
||||
56FC78671BBAEB8C00CA1285 /* MappingTests.swift in Sources */,
|
||||
56A238441B9C74A90082EB20 /* RawRepresentableTests.swift in Sources */,
|
||||
5607EFD41BB827FD00605DE3 /* TransactionObserverTests.swift in Sources */,
|
||||
@@ -1368,9 +1380,11 @@
|
||||
56CA21BB1BB3FCF7009A04C5 /* NSDataTests.swift in Sources */,
|
||||
56A238B71B9CA2590082EB20 /* DatabaseTimestampTests.swift in Sources */,
|
||||
565D5D751BBC70AE00DC9BD4 /* StatementArguments+FoundationTests.swift in Sources */,
|
||||
560B3FAD1C19E01000C58EC7 /* DatabasePersistableTests.swift in Sources */,
|
||||
56300B6C1C53D3E8005A543B /* TableMapping+FetchRequestTests.swift in Sources */,
|
||||
560B3FAD1C19E01000C58EC7 /* PersistableTests.swift in Sources */,
|
||||
56F0B9921B6001C600A2F135 /* NSDateTests.swift in Sources */,
|
||||
56A238381B9C74A90082EB20 /* DatabaseTests.swift in Sources */,
|
||||
56300B5F1C53C38F005A543B /* FetchRequestTests.swift in Sources */,
|
||||
56F0B9901B6001C600A2F135 /* NSDateComponentsTests.swift in Sources */,
|
||||
560C97C81BFD0B8400BF8471 /* FunctionTests.swift in Sources */,
|
||||
56A2383A1B9C74A90082EB20 /* InMemoryDatabaseTests.swift in Sources */,
|
||||
@@ -1385,6 +1399,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5614DEF81BAA1B43003163B3 /* DatabaseValueConversionTests.swift in Sources */,
|
||||
56300B851C54DC95005A543B /* Record+FetchRequestTests.swift in Sources */,
|
||||
56A2385F1B9C74A90082EB20 /* RecordDescriptionTests.swift in Sources */,
|
||||
56A238551B9C74A90082EB20 /* PrimaryKeyNoneTests.swift in Sources */,
|
||||
56A2384F1B9C74A90082EB20 /* MinimalPrimaryKeyRowIDTests.swift in Sources */,
|
||||
@@ -1392,6 +1407,7 @@
|
||||
56A238451B9C74A90082EB20 /* DictionaryRowTests.swift in Sources */,
|
||||
56A238491B9C74A90082EB20 /* SelectStatementTests.swift in Sources */,
|
||||
56B7F4371BE4C11200E39BBF /* DatabaseCoderTests.swift in Sources */,
|
||||
56300B681C53D25E005A543B /* SQLSupportTests.swift in Sources */,
|
||||
564A50C71BFF4B7F00B3A3A2 /* CollationTests.swift in Sources */,
|
||||
56A2384B1B9C74A90082EB20 /* UpdateStatementTests.swift in Sources */,
|
||||
56A2384D1B9C74A90082EB20 /* DatabaseMigratorTests.swift in Sources */,
|
||||
@@ -1404,11 +1420,12 @@
|
||||
56A238531B9C74A90082EB20 /* PrimaryKeyMultipleTests.swift in Sources */,
|
||||
56DE7B111C3D93ED00861EB8 /* StatementArgumentsTests.swift in Sources */,
|
||||
56A238671B9C74A90082EB20 /* RecordInitializersTests.swift in Sources */,
|
||||
56300B611C53C42C005A543B /* RowConvertible+FetchRequestTests.swift in Sources */,
|
||||
56A2385D1B9C74A90082EB20 /* RecordCopyTests.swift in Sources */,
|
||||
56A238431B9C74A90082EB20 /* RawRepresentableTests.swift in Sources */,
|
||||
56EB0AB21BCD787300A3DC55 /* NSDataMemoryTests.swift in Sources */,
|
||||
56FC78681BBAEB8C00CA1285 /* ManagedDataControllerTests.swift in Sources */,
|
||||
5658420E1C1A1C820099FE88 /* MutableDatabasePersistableTests.swift in Sources */,
|
||||
5658420E1C1A1C820099FE88 /* MutablePersistableTests.swift in Sources */,
|
||||
56FC78661BBAEB8C00CA1285 /* MappingTests.swift in Sources */,
|
||||
56A238691B9C74A90082EB20 /* RecordSubClassTests.swift in Sources */,
|
||||
5607EFD31BB8254800605DE3 /* TransactionObserverTests.swift in Sources */,
|
||||
@@ -1426,9 +1443,11 @@
|
||||
56CA21BA1BB3FCF7009A04C5 /* NSDataTests.swift in Sources */,
|
||||
56A238B61B9CA2590082EB20 /* DatabaseTimestampTests.swift in Sources */,
|
||||
565D5D741BBC70AE00DC9BD4 /* StatementArguments+FoundationTests.swift in Sources */,
|
||||
560B3FAC1C19E01000C58EC7 /* DatabasePersistableTests.swift in Sources */,
|
||||
56300B6B1C53D3E8005A543B /* TableMapping+FetchRequestTests.swift in Sources */,
|
||||
560B3FAC1C19E01000C58EC7 /* PersistableTests.swift in Sources */,
|
||||
56F0B9911B6001C600A2F135 /* NSDateTests.swift in Sources */,
|
||||
56A238371B9C74A90082EB20 /* DatabaseTests.swift in Sources */,
|
||||
56300B661C53C8A7005A543B /* FetchRequestTests.swift in Sources */,
|
||||
56F0B98F1B6001C600A2F135 /* NSDateComponentsTests.swift in Sources */,
|
||||
560C97C71BFD0B8400BF8471 /* FunctionTests.swift in Sources */,
|
||||
56A238391B9C74A90082EB20 /* InMemoryDatabaseTests.swift in Sources */,
|
||||
@@ -1442,20 +1461,23 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
56300B781C53F592005A543B /* FetchRequest.swift in Sources */,
|
||||
56A238AD1B9C90090082EB20 /* NSNull.swift in Sources */,
|
||||
56437C841C180EDB007D6DB3 /* DatabasePersistable.swift in Sources */,
|
||||
56437C841C180EDB007D6DB3 /* Persistable.swift in Sources */,
|
||||
56E5891F1BBA5D5400CC0140 /* NSURL.swift in Sources */,
|
||||
56A2389D1B9C752B0082EB20 /* RowConvertible.swift in Sources */,
|
||||
5614DEF01BA9DA15003163B3 /* SQLiteStatementConvertible.swift in Sources */,
|
||||
563445051C4A7FD7003D3DC6 /* Utils.swift in Sources */,
|
||||
56A238051B9C6D670082EB20 /* NSDate.swift in Sources */,
|
||||
56A2387B1B9C75030082EB20 /* Configuration.swift in Sources */,
|
||||
56300B7E1C53F592005A543B /* Function.swift in Sources */,
|
||||
56B7F42E1BE14CD400E39BBF /* CGFloat.swift in Sources */,
|
||||
56A2389B1B9C752B0082EB20 /* DatabaseValueConvertible.swift in Sources */,
|
||||
56300B7C1C53F592005A543B /* Collation.swift in Sources */,
|
||||
56A2380F1B9C74460082EB20 /* RawRepresentable.swift in Sources */,
|
||||
56A238AA1B9C7E540082EB20 /* StatementArguments+Foundation.swift in Sources */,
|
||||
56A238811B9C75030082EB20 /* DatabaseError.swift in Sources */,
|
||||
56A238991B9C752B0082EB20 /* DatabaseTableMapping.swift in Sources */,
|
||||
56A238991B9C752B0082EB20 /* TableMapping.swift in Sources */,
|
||||
56CA0D411BF5D8E20019C023 /* DatabaseValue+Foundation.swift in Sources */,
|
||||
56A238851B9C75030082EB20 /* DatabaseValue.swift in Sources */,
|
||||
56A238A41B9C753B0082EB20 /* Record.swift in Sources */,
|
||||
@@ -1463,6 +1485,7 @@
|
||||
56A238021B9C6A650082EB20 /* DatabaseDateComponents.swift in Sources */,
|
||||
56B7F43A1BEB42D500E39BBF /* Migration.swift in Sources */,
|
||||
56A2388B1B9C75030082EB20 /* Statement.swift in Sources */,
|
||||
56300B801C53F592005A543B /* Operator.swift in Sources */,
|
||||
56A238B31B9C919D0082EB20 /* NSNumber.swift in Sources */,
|
||||
56A238B01B9C90BB0082EB20 /* NSString.swift in Sources */,
|
||||
565D5D681BBC604000DC9BD4 /* Row+Foundation.swift in Sources */,
|
||||
@@ -1471,6 +1494,7 @@
|
||||
56A238831B9C75030082EB20 /* DatabaseQueue.swift in Sources */,
|
||||
56A238871B9C75030082EB20 /* Row.swift in Sources */,
|
||||
56B7F4341BE4BF1600E39BBF /* DatabaseCoder.swift in Sources */,
|
||||
56300B821C53F592005A543B /* SQLQuery.swift in Sources */,
|
||||
56A2380C1B9C6E440082EB20 /* NSData.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1517,13 +1541,13 @@
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "GRDB Tests/Info.plist";
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "GRDB Tests/GRDBPerformanceTests-Bridging.h";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBPerformanceTests-Bridging.h";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -1534,13 +1558,13 @@
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "GRDB Tests/Info.plist";
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "GRDB Tests/GRDBPerformanceTests-Bridging.h";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBPerformanceTests-Bridging.h";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -1550,7 +1574,7 @@
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "GRDB Tests/Info.plist";
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
@@ -1566,7 +1590,7 @@
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "GRDB Tests/Info.plist";
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
@@ -1577,6 +1601,7 @@
|
||||
};
|
||||
56E5D7DC1B4D3FEE00430942 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */;
|
||||
buildSettings = {
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
@@ -1586,7 +1611,7 @@
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = GRDB/Info.plist;
|
||||
INFOPLIST_FILE = Support/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
@@ -1600,6 +1625,7 @@
|
||||
};
|
||||
56E5D7DD1B4D3FEE00430942 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */;
|
||||
buildSettings = {
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
@@ -1610,7 +1636,7 @@
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = GRDB/Info.plist;
|
||||
INFOPLIST_FILE = Support/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
@@ -1629,7 +1655,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "GRDB Tests/Info.plist";
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBiOSTests;
|
||||
@@ -1645,7 +1671,7 @@
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "GRDB Tests/Info.plist";
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBiOSTests;
|
||||
@@ -1660,7 +1686,7 @@
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "GRDB Tests/Info.plist";
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
@@ -1676,7 +1702,7 @@
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
INFOPLIST_FILE = "GRDB Tests/Info.plist";
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
@@ -1687,7 +1713,6 @@
|
||||
};
|
||||
DC37740719C8CBB3004FCF85 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
@@ -1731,7 +1756,6 @@
|
||||
};
|
||||
DC37740819C8CBB3004FCF85 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
@@ -1767,6 +1791,7 @@
|
||||
};
|
||||
DC37740A19C8CBB3004FCF85 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */;
|
||||
buildSettings = {
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -1775,7 +1800,7 @@
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = GRDB/Info.plist;
|
||||
INFOPLIST_FILE = Support/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
@@ -1787,6 +1812,7 @@
|
||||
};
|
||||
DC37740B19C8CBB3004FCF85 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */;
|
||||
buildSettings = {
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -1795,7 +1821,7 @@
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = GRDB/Info.plist;
|
||||
INFOPLIST_FILE = Support/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
location = "group:GRDB.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:GRDB Tests/GRDBProfiling/GRDBProfiling.xcodeproj">
|
||||
location = "group:Tests/GRDBProfiling/GRDBProfiling.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
/// Configuration are arguments to the DatabaseQueue initializers.
|
||||
/// Configure a DatabaseQueue
|
||||
public struct Configuration {
|
||||
|
||||
// MARK: - Misc options
|
||||
|
||||
@@ -26,7 +26,6 @@ public final class Database {
|
||||
private var functions = Set<DatabaseFunction>()
|
||||
private var collations = Set<DatabaseCollation>()
|
||||
|
||||
private var columnInfosCache: [String: [ColumnInfo]] = [:]
|
||||
private var primaryKeyCache: [String: PrimaryKey] = [:]
|
||||
private var updateStatementCache: [String: UpdateStatement] = [:]
|
||||
private var selectStatementCache: [String: SelectStatement] = [:]
|
||||
@@ -51,7 +50,7 @@ public final class Database {
|
||||
var sqliteConnection = SQLiteConnection()
|
||||
let code = sqlite3_open_v2(path, &sqliteConnection, configuration.sqliteOpenFlags, nil)
|
||||
self.sqliteConnection = sqliteConnection
|
||||
if code != SQLITE_OK {
|
||||
guard code == SQLITE_OK else {
|
||||
throw DatabaseError(code: code, message: String.fromCString(sqlite3_errmsg(sqliteConnection)))
|
||||
}
|
||||
|
||||
@@ -516,7 +515,7 @@ extension Database {
|
||||
|
||||
/// A Collation.
|
||||
public class DatabaseCollation : Hashable {
|
||||
let name: String
|
||||
public let name: String
|
||||
let function: (String, String) -> NSComparisonResult
|
||||
|
||||
/// The hash value.
|
||||
@@ -560,7 +559,6 @@ extension Database {
|
||||
/// outside of a database migration performed by DatabaseMigrator.
|
||||
public func clearSchemaCache() {
|
||||
preconditionValidQueue()
|
||||
columnInfosCache = [:]
|
||||
primaryKeyCache = [:]
|
||||
updateStatementCache = [:]
|
||||
selectStatementCache = [:]
|
||||
@@ -575,10 +573,10 @@ extension Database {
|
||||
}
|
||||
|
||||
/// Return the primary key for table named `tableName`.
|
||||
/// Crashes if table does not exist.
|
||||
/// Throws if table does not exist.
|
||||
///
|
||||
/// This method is not thread-safe.
|
||||
func primaryKey(tableName: String) -> PrimaryKey {
|
||||
func primaryKey(tableName: String) throws -> PrimaryKey {
|
||||
if let primaryKey = primaryKeyCache[tableName] {
|
||||
return primaryKey
|
||||
}
|
||||
@@ -607,9 +605,9 @@ extension Database {
|
||||
// 1 | firstName | TEXT | 0 | NULL | 0 |
|
||||
// 2 | lastName | TEXT | 0 | NULL | 0 |
|
||||
|
||||
let columnInfos = self.columnInfos(tableName)
|
||||
let columnInfos = ColumnInfo.fetchAll(self, "PRAGMA table_info(\(tableName.quotedDatabaseIdentifier))")
|
||||
guard columnInfos.count > 0 else {
|
||||
fatalError("no such table: \(tableName)")
|
||||
throw DatabaseError(message: "no such table: \(tableName)")
|
||||
}
|
||||
|
||||
let primaryKey: PrimaryKey
|
||||
@@ -686,16 +684,6 @@ extension Database {
|
||||
primaryKeyIndex:row.value(named: "pk"))
|
||||
}
|
||||
}
|
||||
|
||||
private func columnInfos(tableName: String) -> [ColumnInfo] {
|
||||
if let columnInfos = columnInfosCache[tableName] {
|
||||
return columnInfos
|
||||
}
|
||||
|
||||
let columnInfos = ColumnInfo.fetchAll(self, "PRAGMA table_info(\(tableName.quotedDatabaseIdentifier))")
|
||||
columnInfosCache[tableName] = columnInfos
|
||||
return columnInfos
|
||||
}
|
||||
}
|
||||
|
||||
/// A primary key
|
||||
@@ -846,9 +834,7 @@ extension Database {
|
||||
|
||||
public func removeTransactionObserver(transactionObserver: TransactionObserverType) {
|
||||
preconditionValidQueue()
|
||||
if let index = transactionObservers.indexOf({ $0 === transactionObserver}) {
|
||||
transactionObservers.removeAtIndex(index)
|
||||
}
|
||||
transactionObservers.removeFirst { $0 === transactionObserver }
|
||||
if transactionObservers.isEmpty {
|
||||
uninstallTransactionObserverHooks()
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
/// String.fetchOne(statement, arguments:...) // String?
|
||||
///
|
||||
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
|
||||
public protocol DatabaseValueConvertible {
|
||||
public protocol DatabaseValueConvertible : _SQLExpressionType {
|
||||
/// Returns a value that can be stored in the database.
|
||||
var databaseValue: DatabaseValue { get }
|
||||
|
||||
@@ -38,6 +38,9 @@ public protocol DatabaseValueConvertible {
|
||||
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
|
||||
public extension DatabaseValueConvertible {
|
||||
|
||||
|
||||
// MARK: - Fetching From SelectStatement
|
||||
|
||||
/// Returns a sequence of values fetched from a prepared statement.
|
||||
///
|
||||
/// let statement = db.selectStatement("SELECT name FROM ...")
|
||||
@@ -58,6 +61,7 @@ public extension DatabaseValueConvertible {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence.
|
||||
@warn_unused_result
|
||||
public static func fetch(statement: SelectStatement, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
|
||||
let sqliteStatement = statement.sqliteStatement
|
||||
return statement.fetchSequence(arguments: arguments) {
|
||||
@@ -73,6 +77,7 @@ public extension DatabaseValueConvertible {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(statement: SelectStatement, arguments: StatementArguments? = nil) -> [Self] {
|
||||
return Array(fetch(statement, arguments: arguments))
|
||||
}
|
||||
@@ -88,6 +93,7 @@ public extension DatabaseValueConvertible {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An optional value.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(statement: SelectStatement, arguments: StatementArguments? = nil) -> Self? {
|
||||
let sequence = statement.fetchSequence(arguments: arguments) {
|
||||
fromDatabaseValue(DatabaseValue(sqliteStatement: statement.sqliteStatement, index: 0))
|
||||
@@ -98,6 +104,9 @@ public extension DatabaseValueConvertible {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Fetching From SQL
|
||||
|
||||
/// Returns a sequence of values fetched from an SQL query.
|
||||
///
|
||||
/// let names = String.fetch(db, "SELECT name FROM ...") // DatabaseSequence<String>
|
||||
@@ -118,6 +127,7 @@ public extension DatabaseValueConvertible {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence.
|
||||
@warn_unused_result
|
||||
public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
|
||||
return fetch(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -130,6 +140,7 @@ public extension DatabaseValueConvertible {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> [Self] {
|
||||
return fetchAll(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -145,6 +156,7 @@ public extension DatabaseValueConvertible {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An optional value.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> Self? {
|
||||
return fetchOne(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -164,6 +176,9 @@ public extension DatabaseValueConvertible {
|
||||
/// DatabaseValueConvertible is adopted by Bool, Int, String, etc.
|
||||
public extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
|
||||
|
||||
// MARK: - Fetching From SelectStatement
|
||||
|
||||
/// Returns a sequence of optional values fetched from a prepared statement.
|
||||
///
|
||||
/// let statement = db.selectStatement("SELECT name FROM ...")
|
||||
@@ -184,6 +199,7 @@ public extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence of optional values.
|
||||
@warn_unused_result
|
||||
public static func fetch(statement: SelectStatement, arguments: StatementArguments? = nil) -> DatabaseSequence<Wrapped?> {
|
||||
let sqliteStatement = statement.sqliteStatement
|
||||
return statement.fetchSequence(arguments: arguments) {
|
||||
@@ -199,10 +215,14 @@ public extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array of optional values.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(statement: SelectStatement, arguments: StatementArguments? = nil) -> [Wrapped?] {
|
||||
return Array(fetch(statement, arguments: arguments))
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Fetching From SQL
|
||||
|
||||
/// Returns a sequence of optional values fetched from an SQL query.
|
||||
///
|
||||
/// let names = Optional<String>.fetch(db, "SELECT name FROM ...") // DatabaseSequence<String?>
|
||||
@@ -223,6 +243,7 @@ public extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence of optional values.
|
||||
@warn_unused_result
|
||||
public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> DatabaseSequence<Wrapped?> {
|
||||
return fetch(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -235,6 +256,7 @@ public extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array of optional values.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> [Wrapped?] {
|
||||
return fetchAll(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
|
||||
+53
-57
@@ -1,11 +1,11 @@
|
||||
// MARK: - PersistenceError
|
||||
|
||||
/// An error thrown by a type that adopts DatabasePersistable.
|
||||
/// An error thrown by a type that adopts Persistable.
|
||||
public enum PersistenceError: ErrorType {
|
||||
|
||||
/// Thrown by MutableDatabasePersistable.update() when no matching row could be
|
||||
/// Thrown by MutablePersistable.update() when no matching row could be
|
||||
/// found in the database.
|
||||
case NotFound(MutableDatabasePersistable)
|
||||
case NotFound(MutablePersistable)
|
||||
}
|
||||
|
||||
extension PersistenceError : CustomStringConvertible {
|
||||
@@ -34,26 +34,25 @@ private func databaseValues(forColumns columns: [String], inDictionary dictionar
|
||||
}
|
||||
|
||||
|
||||
// MARK: - MutableDatabasePersistable
|
||||
// MARK: - MutablePersistable
|
||||
|
||||
/// Types that adopt MutableDatabasePersistable can be inserted, updated,
|
||||
/// and deleted.
|
||||
/// Types that adopt MutablePersistable can be inserted, updated, and deleted.
|
||||
///
|
||||
/// This protocol is intented for types that have an INTEGER PRIMARY KEY, and
|
||||
/// are interested in the inserted RowID: they can mutate themselves upon
|
||||
/// successful insertion with the didInsertWithRowID(_:forColumn:) method.
|
||||
///
|
||||
/// The insert() and save() methods are mutating methods.
|
||||
public protocol MutableDatabasePersistable : DatabaseTableMapping {
|
||||
public protocol MutablePersistable : TableMapping {
|
||||
|
||||
/// Returns the values that should be stored in the database.
|
||||
///
|
||||
/// Keys of the returned dictionary must match the column names of the
|
||||
/// target database table (see DatabaseTableMapping.databaseTableName()).
|
||||
/// target database table (see TableMapping.databaseTableName()).
|
||||
///
|
||||
/// In particular, primary key columns, if any, must be included.
|
||||
///
|
||||
/// struct Person : MutableDatabasePersistable {
|
||||
/// struct Person : MutablePersistable {
|
||||
/// var id: Int64?
|
||||
/// var name: String?
|
||||
///
|
||||
@@ -69,7 +68,7 @@ public protocol MutableDatabasePersistable : DatabaseTableMapping {
|
||||
///
|
||||
/// This method is optional: the default implementation does nothing.
|
||||
///
|
||||
/// struct Person : MutableDatabasePersistable {
|
||||
/// struct Person : MutablePersistable {
|
||||
/// var id: Int64?
|
||||
/// var name: String?
|
||||
///
|
||||
@@ -160,7 +159,7 @@ public protocol MutableDatabasePersistable : DatabaseTableMapping {
|
||||
func exists(db: Database) -> Bool
|
||||
}
|
||||
|
||||
public extension MutableDatabasePersistable {
|
||||
public extension MutablePersistable {
|
||||
|
||||
/// The default implementation does nothing.
|
||||
mutating func didInsertWithRowID(rowID: Int64, forColumn column: String?) {
|
||||
@@ -212,7 +211,7 @@ public extension MutableDatabasePersistable {
|
||||
private func canUpdateInDatabase(db: Database) -> Bool {
|
||||
// Fail early if database table does not exist.
|
||||
let databaseTableName = self.dynamicType.databaseTableName()
|
||||
let primaryKey = db.primaryKey(databaseTableName)
|
||||
let primaryKey = try! db.primaryKey(databaseTableName)
|
||||
|
||||
let persistentDictionary = self.persistentDictionary
|
||||
for column in primaryKey.columns where !databaseValue(forColumn: column, inDictionary: persistentDictionary).isNull {
|
||||
@@ -222,11 +221,11 @@ public extension MutableDatabasePersistable {
|
||||
}
|
||||
|
||||
/// Don't invoke this method directly: it is an internal method for types
|
||||
/// that adopt MutableDatabasePersistable.
|
||||
/// that adopt MutablePersistable.
|
||||
///
|
||||
/// performInsert() provides the default implementation for insert(). Types
|
||||
/// that adopt MutableDatabasePersistable can invoke performInsert() in
|
||||
/// their implementation of insert(). They should not provide their own
|
||||
/// that adopt MutablePersistable can invoke performInsert() in their
|
||||
/// implementation of insert(). They should not provide their own
|
||||
/// implementation of performInsert().
|
||||
mutating func performInsert(db: Database) throws {
|
||||
let dataMapper = DataMapper(db, self)
|
||||
@@ -237,11 +236,11 @@ public extension MutableDatabasePersistable {
|
||||
}
|
||||
|
||||
/// Don't invoke this method directly: it is an internal method for types
|
||||
/// that adopt MutableDatabasePersistable.
|
||||
/// that adopt MutablePersistable.
|
||||
///
|
||||
/// performUpdate() provides the default implementation for update(). Types
|
||||
/// that adopt MutableDatabasePersistable can invoke performUpdate() in
|
||||
/// their implementation of update(). They should not provide their own
|
||||
/// that adopt MutablePersistable can invoke performUpdate() in their
|
||||
/// implementation of update(). They should not provide their own
|
||||
/// implementation of performUpdate().
|
||||
func performUpdate(db: Database) throws {
|
||||
let changes = try DataMapper(db, self).updateStatement().execute()
|
||||
@@ -251,10 +250,10 @@ public extension MutableDatabasePersistable {
|
||||
}
|
||||
|
||||
/// Don't invoke this method directly: it is an internal method for types
|
||||
/// that adopt MutableDatabasePersistable.
|
||||
/// that adopt MutablePersistable.
|
||||
///
|
||||
/// performSave() provides the default implementation for save(). Types
|
||||
/// that adopt MutableDatabasePersistable can invoke performSave() in their
|
||||
/// that adopt MutablePersistable can invoke performSave() in their
|
||||
/// implementation of save(). They should not provide their own
|
||||
/// implementation of performSave().
|
||||
///
|
||||
@@ -280,10 +279,10 @@ public extension MutableDatabasePersistable {
|
||||
}
|
||||
|
||||
/// Don't invoke this method directly: it is an internal method for types
|
||||
/// that adopt MutableDatabasePersistable.
|
||||
/// that adopt MutablePersistable.
|
||||
///
|
||||
/// performDelete() provides the default implementation for deelte(). Types
|
||||
/// that adopt MutableDatabasePersistable can invoke performDelete() in
|
||||
/// that adopt MutablePersistable can invoke performDelete() in
|
||||
/// their implementation of delete(). They should not provide their own
|
||||
/// implementation of performDelete().
|
||||
func performDelete(db: Database) throws -> Bool {
|
||||
@@ -291,10 +290,10 @@ public extension MutableDatabasePersistable {
|
||||
}
|
||||
|
||||
/// Don't invoke this method directly: it is an internal method for types
|
||||
/// that adopt MutableDatabasePersistable.
|
||||
/// that adopt MutablePersistable.
|
||||
///
|
||||
/// performExists() provides the default implementation for exists(). Types
|
||||
/// that adopt MutableDatabasePersistable can invoke performExists() in
|
||||
/// that adopt MutablePersistable can invoke performExists() in
|
||||
/// their implementation of exists(). They should not provide their own
|
||||
/// implementation of performExists().
|
||||
func performExists(db: Database) -> Bool {
|
||||
@@ -304,15 +303,15 @@ public extension MutableDatabasePersistable {
|
||||
}
|
||||
|
||||
|
||||
// MARK: - DatabasePersistable
|
||||
// MARK: - Persistable
|
||||
|
||||
/// Types that adopt DatabasePersistable can be inserted, updated, and deleted.
|
||||
/// Types that adopt Persistable can be inserted, updated, and deleted.
|
||||
///
|
||||
/// This protocol is intented for types that don't have an INTEGER PRIMARY KEY.
|
||||
///
|
||||
/// Unlike MutableDatabasePersistable, the insert() and save() methods are not
|
||||
/// Unlike MutablePersistable, the insert() and save() methods are not
|
||||
/// mutating methods.
|
||||
public protocol DatabasePersistable : MutableDatabasePersistable {
|
||||
public protocol Persistable : MutablePersistable {
|
||||
|
||||
/// Don't call this method directly: it is called upon successful insertion,
|
||||
/// with the inserted RowID and the eventual INTEGER PRIMARY KEY
|
||||
@@ -321,7 +320,7 @@ public protocol DatabasePersistable : MutableDatabasePersistable {
|
||||
/// This method is optional: the default implementation does nothing.
|
||||
///
|
||||
/// If you need a mutating variant of this method, adopt the
|
||||
/// MutableDatabasePersistable protocol instead.
|
||||
/// MutablePersistable protocol instead.
|
||||
///
|
||||
/// - parameter rowID: The inserted rowID.
|
||||
/// - parameter column: The name of the eventual INTEGER PRIMARY KEY column.
|
||||
@@ -365,7 +364,7 @@ public protocol DatabasePersistable : MutableDatabasePersistable {
|
||||
func save(db: Database) throws
|
||||
}
|
||||
|
||||
public extension DatabasePersistable {
|
||||
public extension Persistable {
|
||||
|
||||
/// The default implementation does nothing.
|
||||
func didInsertWithRowID(rowID: Int64, forColumn column: String?) {
|
||||
@@ -392,10 +391,10 @@ public extension DatabasePersistable {
|
||||
// MARK: - Immutable CRUD Internals
|
||||
|
||||
/// Don't invoke this method directly: it is an internal method for types
|
||||
/// that adopt DatabasePersistable.
|
||||
/// that adopt Persistable.
|
||||
///
|
||||
/// performInsert() provides the default implementation for insert(). Types
|
||||
/// that adopt DatabasePersistable can invoke performInsert() in their
|
||||
/// that adopt Persistable can invoke performInsert() in their
|
||||
/// implementation of insert(). They should not provide their own
|
||||
/// implementation of performInsert().
|
||||
func performInsert(db: Database) throws {
|
||||
@@ -407,10 +406,10 @@ public extension DatabasePersistable {
|
||||
}
|
||||
|
||||
/// Don't invoke this method directly: it is an internal method for types
|
||||
/// that adopt DatabasePersistable.
|
||||
/// that adopt Persistable.
|
||||
///
|
||||
/// performSave() provides the default implementation for save(). Types
|
||||
/// that adopt DatabasePersistable can invoke performSave() in their
|
||||
/// that adopt Persistable can invoke performSave() in their
|
||||
/// implementation of save(). They should not provide their own
|
||||
/// implementation of performSave().
|
||||
///
|
||||
@@ -440,14 +439,14 @@ public extension DatabasePersistable {
|
||||
|
||||
// MARK: - DataMapper
|
||||
|
||||
/// DataMapper takes care of DatabasePersistable CRUD
|
||||
/// DataMapper takes care of Persistable CRUD
|
||||
final class DataMapper {
|
||||
|
||||
/// The database
|
||||
let db: Database
|
||||
|
||||
/// The persistable
|
||||
let persistable: MutableDatabasePersistable
|
||||
let persistable: MutablePersistable
|
||||
|
||||
/// DataMapper keeps a copy the persistable's persistentDictionary, so
|
||||
/// that this dictionary is built once whatever the database operation.
|
||||
@@ -460,10 +459,10 @@ final class DataMapper {
|
||||
/// The table primary key
|
||||
let primaryKey: PrimaryKey
|
||||
|
||||
init(_ db: Database, _ persistable: MutableDatabasePersistable) {
|
||||
init(_ db: Database, _ persistable: MutablePersistable) {
|
||||
// Fail early if database table does not exist.
|
||||
let databaseTableName = persistable.dynamicType.databaseTableName()
|
||||
let primaryKey = db.primaryKey(databaseTableName)
|
||||
let primaryKey = try! db.primaryKey(databaseTableName)
|
||||
|
||||
// Fail early if persistentDictionary is empty
|
||||
let persistentDictionary = persistable.persistentDictionary
|
||||
@@ -477,11 +476,10 @@ final class DataMapper {
|
||||
}
|
||||
|
||||
func insertStatement() -> UpdateStatement {
|
||||
let sql = InsertQuery(
|
||||
let query = InsertQuery(
|
||||
tableName: databaseTableName,
|
||||
insertedColumns: Array(persistentDictionary.keys))
|
||||
.sql
|
||||
let statement = try! db.cachedUpdateStatement(sql)
|
||||
let statement = try! db.cachedUpdateStatement(query.sql)
|
||||
statement.unsafeSetArguments(StatementArguments(persistentDictionary.values))
|
||||
return statement
|
||||
}
|
||||
@@ -490,9 +488,10 @@ final class DataMapper {
|
||||
// Fail early if primary key does not resolve to a database row.
|
||||
let primaryKeyColumns = primaryKey.columns
|
||||
let primaryKeyValues = databaseValues(forColumns: primaryKeyColumns, inDictionary: persistentDictionary)
|
||||
precondition(primaryKeyValues.indexOf({ !$0.isNull }) != nil, "invalid primary key in \(persistable)")
|
||||
precondition(primaryKeyValues.contains { !$0.isNull }, "invalid primary key in \(persistable)")
|
||||
|
||||
var updatedColumns = Array(persistentDictionary.keys.filter { !primaryKeyColumns.contains($0) })
|
||||
// Update everything but primary key
|
||||
var updatedColumns = persistentDictionary.keys.removingElementsOf(primaryKeyColumns)
|
||||
if updatedColumns.isEmpty {
|
||||
// IMPLEMENTATION NOTE
|
||||
//
|
||||
@@ -506,12 +505,11 @@ final class DataMapper {
|
||||
}
|
||||
let updatedValues = databaseValues(forColumns: updatedColumns, inDictionary: persistentDictionary)
|
||||
|
||||
let sql = UpdateQuery(
|
||||
let query = UpdateQuery(
|
||||
tableName: databaseTableName,
|
||||
updatedColumns: updatedColumns,
|
||||
conditionColumns: primaryKeyColumns)
|
||||
.sql
|
||||
let statement = try! db.cachedUpdateStatement(sql)
|
||||
let statement = try! db.cachedUpdateStatement(query.sql)
|
||||
statement.unsafeSetArguments(StatementArguments(updatedValues + primaryKeyValues))
|
||||
return statement
|
||||
}
|
||||
@@ -520,13 +518,12 @@ final class DataMapper {
|
||||
// Fail early if primary key does not resolve to a database row.
|
||||
let primaryKeyColumns = primaryKey.columns
|
||||
let primaryKeyValues = databaseValues(forColumns: primaryKeyColumns, inDictionary: persistentDictionary)
|
||||
precondition(primaryKeyValues.indexOf({ !$0.isNull }) != nil, "invalid primary key in \(persistable)")
|
||||
precondition(primaryKeyValues.contains { !$0.isNull }, "invalid primary key in \(persistable)")
|
||||
|
||||
let sql = DeleteQuery(
|
||||
let query = DeleteQuery(
|
||||
tableName: databaseTableName,
|
||||
conditionColumns: primaryKeyColumns)
|
||||
.sql
|
||||
let statement = try! db.cachedUpdateStatement(sql)
|
||||
let statement = try! db.cachedUpdateStatement(query.sql)
|
||||
statement.unsafeSetArguments(StatementArguments(primaryKeyValues))
|
||||
return statement
|
||||
}
|
||||
@@ -535,13 +532,12 @@ final class DataMapper {
|
||||
// Fail early if primary key does not resolve to a database row.
|
||||
let primaryKeyColumns = primaryKey.columns
|
||||
let primaryKeyValues = databaseValues(forColumns: primaryKeyColumns, inDictionary: persistentDictionary)
|
||||
precondition(primaryKeyValues.indexOf({ !$0.isNull }) != nil, "invalid primary key in \(persistable)")
|
||||
precondition(primaryKeyValues.contains { !$0.isNull }, "invalid primary key in \(persistable)")
|
||||
|
||||
let sql = ExistsQuery(
|
||||
let query = ExistsQuery(
|
||||
tableName: databaseTableName,
|
||||
conditionColumns: primaryKeyColumns)
|
||||
.sql
|
||||
let statement = try! db.cachedSelectStatement(sql)
|
||||
let statement = try! db.cachedSelectStatement(query.sql)
|
||||
statement.unsafeSetArguments(StatementArguments(primaryKeyValues))
|
||||
return statement
|
||||
}
|
||||
@@ -570,9 +566,9 @@ extension InsertQuery {
|
||||
if let sql = InsertQuery.sqlCache[self] {
|
||||
return sql
|
||||
}
|
||||
let columnSQL = insertedColumns.map { $0.quotedDatabaseIdentifier }.joinWithSeparator(",")
|
||||
let valuesSQL = Array(count: insertedColumns.count, repeatedValue: "?").joinWithSeparator(",")
|
||||
let sql = "INSERT INTO \(tableName.quotedDatabaseIdentifier) (\(columnSQL)) VALUES (\(valuesSQL))"
|
||||
let columnsSQL = insertedColumns.map { $0.quotedDatabaseIdentifier }.joinWithSeparator(",")
|
||||
let valuesSQL = databaseQuestionMarks(count: insertedColumns.count)
|
||||
let sql = "INSERT INTO \(tableName.quotedDatabaseIdentifier) (\(columnsSQL)) VALUES (\(valuesSQL))"
|
||||
InsertQuery.sqlCache[self] = sql
|
||||
return sql
|
||||
}
|
||||
@@ -61,6 +61,7 @@ extension RowConvertible {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence.
|
||||
@warn_unused_result
|
||||
public static func fetch(statement: SelectStatement, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
|
||||
let row = Row(statement: statement)
|
||||
let database = statement.database
|
||||
@@ -79,6 +80,7 @@ extension RowConvertible {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(statement: SelectStatement, arguments: StatementArguments? = nil) -> [Self] {
|
||||
return Array(fetch(statement, arguments: arguments))
|
||||
}
|
||||
@@ -91,12 +93,13 @@ extension RowConvertible {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An optional value.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(statement: SelectStatement, arguments: StatementArguments? = nil) -> Self? {
|
||||
return fetch(statement, arguments: arguments).generate().next()
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Fetching From Database
|
||||
// MARK: - Fetching From SQL
|
||||
|
||||
/// Returns a sequence of values fetched from an SQL query.
|
||||
///
|
||||
@@ -118,6 +121,7 @@ extension RowConvertible {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence.
|
||||
@warn_unused_result
|
||||
public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
|
||||
return fetch(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -130,6 +134,7 @@ extension RowConvertible {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> [Self] {
|
||||
return fetchAll(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -142,6 +147,7 @@ extension RowConvertible {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An optional value.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> Self? {
|
||||
return fetchOne(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ public protocol SQLiteStatementConvertible {
|
||||
/// See DatabaseValueConvertible for more information.
|
||||
public extension DatabaseValueConvertible where Self: SQLiteStatementConvertible {
|
||||
|
||||
|
||||
// MARK: - Fetching From SelectStatement
|
||||
|
||||
/// Returns a sequence of values fetched from a prepared statement.
|
||||
///
|
||||
/// let statement = db.selectStatement("SELECT name FROM ...")
|
||||
@@ -50,6 +53,7 @@ public extension DatabaseValueConvertible where Self: SQLiteStatementConvertible
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence of values.
|
||||
@warn_unused_result
|
||||
public static func fetch(statement: SelectStatement, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
|
||||
let sqliteStatement = statement.sqliteStatement
|
||||
return statement.fetchSequence(arguments: arguments) {
|
||||
@@ -68,6 +72,7 @@ public extension DatabaseValueConvertible where Self: SQLiteStatementConvertible
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array of values.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(statement: SelectStatement, arguments: StatementArguments? = nil) -> [Self] {
|
||||
return Array(fetch(statement, arguments: arguments))
|
||||
}
|
||||
@@ -80,6 +85,7 @@ public extension DatabaseValueConvertible where Self: SQLiteStatementConvertible
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An optional value.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(statement: SelectStatement, arguments: StatementArguments? = nil) -> Self? {
|
||||
let sqliteStatement = statement.sqliteStatement
|
||||
let isNullSequence = statement.fetchSequence(arguments: arguments) {
|
||||
@@ -91,6 +97,9 @@ public extension DatabaseValueConvertible where Self: SQLiteStatementConvertible
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Fetching From SQL
|
||||
|
||||
/// Returns a sequence of values fetched from an SQL query.
|
||||
///
|
||||
/// let names = String.fetch(db, "SELECT name FROM ...") // DatabaseSequence<String>
|
||||
@@ -111,6 +120,7 @@ public extension DatabaseValueConvertible where Self: SQLiteStatementConvertible
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence of values.
|
||||
@warn_unused_result
|
||||
public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> DatabaseSequence<Self> {
|
||||
return fetch(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -123,6 +133,7 @@ public extension DatabaseValueConvertible where Self: SQLiteStatementConvertible
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array of values.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> [Self] {
|
||||
return fetchAll(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -135,6 +146,7 @@ public extension DatabaseValueConvertible where Self: SQLiteStatementConvertible
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An optional value.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> Self? {
|
||||
return fetchOne(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
|
||||
+31
-23
@@ -1,19 +1,19 @@
|
||||
/// Types that adopt DatabaseTableMapping declare a particular relationship with
|
||||
/// Types that adopt TableMapping declare a particular relationship with
|
||||
/// a database table.
|
||||
///
|
||||
/// Types that adopt both DatabaseTableMapping and RowConvertible are granted
|
||||
/// with built-in methods that allow to fetch instances identified by key:
|
||||
/// Types that adopt both TableMapping and RowConvertible are granted with
|
||||
/// built-in methods that allow to fetch instances identified by key:
|
||||
///
|
||||
/// Person.fetchOne(db, key: 123) // Person?
|
||||
/// Citizenship.fetchOne(db, key: ["personId": 12, "countryId": 45]) // Citizenship?
|
||||
///
|
||||
/// DatabaseTableMapping is adopted by Record.
|
||||
public protocol DatabaseTableMapping {
|
||||
/// TableMapping is adopted by Record.
|
||||
public protocol TableMapping {
|
||||
/// The name of the database table
|
||||
static func databaseTableName() -> String
|
||||
}
|
||||
|
||||
extension RowConvertible where Self: DatabaseTableMapping {
|
||||
extension RowConvertible where Self: TableMapping {
|
||||
|
||||
// MARK: - Single-Column Primary Key
|
||||
|
||||
@@ -26,8 +26,9 @@ extension RowConvertible where Self: DatabaseTableMapping {
|
||||
/// - parameter db: A Database.
|
||||
/// - parameter keys: An array of primary keys.
|
||||
/// - returns: A sequence.
|
||||
@warn_unused_result
|
||||
public static func fetch<Sequence: SequenceType where Sequence.Generator.Element: DatabaseValueConvertible>(db: Database, keys: Sequence) -> DatabaseSequence<Self> {
|
||||
guard let statement = fetchByPrimaryKeyStatement(db, keys: keys) else {
|
||||
guard let statement = fetchByPrimaryKeyStatement(db, values: keys) else {
|
||||
return DatabaseSequence.emptySequence(db)
|
||||
}
|
||||
return fetch(statement)
|
||||
@@ -42,8 +43,9 @@ extension RowConvertible where Self: DatabaseTableMapping {
|
||||
/// - parameter db: A Database.
|
||||
/// - parameter keys: An array of primary keys.
|
||||
/// - returns: An array.
|
||||
@warn_unused_result
|
||||
public static func fetchAll<Sequence: SequenceType where Sequence.Generator.Element: DatabaseValueConvertible>(db: Database, keys: Sequence) -> [Self] {
|
||||
guard let statement = fetchByPrimaryKeyStatement(db, keys: keys) else {
|
||||
guard let statement = fetchByPrimaryKeyStatement(db, values: keys) else {
|
||||
return []
|
||||
}
|
||||
return fetchAll(statement)
|
||||
@@ -56,43 +58,45 @@ extension RowConvertible where Self: DatabaseTableMapping {
|
||||
/// - parameter db: A Database.
|
||||
/// - parameter key: A primary key value.
|
||||
/// - returns: An optional value.
|
||||
@warn_unused_result
|
||||
public static func fetchOne<PrimaryKeyType: DatabaseValueConvertible>(db: Database, key: PrimaryKeyType?) -> Self? {
|
||||
guard let key = key else {
|
||||
return nil
|
||||
}
|
||||
return fetchOne(fetchByPrimaryKeyStatement(db, keys: [key])!)
|
||||
return fetchOne(fetchByPrimaryKeyStatement(db, values: [key])!)
|
||||
}
|
||||
|
||||
// Returns "SELECT * FROM table WHERE id IN (?,?,?)"
|
||||
//
|
||||
// Returns nil if keys is empty.
|
||||
private static func fetchByPrimaryKeyStatement<Sequence: SequenceType where Sequence.Generator.Element: DatabaseValueConvertible>(db: Database, keys: Sequence) -> SelectStatement? {
|
||||
// Returns nil if values is empty.
|
||||
@warn_unused_result
|
||||
private static func fetchByPrimaryKeyStatement<Sequence: SequenceType where Sequence.Generator.Element: DatabaseValueConvertible>(db: Database, values: Sequence) -> SelectStatement? {
|
||||
// Fail early if database table does not exist.
|
||||
let databaseTableName = self.databaseTableName()
|
||||
let primaryKey = db.primaryKey(databaseTableName)
|
||||
let primaryKey = try! db.primaryKey(databaseTableName)
|
||||
|
||||
// Fail early if database table has not one column in its primary key
|
||||
let columns = primaryKey.columns
|
||||
precondition(columns.count == 1, "expected single column primary key in table: \(databaseTableName)")
|
||||
let column = columns.first!
|
||||
|
||||
let keys = keys.map { $0 as DatabaseValueConvertible? }
|
||||
|
||||
switch keys.count {
|
||||
let values = Array(values)
|
||||
switch values.count {
|
||||
case 0:
|
||||
// Avoid performing useless SELECT
|
||||
return nil
|
||||
case 1:
|
||||
// Use '=' in SQL query
|
||||
let sql = "SELECT * FROM \(databaseTableName.quotedDatabaseIdentifier) WHERE \(columns.first!.quotedDatabaseIdentifier) = ?"
|
||||
// SELECT * FROM table WHERE id = ?
|
||||
let sql = "SELECT * FROM \(databaseTableName.quotedDatabaseIdentifier) WHERE \(column.quotedDatabaseIdentifier) = ?"
|
||||
let statement = try! db.selectStatement(sql)
|
||||
statement.arguments = StatementArguments(keys)
|
||||
statement.arguments = StatementArguments(values)
|
||||
return statement
|
||||
default:
|
||||
// Use 'IN'
|
||||
let questionMarks = Array(count: keys.count, repeatedValue: "?").joinWithSeparator(",")
|
||||
let sql = "SELECT * FROM \(databaseTableName.quotedDatabaseIdentifier) WHERE \(columns.first!.quotedDatabaseIdentifier) IN (\(questionMarks))"
|
||||
case let count:
|
||||
// SELECT * FROM table WHERE id IN (?,?,?)
|
||||
let valuesSQL = databaseQuestionMarks(count: count)
|
||||
let sql = "SELECT * FROM \(databaseTableName.quotedDatabaseIdentifier) WHERE \(column.quotedDatabaseIdentifier) IN (\(valuesSQL))"
|
||||
let statement = try! db.selectStatement(sql)
|
||||
statement.arguments = StatementArguments(keys)
|
||||
statement.arguments = StatementArguments(values)
|
||||
return statement
|
||||
}
|
||||
}
|
||||
@@ -109,6 +113,7 @@ extension RowConvertible where Self: DatabaseTableMapping {
|
||||
/// - parameter db: A Database.
|
||||
/// - parameter keys: An array of key dictionaries.
|
||||
/// - returns: A sequence.
|
||||
@warn_unused_result
|
||||
public static func fetch(db: Database, keys: [[String: DatabaseValueConvertible?]]) -> DatabaseSequence<Self> {
|
||||
guard let statement = fetchByKeyStatement(db, keys: keys) else {
|
||||
return DatabaseSequence.emptySequence(db)
|
||||
@@ -125,6 +130,7 @@ extension RowConvertible where Self: DatabaseTableMapping {
|
||||
/// - parameter db: A Database.
|
||||
/// - parameter keys: An array of key dictionaries.
|
||||
/// - returns: An array.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(db: Database, keys: [[String: DatabaseValueConvertible?]]) -> [Self] {
|
||||
guard let statement = fetchByKeyStatement(db, keys: keys) else {
|
||||
return []
|
||||
@@ -139,6 +145,7 @@ extension RowConvertible where Self: DatabaseTableMapping {
|
||||
/// - parameter db: A Database.
|
||||
/// - parameter key: A dictionary of values.
|
||||
/// - returns: An optional value.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(db: Database, key: [String: DatabaseValueConvertible?]) -> Self? {
|
||||
return fetchOne(fetchByKeyStatement(db, keys: [key])!)
|
||||
}
|
||||
@@ -146,6 +153,7 @@ extension RowConvertible where Self: DatabaseTableMapping {
|
||||
// Returns "SELECT * FROM table WHERE (a = ? AND b = ?) OR (a = ? AND b = ?) ...
|
||||
//
|
||||
// Returns nil if keys is empty.
|
||||
@warn_unused_result
|
||||
private static func fetchByKeyStatement(db: Database, keys: [[String: DatabaseValueConvertible?]]) -> SelectStatement? {
|
||||
// Avoid performing useless SELECT
|
||||
guard keys.count > 0 else {
|
||||
+17
-7
@@ -391,13 +391,14 @@ public final class Row: CollectionType {
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Fetch Rows
|
||||
// MARK: - Fetching From SelectStatement
|
||||
|
||||
/// Returns a sequence of rows fetched from a prepared statement.
|
||||
///
|
||||
/// for row in Row.fetch(db, "SELECT id, name FROM persons") {
|
||||
/// let id = row.int64(atIndex: 0)
|
||||
/// let name = row.string(atIndex: 1)
|
||||
/// let statement = db.selectStatement("SELECT ...")
|
||||
/// for row in Row.fetch(statement) {
|
||||
/// let id: Int64 = row.value(atIndex: 0)
|
||||
/// let name: String = row.value(atIndex: 1)
|
||||
/// }
|
||||
///
|
||||
/// Fetched rows are reused during the sequence iteration: don't wrap a row
|
||||
@@ -424,6 +425,7 @@ public final class Row: CollectionType {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence of rows.
|
||||
@warn_unused_result
|
||||
public static func fetch(statement: SelectStatement, arguments: StatementArguments? = nil) -> DatabaseSequence<Row> {
|
||||
// Metal rows can be reused. And reusing them yields better performance.
|
||||
let row = Row(statement: statement)
|
||||
@@ -438,6 +440,7 @@ public final class Row: CollectionType {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array of rows.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(statement: SelectStatement, arguments: StatementArguments? = nil) -> [Row] {
|
||||
let sequence = statement.fetchSequence(arguments: arguments) {
|
||||
Row(copiedFromStatement: statement)
|
||||
@@ -453,6 +456,7 @@ public final class Row: CollectionType {
|
||||
/// - parameter statement: The statement to run.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An optional row.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(statement: SelectStatement, arguments: StatementArguments? = nil) -> Row? {
|
||||
let sequence = statement.fetchSequence(arguments: arguments) {
|
||||
Row(copiedFromStatement: statement)
|
||||
@@ -460,11 +464,14 @@ public final class Row: CollectionType {
|
||||
return sequence.generate().next()
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Fetching From SQL
|
||||
|
||||
/// Returns a sequence of rows fetched from an SQL query.
|
||||
///
|
||||
/// for row in Row.fetch(db, "SELECT id, name FROM persons") {
|
||||
/// let id = row.int64(atIndex: 0)
|
||||
/// let name = row.string(atIndex: 1)
|
||||
/// let id: Int64 = row.value(atIndex: 0)
|
||||
/// let name: String = row.value(atIndex: 1)
|
||||
/// }
|
||||
///
|
||||
/// Fetched rows are reused during the sequence iteration: don't wrap a row
|
||||
@@ -491,6 +498,7 @@ public final class Row: CollectionType {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: A sequence of rows.
|
||||
@warn_unused_result
|
||||
public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> DatabaseSequence<Row> {
|
||||
return fetch(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -503,6 +511,7 @@ public final class Row: CollectionType {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An array of rows.
|
||||
@warn_unused_result
|
||||
public static func fetchAll(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> [Row] {
|
||||
return fetchAll(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
@@ -515,10 +524,11 @@ public final class Row: CollectionType {
|
||||
/// - parameter sql: An SQL query.
|
||||
/// - parameter arguments: Optional statement arguments.
|
||||
/// - returns: An optional row.
|
||||
@warn_unused_result
|
||||
public static func fetchOne(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> Row? {
|
||||
return fetchOne(try! db.selectStatement(sql), arguments: arguments)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - Not Public
|
||||
|
||||
|
||||
+28
-17
@@ -59,7 +59,7 @@ public class Statement {
|
||||
|
||||
final func reset() throws {
|
||||
let code = sqlite3_reset(sqliteStatement)
|
||||
if code != SQLITE_OK {
|
||||
guard code == SQLITE_OK else {
|
||||
throw DatabaseError(code: code, message: database.lastErrorMessage, sql: sql)
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class Statement {
|
||||
}
|
||||
}
|
||||
|
||||
private func setArgumentsWithValidation(arguments: StatementArguments) throws {
|
||||
func setArgumentsWithValidation(arguments: StatementArguments) throws {
|
||||
// Validate
|
||||
let bindings = try validatedBindings(arguments)
|
||||
_arguments = arguments
|
||||
@@ -149,7 +149,7 @@ public class Statement {
|
||||
code = sqlite3_bind_blob(sqliteStatement, index, data.bytes, Int32(data.length), SQLITE_TRANSIENT)
|
||||
}
|
||||
|
||||
if code != SQLITE_OK {
|
||||
guard code == SQLITE_OK else {
|
||||
throw DatabaseError(code: code, message: database.lastErrorMessage, sql: sql)
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public class Statement {
|
||||
// Don't make this one public unless we keep the arguments property in sync.
|
||||
private func clearBindings() throws {
|
||||
let code = sqlite3_clear_bindings(sqliteStatement)
|
||||
if code != SQLITE_OK {
|
||||
guard code == SQLITE_OK else {
|
||||
throw DatabaseError(code: code, message: database.lastErrorMessage, sql: sql)
|
||||
}
|
||||
}
|
||||
@@ -291,6 +291,7 @@ public final class SelectStatement : Statement {
|
||||
}
|
||||
|
||||
/// The DatabaseSequence builder.
|
||||
@warn_unused_result
|
||||
func fetchSequence<T>(arguments arguments: StatementArguments?, element: () -> T) -> DatabaseSequence<T> {
|
||||
// Force arguments validity. See UpdateStatement.execute(), and Database.execute()
|
||||
try! prepareWithArguments(arguments)
|
||||
@@ -317,14 +318,13 @@ public struct DatabaseSequence<T>: SequenceType {
|
||||
// Check that generator is used on a valid queue.
|
||||
preconditionValidQueue()
|
||||
|
||||
let code = sqlite3_step(sqliteStatement)
|
||||
switch code {
|
||||
switch sqlite3_step(sqliteStatement) {
|
||||
case SQLITE_DONE:
|
||||
return nil
|
||||
case SQLITE_ROW:
|
||||
return element()
|
||||
default:
|
||||
throw DatabaseError(code: code, message: statement.database.lastErrorMessage, sql: statement.sql, arguments: statement.arguments)
|
||||
case let errorCode:
|
||||
throw DatabaseError(code: errorCode, message: statement.database.lastErrorMessage, sql: statement.sql, arguments: statement.arguments)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -480,6 +480,16 @@ public struct DatabaseChanges {
|
||||
/// See https://www.sqlite.org/lang_expr.html#varparam for more information.
|
||||
public struct StatementArguments {
|
||||
|
||||
public var isEmpty: Bool {
|
||||
switch kind {
|
||||
case .Values(let values):
|
||||
return values.isEmpty
|
||||
case .NamedValues(let namedValues):
|
||||
return namedValues.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Positional Arguments
|
||||
|
||||
/// Initializes arguments from a sequence of optional values.
|
||||
@@ -531,18 +541,19 @@ public struct StatementArguments {
|
||||
kind = .NamedValues(Dictionary(sequence.map { (key, value) in return (key, value as DatabaseValueConvertible?) }))
|
||||
}
|
||||
|
||||
public var isEmpty: Bool {
|
||||
switch kind {
|
||||
case .Values(let values):
|
||||
return values.isEmpty
|
||||
case .NamedValues(let namedValues):
|
||||
return namedValues.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Not Public
|
||||
|
||||
/// Returns a double optional
|
||||
func value(named name: String) -> DatabaseValueConvertible?? {
|
||||
switch kind {
|
||||
case .Values:
|
||||
return nil
|
||||
case .NamedValues(let dictionary):
|
||||
return dictionary[name]
|
||||
}
|
||||
}
|
||||
|
||||
enum Kind {
|
||||
case Values([DatabaseValueConvertible?])
|
||||
case NamedValues(Dictionary<String, DatabaseValueConvertible?>)
|
||||
|
||||
+25
-2
@@ -14,6 +14,13 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Return as many question marks separated with commas as the *count* argument.
|
||||
///
|
||||
/// databaseQuestionMarks(count: 3) // "?,?,?"
|
||||
public func databaseQuestionMarks(count count: Int) -> String {
|
||||
return Array(count: count, repeatedValue: "?").joinWithSeparator(",")
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Internal
|
||||
|
||||
@@ -38,10 +45,18 @@ func dispatchSync<T>(queue: dispatch_queue_t, block: () throws -> T) rethrows ->
|
||||
return try dispatchSyncImpl(queue, block: block, block2: { throw $0 })
|
||||
}
|
||||
|
||||
extension Array {
|
||||
/// Removesthe first object that matches *predicate*.
|
||||
mutating func removeFirst(@noescape predicate: (Element) throws -> Bool) rethrows {
|
||||
if let index = try indexOf(predicate) {
|
||||
removeAtIndex(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Dictionary {
|
||||
|
||||
/// Creates a dictionary with the keys and values in the given sequence.
|
||||
/// Create 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 {
|
||||
@@ -49,7 +64,7 @@ extension Dictionary {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a dictionary from keys and a value builder.
|
||||
/// Create a dictionary from keys and a value builder.
|
||||
init<Sequence: SequenceType where Sequence.Generator.Element == Key>(keys: Sequence, value: Key -> Value) {
|
||||
self.init(minimumCapacity: keys.underestimateCount())
|
||||
for key in keys {
|
||||
@@ -57,3 +72,11 @@ extension Dictionary {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SequenceType where Generator.Element: Equatable {
|
||||
|
||||
/// Filter out elements contained in *removedElements*.
|
||||
func removingElementsOf<S : SequenceType where S.Generator.Element == Self.Generator.Element>(removedElements: S) -> [Self.Generator.Element] {
|
||||
return filter { element in !removedElements.contains(element) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,539 @@
|
||||
/// A FetchRequest describes an SQL query.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift#the-query-interface
|
||||
public struct FetchRequest<T> {
|
||||
let query: _SQLQuery
|
||||
|
||||
/// Initializes a FetchRequest based on table *tableName*.
|
||||
public init(tableName: String) {
|
||||
self.init(_SQLQuery(select: [_SQLResultColumn.Star(nil)], from: .Table(name: tableName, alias: nil)))
|
||||
}
|
||||
|
||||
/// Returns a prepared statement that is ready to be executed.
|
||||
@warn_unused_result
|
||||
public func selectStatement(db: Database) throws -> SelectStatement {
|
||||
// TODO: split statement generation from arguments building
|
||||
var bindings: [DatabaseValueConvertible?] = []
|
||||
let sql = try query.sql(db, &bindings)
|
||||
let statement = try db.selectStatement(sql)
|
||||
try statement.setArgumentsWithValidation(StatementArguments(bindings))
|
||||
return statement
|
||||
}
|
||||
|
||||
init(_ query: _SQLQuery) {
|
||||
self.query = query
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension FetchRequest {
|
||||
|
||||
// MARK: Request Derivation
|
||||
|
||||
/// Returns a new FetchRequest with a new net of selected columns.
|
||||
@warn_unused_result
|
||||
public func select(selection: _SQLSelectable...) -> FetchRequest<T> {
|
||||
return select(selection)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with a new net of selected columns.
|
||||
@warn_unused_result
|
||||
public func select(selection: [_SQLSelectable]) -> FetchRequest<T> {
|
||||
return FetchRequest(query.select(selection))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with a new net of selected columns.
|
||||
@warn_unused_result
|
||||
public func select(sql sql: String) -> FetchRequest<T> {
|
||||
return select(SQLLiteral(sql))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest which returns distinct rows.
|
||||
public var distinct: FetchRequest<T> {
|
||||
var query = self.query
|
||||
query.distinct = true
|
||||
return FetchRequest(query)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *predicate* added to the
|
||||
/// eventual set of already applied predicates.
|
||||
@warn_unused_result
|
||||
public func filter(predicate: _SQLExpressionType) -> FetchRequest<T> {
|
||||
return FetchRequest(query.filter(predicate.SQLExpression))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *predicate* added to the
|
||||
/// eventual set of already applied predicates.
|
||||
@warn_unused_result
|
||||
public func filter(sql sql: String) -> FetchRequest<T> {
|
||||
return filter(SQLLiteral(sql))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest grouped according to *expressions*.
|
||||
@warn_unused_result
|
||||
public func group(expressions: _SQLExpressionType...) -> FetchRequest<T> {
|
||||
return group(expressions)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest grouped according to *expressions*.
|
||||
@warn_unused_result
|
||||
public func group(expressions: [_SQLExpressionType]) -> FetchRequest<T> {
|
||||
return FetchRequest(query.group(expressions.map { $0.SQLExpression }))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with a new grouping.
|
||||
@warn_unused_result
|
||||
public func group(sql sql: String) -> FetchRequest<T> {
|
||||
return group(SQLLiteral(sql))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *predicate* added to the
|
||||
/// eventual set of already applied predicates.
|
||||
@warn_unused_result
|
||||
public func having(predicate: _SQLExpressionType) -> FetchRequest<T> {
|
||||
return FetchRequest(query.having(predicate.SQLExpression))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *sql* added to
|
||||
/// the eventual set of already applied predicates.
|
||||
@warn_unused_result
|
||||
public func having(sql sql: String) -> FetchRequest<T> {
|
||||
return having(SQLLiteral(sql))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *sortDescriptors* added to
|
||||
/// the eventual set of already applied sort descriptors.
|
||||
@warn_unused_result
|
||||
public func order(sortDescriptors: _SQLSortDescriptorType...) -> FetchRequest<T> {
|
||||
return order(sortDescriptors)
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *sortDescriptors* added to
|
||||
/// the eventual set of already applied sort descriptors.
|
||||
@warn_unused_result
|
||||
public func order(sortDescriptors: [_SQLSortDescriptorType]) -> FetchRequest<T> {
|
||||
return FetchRequest(query.order(sortDescriptors))
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest with the provided *sql* added to the
|
||||
/// eventual set of already applied sort descriptors.
|
||||
@warn_unused_result
|
||||
public func order(sql sql: String) -> FetchRequest<T> {
|
||||
return order([SQLLiteral(sql)])
|
||||
}
|
||||
|
||||
/// Returns a new FetchRequest sorted in reversed order.
|
||||
@warn_unused_result
|
||||
public func reverse() -> FetchRequest<T> {
|
||||
var query = self.query
|
||||
query.reversed = !query.reversed
|
||||
return FetchRequest(query)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest which fetches *limit* rows, starting at
|
||||
/// *offset*.
|
||||
@warn_unused_result
|
||||
public func limit(limit: Int, offset: Int? = nil) -> FetchRequest<T> {
|
||||
return FetchRequest(query.limit(limit, offset: offset))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension FetchRequest {
|
||||
|
||||
// MARK: Counting
|
||||
|
||||
/// Returns the number of rows matched by the request.
|
||||
@warn_unused_result
|
||||
public func fetchCount(db: Database) -> Int {
|
||||
return fetchAggregate(db, _SQLExpression.Count(_SQLResultColumn.Star(nil)))!
|
||||
}
|
||||
|
||||
/// Returns the number of non-NULL values of *counted*.
|
||||
@warn_unused_result
|
||||
public func fetchCount(db: Database, _ counted: _SQLSelectable) -> Int {
|
||||
return fetchAggregate(db, _SQLExpression.Count(counted ?? _SQLResultColumn.Star(nil)))!
|
||||
}
|
||||
|
||||
/// Returns the number of distinct values of *counted*.
|
||||
@warn_unused_result
|
||||
public func fetchCount(db: Database, distinct counted: _SQLExpressionType) -> Int {
|
||||
return fetchAggregate(db, count(distinct: counted.SQLExpression))!
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
private func fetchAggregate<T: DatabaseValueConvertible>(db: Database, _ selection: _SQLSelectable) -> T? {
|
||||
return T.fetchOne(db, FetchRequest<Void>(query.select([selection])))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension FetchRequest where T: RowConvertible {
|
||||
|
||||
// MARK: Fetching Record and RowConvertible
|
||||
|
||||
/// Returns a sequence of values.
|
||||
///
|
||||
/// let request = Person.order(name)
|
||||
/// let persons = request.fetch(db) // DatabaseSequence<Person>
|
||||
///
|
||||
/// The returned sequence can be consumed several times, but it may yield
|
||||
/// different results, should database changes have occurred between two
|
||||
/// generations:
|
||||
///
|
||||
/// let persons = request.fetch(db)
|
||||
/// Array(persons).count // 3
|
||||
/// db.execute("DELETE ...")
|
||||
/// Array(persons).count // 2
|
||||
///
|
||||
/// If the database is modified while the sequence is iterating, the
|
||||
/// remaining elements are undefined.
|
||||
@warn_unused_result
|
||||
public func fetch(db: Database) -> DatabaseSequence<T> {
|
||||
return try! T.fetch(selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns an array of values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.order(name)
|
||||
/// let persons = request.fetchAll(db) // DatabaseSequence<Person>
|
||||
@warn_unused_result
|
||||
public func fetchAll(db: Database) -> [T] {
|
||||
return Array(fetch(db))
|
||||
}
|
||||
|
||||
/// Returns a single value fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.order(name)
|
||||
/// let persons = request.fetchOne(db) // Person?
|
||||
@warn_unused_result
|
||||
public func fetchOne(db: Database) -> T? {
|
||||
return fetch(db).generate().next()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension TableMapping {
|
||||
|
||||
// MARK: Request Derivation
|
||||
|
||||
/// Returns a FetchRequest which fetches all rows in the table.
|
||||
@warn_unused_result
|
||||
public static func all() -> FetchRequest<Self> {
|
||||
return FetchRequest(tableName: databaseTableName())
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest which selects *selection*.
|
||||
@warn_unused_result
|
||||
public static func select(selection: _SQLSelectable...) -> FetchRequest<Self> {
|
||||
return all().select(selection)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest which selects *selection*.
|
||||
@warn_unused_result
|
||||
public static func select(selection: [_SQLSelectable]) -> FetchRequest<Self> {
|
||||
return all().select(selection)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest which selects *sql*.
|
||||
@warn_unused_result
|
||||
public static func select(sql sql: String) -> FetchRequest<Self> {
|
||||
return all().select(sql: sql)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest with the provided *predicate*.
|
||||
@warn_unused_result
|
||||
public static func filter(predicate: _SQLExpressionType) -> FetchRequest<Self> {
|
||||
return all().filter(predicate)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest with the provided *predicate*.
|
||||
@warn_unused_result
|
||||
public static func filter(sql sql: String) -> FetchRequest<Self> {
|
||||
return all().filter(sql: sql)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest sorted according to the
|
||||
/// provided *sortDescriptors*.
|
||||
@warn_unused_result
|
||||
public static func order(sortDescriptors: _SQLSortDescriptorType...) -> FetchRequest<Self> {
|
||||
return all().order(sortDescriptors)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest sorted according to the
|
||||
/// provided *sortDescriptors*.
|
||||
@warn_unused_result
|
||||
public static func order(sortDescriptors: [_SQLSortDescriptorType]) -> FetchRequest<Self> {
|
||||
return all().order(sortDescriptors)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest sorted according to *sql*.
|
||||
@warn_unused_result
|
||||
public static func order(sql sql: String) -> FetchRequest<Self> {
|
||||
return all().order(sql: sql)
|
||||
}
|
||||
|
||||
/// Returns a FetchRequest which fetches *limit* rows, starting at
|
||||
/// *offset*.
|
||||
@warn_unused_result
|
||||
public static func limit(limit: Int, offset: Int? = nil) -> FetchRequest<Self> {
|
||||
return all().limit(limit, offset: offset)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension TableMapping {
|
||||
|
||||
// MARK: Counting
|
||||
|
||||
/// Returns the number of rows.
|
||||
@warn_unused_result
|
||||
public static func fetchCount(db: Database) -> Int {
|
||||
return all().fetchCount(db)
|
||||
}
|
||||
|
||||
/// Returns the number of non-NULL values of *counted*.
|
||||
@warn_unused_result
|
||||
public static func fetchCount(db: Database, _ counted: _SQLSelectable) -> Int {
|
||||
return all().fetchCount(db, counted)
|
||||
}
|
||||
|
||||
/// Returns the number of distinct values of *counted*.
|
||||
@warn_unused_result
|
||||
public static func fetchCount(db: Database, distinct counted: _SQLExpressionType) -> Int {
|
||||
return all().fetchCount(db, distinct: counted)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching From FetchRequest
|
||||
|
||||
/// Returns a sequence of values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.select(name)
|
||||
/// let names = String.fetch(db, request) // DatabaseSequence<String>
|
||||
///
|
||||
/// The returned sequence can be consumed several times, but it may yield
|
||||
/// different results, should database changes have occurred between two
|
||||
/// generations:
|
||||
///
|
||||
/// let names = String.fetch(db, request)
|
||||
/// Array(names) // Arthur, Barbara
|
||||
/// db.execute("DELETE ...")
|
||||
/// Array(names) // Arthur
|
||||
///
|
||||
/// If the database is modified while the sequence is iterating, the
|
||||
/// remaining elements are undefined.
|
||||
@warn_unused_result
|
||||
public static func fetch<T>(db: Database, _ request: FetchRequest<T>) -> DatabaseSequence<Self> {
|
||||
return try! fetch(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns an array of values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.select(name)
|
||||
/// let names = String.fetchAll(db, request) // [String]
|
||||
@warn_unused_result
|
||||
public static func fetchAll<T>(db: Database, _ request: FetchRequest<T>) -> [Self] {
|
||||
return try! fetchAll(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns a single value fetched from a fetch request.
|
||||
///
|
||||
/// The result is nil if the query returns no row, or if no value can be
|
||||
/// extracted from the first row.
|
||||
///
|
||||
/// let request = Person.select(name)
|
||||
/// let name = String.fetchOne(db, request) // String?
|
||||
@warn_unused_result
|
||||
public static func fetchOne<T>(db: Database, _ request: FetchRequest<T>) -> Self? {
|
||||
return try! fetchOne(request.selectStatement(db))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
|
||||
// MARK: Fetching From FetchRequest
|
||||
|
||||
/// Returns a sequence of optional values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.select(name)
|
||||
/// let names = Optional<String>.fetch(db, request) // DatabaseSequence<String?>
|
||||
///
|
||||
/// The returned sequence can be consumed several times, but it may yield
|
||||
/// different results, should database changes have occurred between two
|
||||
/// generations:
|
||||
///
|
||||
/// let names = Optional<String>.fetch(db, request)
|
||||
/// Array(names) // Arthur, Barbara
|
||||
/// db.execute("DELETE ...")
|
||||
/// Array(names) // Arthur
|
||||
///
|
||||
/// If the database is modified while the sequence is iterating, the
|
||||
/// remaining elements are undefined.
|
||||
@warn_unused_result
|
||||
public static func fetch<T>(db: Database, _ request: FetchRequest<T>) -> DatabaseSequence<Wrapped?> {
|
||||
return try! fetch(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns an array of optional values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.select(name)
|
||||
/// let names = Optional<String>.fetchAll(db, request) // [String?]
|
||||
@warn_unused_result
|
||||
public static func fetchAll<T>(db: Database, _ request: FetchRequest<T>) -> [Wrapped?] {
|
||||
return try! fetchAll(request.selectStatement(db))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension DatabaseValueConvertible where Self: SQLiteStatementConvertible {
|
||||
|
||||
// MARK: Fetching From FetchRequest
|
||||
|
||||
/// Returns a sequence of values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.select(name)
|
||||
/// let names = String.fetch(db, request) // DatabaseSequence<String>
|
||||
///
|
||||
/// The returned sequence can be consumed several times, but it may yield
|
||||
/// different results, should database changes have occurred between two
|
||||
/// generations:
|
||||
///
|
||||
/// let names = String.fetch(db, request)
|
||||
/// Array(names) // Arthur, Barbara
|
||||
/// db.execute("DELETE ...")
|
||||
/// Array(names) // Arthur
|
||||
///
|
||||
/// If the database is modified while the sequence is iterating, the
|
||||
/// remaining elements are undefined.
|
||||
@warn_unused_result
|
||||
public static func fetch<T>(db: Database, _ request: FetchRequest<T>) -> DatabaseSequence<Self> {
|
||||
return try! fetch(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns an array of values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.select(name)
|
||||
/// let names = String.fetchAll(db, request) // [String]
|
||||
@warn_unused_result
|
||||
public static func fetchAll<T>(db: Database, _ request: FetchRequest<T>) -> [Self] {
|
||||
return try! fetchAll(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns a single value fetched from a fetch request.
|
||||
///
|
||||
/// The result is nil if the query returns no row, or if no value can be
|
||||
/// extracted from the first row.
|
||||
///
|
||||
/// let request = Person.select(name)
|
||||
/// let name = String.fetchOne(db, request) // String?
|
||||
@warn_unused_result
|
||||
public static func fetchOne<T>(db: Database, _ request: FetchRequest<T>) -> Self? {
|
||||
return try! fetchOne(request.selectStatement(db))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension RowConvertible {
|
||||
|
||||
// MARK: Fetching From FetchRequest
|
||||
|
||||
/// Returns a sequence of values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.order(name)
|
||||
/// let persons = Person.fetch(db, request) // DatabaseSequence<Person>
|
||||
///
|
||||
/// The returned sequence can be consumed several times, but it may yield
|
||||
/// different results, should database changes have occurred between two
|
||||
/// generations:
|
||||
///
|
||||
/// let persons = Person.fetch(db, request)
|
||||
/// Array(persons).count // 3
|
||||
/// db.execute("DELETE ...")
|
||||
/// Array(persons).count // 2
|
||||
///
|
||||
/// If the database is modified while the sequence is iterating, the
|
||||
/// remaining elements are undefined.
|
||||
@warn_unused_result
|
||||
public static func fetch<T>(db: Database, _ request: FetchRequest<T>) -> DatabaseSequence<Self> {
|
||||
return try! fetch(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns an array of values fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.order(name)
|
||||
/// let persons = Person.fetchAll(db, request) // DatabaseSequence<Person>
|
||||
@warn_unused_result
|
||||
public static func fetchAll<T>(db: Database, _ request: FetchRequest<T>) -> [Self] {
|
||||
return try! fetchAll(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns a single value fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.order(name)
|
||||
/// let persons = Person.fetchOne(db, request) // Person?
|
||||
@warn_unused_result
|
||||
public static func fetchOne<T>(db: Database, _ request: FetchRequest<T>) -> Self? {
|
||||
return try! fetchOne(request.selectStatement(db))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension Row {
|
||||
|
||||
// MARK: Fetching From FetchRequest
|
||||
|
||||
/// Returns a sequence of rows fetched from a fetch request.
|
||||
///
|
||||
/// let request = Person.select(id, name)
|
||||
/// for row in Row.fetch(db, request) {
|
||||
/// let id: Int64 = row.value(atIndex: 0)
|
||||
/// let name: String = row.value(atIndex: 1)
|
||||
/// }
|
||||
///
|
||||
/// Fetched rows are reused during the sequence iteration: don't wrap a row
|
||||
/// sequence in an array with `Array(rows)` or `rows.filter { ... }` since
|
||||
/// you would not get the distinct rows you expect. Use `Row.fetchAll(...)`
|
||||
/// instead.
|
||||
///
|
||||
/// For the same reason, make sure you make a copy whenever you extract a
|
||||
/// row for later use: `row.copy()`.
|
||||
///
|
||||
/// The returned sequence can be consumed several times, but it may yield
|
||||
/// different results, should database changes have occurred between two
|
||||
/// generations:
|
||||
///
|
||||
/// let rows = Row.fetch(statement)
|
||||
/// for row in rows { ... } // 3 steps
|
||||
/// db.execute("DELETE ...")
|
||||
/// for row in rows { ... } // 2 steps
|
||||
///
|
||||
/// If the database is modified while the sequence is iterating, the
|
||||
/// remaining elements of the sequence are undefined.
|
||||
@warn_unused_result
|
||||
public static func fetch<T>(db: Database, _ request: FetchRequest<T>) -> DatabaseSequence<Row> {
|
||||
return try! fetch(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns an array of rows fetched from a fetch request.
|
||||
///
|
||||
/// let statement = db.selectStatement("SELECT ...")
|
||||
/// let rows = Row.fetchAll(db, request)
|
||||
@warn_unused_result
|
||||
public static func fetchAll<T>(db: Database, _ request: FetchRequest<T>) -> [Row] {
|
||||
return try! fetchAll(request.selectStatement(db))
|
||||
}
|
||||
|
||||
/// Returns a single row fetched from a fetch request.
|
||||
///
|
||||
/// let statement = db.selectStatement("SELECT ...")
|
||||
/// let row = Row.fetchOne(db, request)
|
||||
@warn_unused_result
|
||||
public static func fetchOne<T>(db: Database, _ request: FetchRequest<T>) -> Row? {
|
||||
return try! fetchOne(request.selectStatement(db))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
/// This protocol is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public struct _CollatedExpression {
|
||||
let baseExpression: _SQLExpression
|
||||
let collationName: String
|
||||
}
|
||||
|
||||
extension _CollatedExpression : _SQLExpressionType {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var SQLExpression: _SQLExpression {
|
||||
return .Collate(baseExpression, collationName)
|
||||
}
|
||||
}
|
||||
|
||||
extension _CollatedExpression : _SQLSortDescriptorType {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var reversedSortDescriptor: _SQLSortDescriptor {
|
||||
return .Desc(SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a value that can be used as an argument to FetchRequest.order()
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var asc: _SQLSortDescriptorType {
|
||||
return _SQLSortDescriptor.Asc(SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a value that can be used as an argument to FetchRequest.order()
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var desc: _SQLSortDescriptorType {
|
||||
return _SQLSortDescriptor.Desc(SQLExpression)
|
||||
}
|
||||
|
||||
/// This method is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public func orderingSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
return try SQLExpression.orderingSQL(&bindings)
|
||||
}
|
||||
}
|
||||
|
||||
extension _DerivedSQLExpressionType {
|
||||
|
||||
/// This method is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public func collating(collationName: String) -> _CollatedExpression {
|
||||
return _CollatedExpression(baseExpression: SQLExpression, collationName: collationName)
|
||||
}
|
||||
|
||||
/// This method is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public func collating(collation: DatabaseCollation) -> _CollatedExpression {
|
||||
return collating(collation.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator = COLLATE
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Equal(
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Equal(
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator != COLLATE
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.NotEqual(
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.NotEqual(
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator < COLLATE
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator("<",
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator("<",
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator <= COLLATE
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator("<=",
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator("<=",
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator > COLLATE
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator(">",
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator(">",
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator >= COLLATE
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator(">=",
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.InfixOperator(">=",
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator BETWEEN COLLATE
|
||||
|
||||
extension ClosedInterval where Bound: _SQLExpressionType {
|
||||
/// Returns a SQL expression that compares the inclusion of a value in
|
||||
/// an interval.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Between(
|
||||
value: element.baseExpression,
|
||||
min: start.SQLExpression,
|
||||
max: end.SQLExpression),
|
||||
element.collationName)
|
||||
}
|
||||
}
|
||||
|
||||
extension HalfOpenInterval where Bound: _SQLExpressionType {
|
||||
/// Returns a SQL expression that compares the inclusion of a value in
|
||||
/// an interval.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND",
|
||||
.Collate(
|
||||
.InfixOperator(">=",
|
||||
element.baseExpression,
|
||||
start.SQLExpression),
|
||||
element.collationName),
|
||||
.Collate(
|
||||
.InfixOperator("<",
|
||||
element.baseExpression,
|
||||
end.SQLExpression),
|
||||
element.collationName))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator IN COLLATE
|
||||
|
||||
extension SequenceType where Self.Generator.Element: _SQLExpressionType {
|
||||
/// Returns a SQL expression that compares the inclusion of a value in
|
||||
/// a sequence.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.In(
|
||||
map { $0.SQLExpression },
|
||||
element.baseExpression),
|
||||
element.collationName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator IS COLLATE
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Is(
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.Is(
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator IS NOT COLLATE
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _CollatedExpression, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.IsNot(
|
||||
lhs.baseExpression,
|
||||
rhs.SQLExpression),
|
||||
lhs.collationName)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _SQLExpressionType, rhs: _CollatedExpression) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Collate(
|
||||
.IsNot(
|
||||
lhs.SQLExpression,
|
||||
rhs.baseExpression),
|
||||
rhs.collationName)
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
// MARK: - Custom Functions
|
||||
|
||||
extension DatabaseFunction {
|
||||
/// Returns an SQL expression that applies the function.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func apply(arguments: _SQLExpressionType...) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function(name, arguments.map { $0.SQLExpression })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - ABS(...)
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func abs(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("ABS", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
// MARK: - AVG(...)
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func average(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("AVG", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
// MARK: - COUNT(...)
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func count(counted: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Count(counted)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - COUNT(DISTINCT ...)
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func count(distinct value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.CountDistinct(value.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - IFNULL(...)
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func ?? (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("IFNULL", [lhs.SQLExpression, rhs.SQLExpression])
|
||||
}
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func ?? (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
if let lhs = lhs {
|
||||
return _SQLExpression.Function("IFNULL", [lhs.SQLExpression, rhs.SQLExpression])
|
||||
} else {
|
||||
return rhs.SQLExpression
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - LOWER(...)
|
||||
|
||||
extension _DerivedSQLExpressionType {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public var lowercaseString: _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("LOWER", [SQLExpression])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - MAX(...)
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func max(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("MAX", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
// MARK: - MIN(...)
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func min(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("MIN", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SUM(...)
|
||||
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public func sum(value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("SUM", [value.SQLExpression])
|
||||
}
|
||||
|
||||
|
||||
// MARK: - UPPER(...)
|
||||
|
||||
extension _DerivedSQLExpressionType {
|
||||
/// Returns an SQL expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-functions
|
||||
public var uppercaseString: _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Function("UPPER", [SQLExpression])
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
// MARK: - Operator =
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Equal(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Equal(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func == (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Equal(lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator !=
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.NotEqual(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.NotEqual(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func != (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.NotEqual(lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator <
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func < (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator <=
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func <= (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("<=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator >
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func > (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator >=
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func >= (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator(">=", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator *
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func * (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("*", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func * (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("*", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func * (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("*", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator /
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func / (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("/", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func / (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("/", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func / (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("/", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator +
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func + (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("+", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func + (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("+", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func + (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("+", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator - (prefix)
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public prefix func - (value: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .PrefixOperator("-", value.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator - (infix)
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func - (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("-", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func - (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("-", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL arithmetic expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func - (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _SQLExpression {
|
||||
return .InfixOperator("-", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator AND
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func && (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func && (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func && (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator BETWEEN
|
||||
|
||||
extension Range where Element: protocol<_SQLExpressionType, BidirectionalIndexType> {
|
||||
/// Returns a SQL expression that compares the inclusion of a value in
|
||||
/// a range.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Between(value: element.SQLExpression, min: startIndex.SQLExpression, max: endIndex.predecessor().SQLExpression)
|
||||
}
|
||||
}
|
||||
|
||||
extension ClosedInterval where Bound: _SQLExpressionType {
|
||||
/// Returns a SQL expression that compares the inclusion of a value in
|
||||
/// an interval.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Between(value: element.SQLExpression, min: start.SQLExpression, max: end.SQLExpression)
|
||||
}
|
||||
}
|
||||
|
||||
extension HalfOpenInterval where Bound: _SQLExpressionType {
|
||||
/// Returns a SQL expression that compares the inclusion of a value in
|
||||
/// an interval.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("AND", .InfixOperator(">=", element.SQLExpression, start.SQLExpression), .InfixOperator("<", element.SQLExpression, end.SQLExpression))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator IN
|
||||
|
||||
extension SequenceType where Self.Generator.Element: _SQLExpressionType {
|
||||
/// Returns a SQL expression that compares the inclusion of a value in
|
||||
/// a sequence.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func contains(element: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.In(map { $0.SQLExpression }, element.SQLExpression)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator IS
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Is(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Is(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func === (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Is(lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator IS NOT
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType?) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.IsNot(lhs.SQLExpression, rhs?.SQLExpression ?? .Value(nil))
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _SQLExpressionType?, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.IsNot(lhs?.SQLExpression ?? .Value(nil), rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL expression that compares two values.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func !== (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.IsNot(lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator OR
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func || (lhs: _DerivedSQLExpressionType, rhs: _SQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func || (lhs: _SQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public func || (lhs: _DerivedSQLExpressionType, rhs: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.InfixOperator("OR", lhs.SQLExpression, rhs.SQLExpression)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Operator NOT
|
||||
|
||||
/// Returns a SQL logical expression.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#sql-operators
|
||||
public prefix func ! (value: _DerivedSQLExpressionType) -> _DerivedSQLExpressionType {
|
||||
return _SQLExpression.Not(value.SQLExpression)
|
||||
}
|
||||
@@ -0,0 +1,618 @@
|
||||
|
||||
|
||||
// MARK: - _SQLQuery
|
||||
|
||||
struct _SQLQuery {
|
||||
var selection: [_SQLSelectable]
|
||||
var distinct: Bool
|
||||
var source: _SQLSource?
|
||||
var whereExpression: _SQLExpression?
|
||||
var groupByExpressions: [_SQLExpression]
|
||||
var sortDescriptors: [_SQLSortDescriptorType]
|
||||
var reversed: Bool
|
||||
var havingExpression: _SQLExpression?
|
||||
var limit: _SQLLimit?
|
||||
|
||||
init(
|
||||
select selection: [_SQLSelectable],
|
||||
distinct: Bool = false,
|
||||
from source: _SQLSource? = nil,
|
||||
filter whereExpression: _SQLExpression? = nil,
|
||||
groupBy groupByExpressions: [_SQLExpression] = [],
|
||||
orderBy sortDescriptors: [_SQLSortDescriptorType] = [],
|
||||
reversed: Bool = false,
|
||||
having havingExpression: _SQLExpression? = nil,
|
||||
limit: _SQLLimit? = nil)
|
||||
{
|
||||
self.selection = selection
|
||||
self.distinct = distinct
|
||||
self.source = source
|
||||
self.whereExpression = whereExpression
|
||||
self.groupByExpressions = groupByExpressions
|
||||
self.sortDescriptors = sortDescriptors
|
||||
self.reversed = reversed
|
||||
self.havingExpression = havingExpression
|
||||
self.limit = limit
|
||||
}
|
||||
|
||||
func sql(db: Database, inout _ bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
var sql = "SELECT"
|
||||
|
||||
if distinct {
|
||||
sql += " DISTINCT"
|
||||
}
|
||||
|
||||
sql += try " " + selection.map { try $0.resultColumnSQL(&bindings) }.joinWithSeparator(", ")
|
||||
|
||||
if let source = source {
|
||||
sql += try " FROM " + source.sql(db, &bindings)
|
||||
}
|
||||
|
||||
if let whereExpression = whereExpression {
|
||||
sql += try " WHERE " + whereExpression.sql(&bindings)
|
||||
}
|
||||
|
||||
if !groupByExpressions.isEmpty {
|
||||
sql += try " GROUP BY " + groupByExpressions.map { try $0.sql(&bindings) }.joinWithSeparator(", ")
|
||||
}
|
||||
|
||||
if let havingExpression = havingExpression {
|
||||
sql += try " HAVING " + havingExpression.sql(&bindings)
|
||||
}
|
||||
|
||||
var sortDescriptors = self.sortDescriptors
|
||||
if reversed {
|
||||
if sortDescriptors.isEmpty {
|
||||
guard let source = source, case .Table(let tableName, let alias) = source else {
|
||||
throw DatabaseError(message: "can't reverse without a source table")
|
||||
}
|
||||
guard case let columns = try db.primaryKey(tableName).columns where !columns.isEmpty else {
|
||||
throw DatabaseError(message: "can't reverse a table without primary key")
|
||||
}
|
||||
sortDescriptors = columns.map { _SQLSortDescriptor.Desc(_SQLExpression.Identifier(identifier: $0, sourceName: alias)) }
|
||||
} else {
|
||||
sortDescriptors = sortDescriptors.map { $0.reversedSortDescriptor }
|
||||
}
|
||||
}
|
||||
if !sortDescriptors.isEmpty {
|
||||
sql += try " ORDER BY " + sortDescriptors.map { try $0.orderingSQL(&bindings) }.joinWithSeparator(", ")
|
||||
}
|
||||
|
||||
if let limit = limit {
|
||||
sql += " LIMIT " + limit.sql
|
||||
}
|
||||
|
||||
return sql
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLQuery derivation
|
||||
|
||||
extension _SQLQuery {
|
||||
|
||||
@warn_unused_result
|
||||
func select(selection: [_SQLSelectable]) -> _SQLQuery {
|
||||
var query = self
|
||||
query.selection = selection
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func filter(predicate: _SQLExpression) -> _SQLQuery {
|
||||
var query = self
|
||||
if let whereExpression = query.whereExpression {
|
||||
query.whereExpression = .InfixOperator("AND", whereExpression, predicate)
|
||||
} else {
|
||||
query.whereExpression = predicate
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func group(expressions: [_SQLExpression]) -> _SQLQuery {
|
||||
var query = self
|
||||
query.groupByExpressions = expressions
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func having(predicate: _SQLExpression) -> _SQLQuery {
|
||||
var query = self
|
||||
if let havingExpression = query.havingExpression {
|
||||
query.havingExpression = .InfixOperator("AND", havingExpression, predicate)
|
||||
} else {
|
||||
query.havingExpression = predicate
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func order(sortDescriptors: [_SQLSortDescriptorType]) -> _SQLQuery {
|
||||
var query = self
|
||||
query.sortDescriptors.appendContentsOf(sortDescriptors)
|
||||
return query
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
func limit(limit: Int, offset: Int?) -> _SQLQuery {
|
||||
var query = self
|
||||
query.limit = _SQLLimit(limit: limit, offset: offset)
|
||||
return query
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLSource
|
||||
|
||||
indirect enum _SQLSource {
|
||||
case Table(name: String, alias: String?)
|
||||
case Query(_SQLQuery, alias: String)
|
||||
case Join(_SQLSource, _SQLExpression, _SQLSource)
|
||||
|
||||
// a JOIN b ON ab JOIN c ON abc
|
||||
// ((a,b,ab), c, abc)
|
||||
func sql(db: Database, inout _ bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
switch self {
|
||||
case .Table(let table, let alias):
|
||||
if let alias = alias {
|
||||
return table.quotedDatabaseIdentifier + " AS " + alias.quotedDatabaseIdentifier
|
||||
} else {
|
||||
return table.quotedDatabaseIdentifier
|
||||
}
|
||||
case .Query(let query, let alias):
|
||||
return try "(" + query.sql(db, &bindings) + ") AS " + alias.quotedDatabaseIdentifier
|
||||
case .Join(let first, let expression, let second):
|
||||
switch second {
|
||||
case .Join:
|
||||
fatalError("WTF")
|
||||
default:
|
||||
break
|
||||
}
|
||||
return try first.sql(db, &bindings) + " JOIN " + second.sql(db, &bindings) + " ON " + expression.sql(&bindings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLSortDescriptorType
|
||||
|
||||
/// This protocol is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public protocol _SQLSortDescriptorType {
|
||||
var reversedSortDescriptor: _SQLSortDescriptor { get }
|
||||
func orderingSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String
|
||||
}
|
||||
|
||||
/// This type is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public enum _SQLSortDescriptor {
|
||||
case Asc(_SQLExpression)
|
||||
case Desc(_SQLExpression)
|
||||
}
|
||||
|
||||
extension _SQLSortDescriptor : _SQLSortDescriptorType {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var reversedSortDescriptor: _SQLSortDescriptor {
|
||||
switch self {
|
||||
case .Asc(let expression):
|
||||
return .Desc(expression)
|
||||
case .Desc(let expression):
|
||||
return .Asc(expression)
|
||||
}
|
||||
}
|
||||
|
||||
/// This method is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public func orderingSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
switch self {
|
||||
case .Asc(let expression):
|
||||
return try expression.sql(&bindings) + " ASC"
|
||||
case .Desc(let expression):
|
||||
return try expression.sql(&bindings) + " DESC"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLLimit
|
||||
|
||||
struct _SQLLimit {
|
||||
let limit: Int
|
||||
let offset: Int?
|
||||
|
||||
var sql: String {
|
||||
if let offset = offset {
|
||||
return "\(limit) OFFSET \(offset)"
|
||||
} else {
|
||||
return "\(limit)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLExpressionType
|
||||
|
||||
public protocol _SQLExpressionType {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
var SQLExpression: _SQLExpression { get }
|
||||
}
|
||||
|
||||
// Conformance to _SQLExpressionType
|
||||
extension DatabaseValueConvertible {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var SQLExpression: _SQLExpression {
|
||||
return .Value(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// This protocol is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public protocol _DerivedSQLExpressionType : _SQLExpressionType, _SQLSortDescriptorType, _SQLSelectable {
|
||||
}
|
||||
|
||||
// Conformance to _SQLSortDescriptorType
|
||||
extension _DerivedSQLExpressionType {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var reversedSortDescriptor: _SQLSortDescriptor {
|
||||
return .Desc(SQLExpression)
|
||||
}
|
||||
|
||||
/// This method is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public func orderingSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
return try SQLExpression.sql(&bindings)
|
||||
}
|
||||
}
|
||||
|
||||
// Conformance to _SQLSelectable
|
||||
extension _DerivedSQLExpressionType {
|
||||
|
||||
/// This method is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public func resultColumnSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
return try SQLExpression.sql(&bindings)
|
||||
}
|
||||
|
||||
/// This method is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public func countedSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
return try SQLExpression.sql(&bindings)
|
||||
}
|
||||
}
|
||||
|
||||
extension _DerivedSQLExpressionType {
|
||||
|
||||
/// Returns a value that can be used as an argument to FetchRequest.order()
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var asc: _SQLSortDescriptorType {
|
||||
return _SQLSortDescriptor.Asc(SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a value that can be used as an argument to FetchRequest.order()
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var desc: _SQLSortDescriptorType {
|
||||
return _SQLSortDescriptor.Desc(SQLExpression)
|
||||
}
|
||||
|
||||
/// Returns a value that can be used as an argument to FetchRequest.select()
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public func aliased(alias: String) -> _SQLSelectable {
|
||||
return _SQLResultColumn.Expression(SQLExpression, alias)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// This type is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public indirect enum _SQLExpression {
|
||||
/// For example: `name || 'rrr' AS pirateName`
|
||||
case Literal(String)
|
||||
|
||||
/// For example: `1` or `'foo'`
|
||||
case Value(DatabaseValueConvertible?)
|
||||
|
||||
/// For example: `name`, `table.name`
|
||||
case Identifier(identifier: String, sourceName: String?)
|
||||
|
||||
/// For example: `name = 'foo' COLLATE NOCASE`
|
||||
case Collate(_SQLExpression, String)
|
||||
|
||||
/// For example: `NOT condition`
|
||||
case Not(_SQLExpression)
|
||||
|
||||
/// For example: `name = 'foo'`
|
||||
case Equal(_SQLExpression, _SQLExpression)
|
||||
|
||||
/// For example: `name <> 'foo'`
|
||||
case NotEqual(_SQLExpression, _SQLExpression)
|
||||
|
||||
/// For example: `name IS NULL`
|
||||
case Is(_SQLExpression, _SQLExpression)
|
||||
|
||||
/// For example: `name IS NOT NULL`
|
||||
case IsNot(_SQLExpression, _SQLExpression)
|
||||
|
||||
/// For example: `-value`
|
||||
case PrefixOperator(String, _SQLExpression)
|
||||
|
||||
/// For example: `age + 1`
|
||||
case InfixOperator(String, _SQLExpression, _SQLExpression)
|
||||
|
||||
/// For example: `id IN (1,2,3)`
|
||||
case In([_SQLExpression], _SQLExpression)
|
||||
|
||||
/// For example: `age BETWEEN 1 AND 2`
|
||||
case Between(value: _SQLExpression, min: _SQLExpression, max: _SQLExpression)
|
||||
|
||||
/// For example: `LOWER(name)`
|
||||
case Function(String, [_SQLExpression])
|
||||
|
||||
/// For example: `COUNT(*)`
|
||||
case Count(_SQLSelectable)
|
||||
|
||||
/// For example: `COUNT(DISTINCT name)`
|
||||
case CountDistinct(_SQLExpression)
|
||||
|
||||
///
|
||||
func sql(inout bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
switch self {
|
||||
case .Literal(let sql):
|
||||
return sql
|
||||
|
||||
case .Value(let value):
|
||||
guard let value = value else {
|
||||
return "NULL"
|
||||
}
|
||||
bindings.append(value)
|
||||
return "?"
|
||||
|
||||
case .Identifier(let identifier, let sourceName):
|
||||
if let sourceName = sourceName {
|
||||
return sourceName.quotedDatabaseIdentifier + "." + identifier.quotedDatabaseIdentifier
|
||||
} else {
|
||||
return identifier.quotedDatabaseIdentifier
|
||||
}
|
||||
|
||||
case .Collate(let expression, let collation):
|
||||
let sql = try expression.sql(&bindings)
|
||||
let chars = sql.characters
|
||||
if chars.last! == ")" {
|
||||
return String(chars.prefixUpTo(chars.endIndex.predecessor())) + " COLLATE " + collation + ")"
|
||||
} else {
|
||||
return sql + " COLLATE " + collation
|
||||
}
|
||||
|
||||
case .Not(let condition):
|
||||
switch condition {
|
||||
case .Not(let expression):
|
||||
return try expression.sql(&bindings)
|
||||
case .In(let expressions, let expression):
|
||||
if expressions.isEmpty {
|
||||
return "1"
|
||||
} else {
|
||||
return try "(" + expression.sql(&bindings) + " NOT IN (" + expressions.map { try $0.sql(&bindings) }.joinWithSeparator(", ") + "))"
|
||||
}
|
||||
case .Equal(let lhs, let rhs):
|
||||
return try _SQLExpression.NotEqual(lhs, rhs).sql(&bindings)
|
||||
case .NotEqual(let lhs, let rhs):
|
||||
return try _SQLExpression.Equal(lhs, rhs).sql(&bindings)
|
||||
case .Is(let lhs, let rhs):
|
||||
return try _SQLExpression.IsNot(lhs, rhs).sql(&bindings)
|
||||
case .IsNot(let lhs, let rhs):
|
||||
return try _SQLExpression.Is(lhs, rhs).sql(&bindings)
|
||||
default:
|
||||
return try "(NOT " + condition.sql(&bindings) + ")"
|
||||
}
|
||||
|
||||
case .Equal(let lhs, let rhs):
|
||||
switch (lhs, rhs) {
|
||||
case (let lhs, .Value(let rhs)) where rhs == nil:
|
||||
// Swiftism!
|
||||
// Turn `filter(a == nil)` into `a IS NULL` since the intention is obviously to check for NULL. `a = NULL` would evaluate to NULL.
|
||||
return try "(" + lhs.sql(&bindings) + " IS NULL)"
|
||||
case (.Value(let lhs), let rhs) where lhs == nil:
|
||||
// Swiftism!
|
||||
return try "(" + rhs.sql(&bindings) + " IS NULL)"
|
||||
default:
|
||||
return try "(" + lhs.sql(&bindings) + " = " + rhs.sql(&bindings) + ")"
|
||||
}
|
||||
|
||||
case .NotEqual(let lhs, let rhs):
|
||||
switch (lhs, rhs) {
|
||||
case (let lhs, .Value(let rhs)) where rhs == nil:
|
||||
// Swiftism!
|
||||
// Turn `filter(a != nil)` into `a IS NOT NULL` since the intention is obviously to check for NULL. `a <> NULL` would evaluate to NULL.
|
||||
return try "(" + lhs.sql(&bindings) + " IS NOT NULL)"
|
||||
case (.Value(let lhs), let rhs) where lhs == nil:
|
||||
// Swiftism!
|
||||
return try "(" + rhs.sql(&bindings) + " IS NOT NULL)"
|
||||
default:
|
||||
return try "(" + lhs.sql(&bindings) + " <> " + rhs.sql(&bindings) + ")"
|
||||
}
|
||||
|
||||
case .Is(let lhs, let rhs):
|
||||
switch (lhs, rhs) {
|
||||
case (let lhs, .Value(let rhs)) where rhs == nil:
|
||||
return try "(" + lhs.sql(&bindings) + " IS NULL)"
|
||||
case (.Value(let lhs), let rhs) where lhs == nil:
|
||||
return try "(" + rhs.sql(&bindings) + " IS NULL)"
|
||||
default:
|
||||
return try "(" + lhs.sql(&bindings) + " IS " + rhs.sql(&bindings) + ")"
|
||||
}
|
||||
|
||||
case .IsNot(let lhs, let rhs):
|
||||
switch (lhs, rhs) {
|
||||
case (let lhs, .Value(let rhs)) where rhs == nil:
|
||||
return try "(" + lhs.sql(&bindings) + " IS NOT NULL)"
|
||||
case (.Value(let lhs), let rhs) where lhs == nil:
|
||||
return try "(" + rhs.sql(&bindings) + " IS NOT NULL)"
|
||||
default:
|
||||
return try "(" + lhs.sql(&bindings) + " IS NOT " + rhs.sql(&bindings) + ")"
|
||||
}
|
||||
|
||||
case .PrefixOperator(let SQLOperator, let value):
|
||||
return try SQLOperator + value.sql(&bindings)
|
||||
|
||||
case .InfixOperator(let SQLOperator, let lhs, let rhs):
|
||||
return try "(" + lhs.sql(&bindings) + " \(SQLOperator) " + rhs.sql(&bindings) + ")"
|
||||
|
||||
case .In(let expressions, let expression):
|
||||
guard !expressions.isEmpty else {
|
||||
return "0"
|
||||
}
|
||||
return try "(" + expression.sql(&bindings) + " IN (" + expressions.map { try $0.sql(&bindings) }.joinWithSeparator(", ") + "))"
|
||||
|
||||
case .Between(value: let value, min: let min, max: let max):
|
||||
return try "(" + value.sql(&bindings) + " BETWEEN " + min.sql(&bindings) + " AND " + max.sql(&bindings) + ")"
|
||||
|
||||
case .Function(let functionName, let functionArguments):
|
||||
return try functionName + "(" + functionArguments.map { try $0.sql(&bindings) }.joinWithSeparator(", ") + ")"
|
||||
|
||||
case .Count(let counted):
|
||||
return try "COUNT(" + counted.countedSQL(&bindings) + ")"
|
||||
|
||||
case .CountDistinct(let expression):
|
||||
return try "COUNT(DISTINCT " + expression.sql(&bindings) + ")"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension _SQLExpression : _DerivedSQLExpressionType {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var SQLExpression: _SQLExpression {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLSelectable
|
||||
|
||||
/// This protocol is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public protocol _SQLSelectable {
|
||||
func resultColumnSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String
|
||||
func countedSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String
|
||||
}
|
||||
|
||||
enum _SQLResultColumn {
|
||||
case Star(String?)
|
||||
case Expression(_SQLExpression, String)
|
||||
}
|
||||
|
||||
extension _SQLResultColumn : _SQLSelectable {
|
||||
|
||||
func resultColumnSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
switch self {
|
||||
case .Star(let sourceName):
|
||||
if let sourceName = sourceName {
|
||||
return sourceName.quotedDatabaseIdentifier + ".*"
|
||||
} else {
|
||||
return "*"
|
||||
}
|
||||
case .Expression(let expression, let identifier):
|
||||
return try expression.sql(&bindings) + " AS " + identifier.quotedDatabaseIdentifier
|
||||
}
|
||||
}
|
||||
|
||||
func countedSQL(inout bindings: [DatabaseValueConvertible?]) throws -> String {
|
||||
switch self {
|
||||
case .Star:
|
||||
return "*"
|
||||
case .Expression(let expression, _):
|
||||
return try expression.sql(&bindings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: SQLLiteral
|
||||
|
||||
struct SQLLiteral {
|
||||
let sql: String
|
||||
init(_ sql: String) {
|
||||
self.sql = sql
|
||||
}
|
||||
}
|
||||
|
||||
extension SQLLiteral : _DerivedSQLExpressionType {
|
||||
var SQLExpression: _SQLExpression {
|
||||
return .Literal(sql)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SQLColumn
|
||||
|
||||
/// A column in the database
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift#the-query-interface
|
||||
public struct SQLColumn {
|
||||
let sourceName: String?
|
||||
|
||||
/// The name of the column
|
||||
public let name: String
|
||||
|
||||
/// Initializes a column given its name.
|
||||
public init(_ name: String) {
|
||||
self.name = name
|
||||
self.sourceName = nil
|
||||
}
|
||||
|
||||
init(_ name: String, sourceName: String?) {
|
||||
self.name = name
|
||||
self.sourceName = sourceName
|
||||
}
|
||||
}
|
||||
|
||||
extension SQLColumn : _DerivedSQLExpressionType {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public var SQLExpression: _SQLExpression {
|
||||
return .Identifier(identifier: name, sourceName: sourceName)
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
MODULEMAP_FILE = $(SRCROOT)/GRDB/module.modulemap
|
||||
@@ -92,7 +92,7 @@ public struct DatabaseMigrator {
|
||||
private var migrations: [Migration] = []
|
||||
|
||||
private mutating func registerMigration(migration: Migration) {
|
||||
precondition(migrations.map({ $0.identifier }).contains(migration.identifier) == false, "already registered migration: \"\(migration.identifier)\"")
|
||||
precondition(!migrations.map({ $0.identifier }).contains(migration.identifier), "already registered migration: \"\(migration.identifier)\"")
|
||||
migrations.append(migration)
|
||||
}
|
||||
|
||||
@@ -101,12 +101,10 @@ public struct DatabaseMigrator {
|
||||
}
|
||||
|
||||
private func runMigrations(db: Database) throws {
|
||||
let appliedMigrationIdentifiers = String.fetchAll(db, "SELECT identifier FROM grdb_migrations")
|
||||
try migrations
|
||||
.filter { !appliedMigrationIdentifiers.contains($0.identifier) }
|
||||
.forEach {
|
||||
try $0.run(db)
|
||||
db.clearSchemaCache()
|
||||
}
|
||||
let appliedIdentifiers = String.fetchAll(db, "SELECT identifier FROM grdb_migrations")
|
||||
for migration in migrations where !appliedIdentifiers.contains(migration.identifier) {
|
||||
try migration.run(db)
|
||||
db.clearSchemaCache()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
GRDB Sources
|
||||
============
|
||||
|
||||
- [Core](Core):
|
||||
|
||||
The core of the SQLite API: database, configuration, statements, rows, values, and basic protocols.
|
||||
|
||||
- [Foundation](Foundation):
|
||||
|
||||
The GRDB additions that support Foundation types: NSDate, NSDateComponents, NSNumber, etc.
|
||||
|
||||
- [Migrations](Migrations):
|
||||
|
||||
Ditto
|
||||
|
||||
- [Record](Record):
|
||||
|
||||
The Record class.
|
||||
|
||||
- [Swift](Swift):
|
||||
|
||||
The GRDB additions that support the Swift standard library: Int, String, Bool, enums, etc.
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/// Record is a class that wraps a table row, or the result of any query. It is
|
||||
/// designed to be subclassed.
|
||||
public class Record : RowConvertible, DatabaseTableMapping, DatabasePersistable {
|
||||
public class Record : RowConvertible, TableMapping, Persistable {
|
||||
|
||||
// MARK: - Initializers
|
||||
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
import GRDB
|
||||
|
||||
|
||||
// ==============================================
|
||||
// SETUP
|
||||
|
||||
// Create the databsae
|
||||
|
||||
var configuration = Configuration()
|
||||
configuration.trace = { print($0) }
|
||||
configuration.trace = { print($0) } // Log all SQL statements
|
||||
|
||||
let dbQueue = DatabaseQueue(configuration: configuration) // Memory database
|
||||
var migrator = DatabaseMigrator()
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
@@ -37,6 +41,7 @@ class Person : Record {
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
||||
// Record overrides
|
||||
|
||||
override class func databaseTableName() -> String {
|
||||
@@ -60,7 +65,16 @@ class Person : Record {
|
||||
}
|
||||
|
||||
|
||||
// Insert and fetch persons from the database
|
||||
// Define colums
|
||||
|
||||
struct Col {
|
||||
static let firstName = SQLColumn("firstName")
|
||||
static let lastName = SQLColumn("lastName")
|
||||
}
|
||||
|
||||
|
||||
// END OF SETUP
|
||||
// ==============================================
|
||||
|
||||
try! dbQueue.inTransaction { db in
|
||||
try Person(firstName: "Arthur", lastName: "Miller").insert(db)
|
||||
@@ -70,8 +84,7 @@ try! dbQueue.inTransaction { db in
|
||||
}
|
||||
|
||||
let persons = dbQueue.inDatabase { db in
|
||||
Person.fetchAll(db, "SELECT * FROM persons ORDER BY firstName, lastName")
|
||||
Person.order(Col.firstName, Col.lastName).fetchAll(db)
|
||||
}
|
||||
|
||||
print(persons)
|
||||
print(persons.map { $0.fullName })
|
||||
@@ -0,0 +1 @@
|
||||
MODULEMAP_FILE = $(SRCROOT)/Support/module.modulemap
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.41.0</string>
|
||||
<string>0.42.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
File renamed without changes.
@@ -1,5 +1,20 @@
|
||||
- [ ] How to have robust single writer/several readers?
|
||||
- [ ] protocol DatabaseEquatable, with default implementation for MutableDatabasePersistable
|
||||
- [ ] protocol DatabaseEquatable, with default implementation for MutablePersistable
|
||||
- [ ] Query builder
|
||||
- [ ] Question the utility of request.fetchCount(db, Col.name) and request.fetchCount(db, distinct: Col.name)
|
||||
- [ ] Check for gross pollution (`1.SQLexpression`)
|
||||
- [ ] SELECT readers.*, books.* FROM ... JOIN ...
|
||||
- [ ] date functions
|
||||
- [ ] Document custom functions
|
||||
- [ ] RANDOM() https://www.sqlite.org/lang_corefunc.html
|
||||
- [ ] LIKE https://www.sqlite.org/lang_expr.html
|
||||
- [ ] GLOB https://www.sqlite.org/lang_expr.html
|
||||
- [ ] MATCH https://www.sqlite.org/lang_expr.html
|
||||
- [ ] REGEXP https://www.sqlite.org/lang_expr.html
|
||||
- [ ] CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END https://www.sqlite.org/lang_expr.html
|
||||
- [ ] EXISTS https://www.sqlite.org/lang_expr.html
|
||||
|
||||
|
||||
|
||||
Not sure:
|
||||
|
||||
|
||||
File renamed without changes.
Generated
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Vendored
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -5,10 +5,12 @@ class GRDBTestCase: XCTestCase {
|
||||
var databasePath: String!
|
||||
var dbQueue: DatabaseQueue!
|
||||
var sqlQueries: [String]!
|
||||
var lastSQLQuery: String!
|
||||
var dbConfiguration: Configuration {
|
||||
var dbConfiguration = Configuration()
|
||||
dbConfiguration.trace = { (sql) in
|
||||
self.sqlQueries.append(sql)
|
||||
self.lastSQLQuery = sql
|
||||
// LogSQL(sql) // Uncomment for verbose tests
|
||||
}
|
||||
return dbConfiguration
|
||||
@@ -39,4 +41,11 @@ class GRDBTestCase: XCTestCase {
|
||||
XCTFail("unexpected error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func sql<T>(request: FetchRequest<T>) -> String {
|
||||
return dbQueue.inDatabase { db in
|
||||
let _ = Row.fetchOne(db, request)
|
||||
return self.lastSQLQuery
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Submodule
+1
Submodule Tests/Performance/SQLite.swift added at d304343f5e.
Submodule
+1
Submodule Tests/Performance/fmdb added at 6c0ff9c423.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -391,7 +391,7 @@ class ConcurrencyTests: XCTestCase {
|
||||
do {
|
||||
dispatch_semaphore_wait(s1, DISPATCH_TIME_FOREVER)
|
||||
try self.dbQueue2.inTransaction(.Deferred) { db in
|
||||
Row.fetchAll(db, "SELECT * FROM stuffs")
|
||||
let _ = Row.fetchAll(db, "SELECT * FROM stuffs")
|
||||
dispatch_semaphore_signal(s2)
|
||||
usleep(100_000) // 0.1s
|
||||
return .Commit
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4
-4
@@ -1,7 +1,7 @@
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
struct MutablePersistablePerson : MutableDatabasePersistable {
|
||||
struct MutablePersistablePerson : MutablePersistable {
|
||||
var id: Int64?
|
||||
var name: String?
|
||||
|
||||
@@ -18,7 +18,7 @@ struct MutablePersistablePerson : MutableDatabasePersistable {
|
||||
}
|
||||
}
|
||||
|
||||
struct MutablePersistableCountry : MutableDatabasePersistable {
|
||||
struct MutablePersistableCountry : MutablePersistable {
|
||||
var rowID: Int64?
|
||||
var isoCode: String
|
||||
var name: String
|
||||
@@ -36,7 +36,7 @@ struct MutablePersistableCountry : MutableDatabasePersistable {
|
||||
}
|
||||
}
|
||||
|
||||
struct MutablePersistableCustomizedCountry : MutableDatabasePersistable {
|
||||
struct MutablePersistableCustomizedCountry : MutablePersistable {
|
||||
var rowID: Int64?
|
||||
var isoCode: String
|
||||
var name: String
|
||||
@@ -84,7 +84,7 @@ struct MutablePersistableCustomizedCountry : MutableDatabasePersistable {
|
||||
}
|
||||
}
|
||||
|
||||
class MutableDatabasePersistableTests: GRDBTestCase {
|
||||
class MutablePersistableTests: GRDBTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
struct PersistablePerson : DatabasePersistable {
|
||||
struct PersistablePerson : Persistable {
|
||||
var name: String?
|
||||
var age: Int?
|
||||
|
||||
@@ -14,7 +14,7 @@ struct PersistablePerson : DatabasePersistable {
|
||||
}
|
||||
}
|
||||
|
||||
class PersistablePersonClass : DatabasePersistable {
|
||||
class PersistablePersonClass : Persistable {
|
||||
var id: Int64?
|
||||
var name: String?
|
||||
var age: Int?
|
||||
@@ -38,7 +38,7 @@ class PersistablePersonClass : DatabasePersistable {
|
||||
}
|
||||
}
|
||||
|
||||
struct PersistableCountry : DatabasePersistable {
|
||||
struct PersistableCountry : Persistable {
|
||||
var isoCode: String
|
||||
var name: String
|
||||
|
||||
@@ -51,7 +51,7 @@ struct PersistableCountry : DatabasePersistable {
|
||||
}
|
||||
}
|
||||
|
||||
struct PersistableCustomizedCountry : DatabasePersistable {
|
||||
struct PersistableCustomizedCountry : Persistable {
|
||||
var isoCode: String
|
||||
var name: String
|
||||
let willInsert: Void -> Void
|
||||
@@ -94,7 +94,7 @@ struct PersistableCustomizedCountry : DatabasePersistable {
|
||||
}
|
||||
}
|
||||
|
||||
class DatabasePersistableTests: GRDBTestCase {
|
||||
class PersistableTests: GRDBTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 136 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user