diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d876ef0d..ee7c22bb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,25 @@ Release Notes ============= +## 0.80.0 + +Released September 7, 2016 + +**Fixed** + +- `Database.tableExists()` learned about temporary tables + +**New** + +- WatchOS support + +- `QueryInterfaceRequest.deleteAll()` deletes database rows: + + ```swift + try Wine.filter(corked == true).deleteAll(db) + ``` + + ## 0.79.4 Released August 17, 2016 diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Assets.xcassets/README__ignoredByTemplate__ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Assets.xcassets/README__ignoredByTemplate__ new file mode 100644 index 000000000..b601d3834 --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Assets.xcassets/README__ignoredByTemplate__ @@ -0,0 +1 @@ +Did you know that git does not support storing empty directories? diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Database.swift b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Database.swift new file mode 100644 index 000000000..afc09c61f --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Database.swift @@ -0,0 +1,39 @@ +import GRDB +import WatchKit + +// The shared database queue +var dbQueue: DatabaseQueue! + +func setupDatabase() { + + // Connect to the database + // See https://github.com/groue/GRDB.swift/#database-connections + + 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 + // See https://github.com/groue/GRDB.swift/#migrations + + var migrator = DatabaseMigrator() + + migrator.registerMigration("createPersons") { db in + // Compare person names in a localized case insensitive fashion + // See https://github.com/groue/GRDB.swift/#unicode + try db.create(table: "persons") { t in + t.column("id", .Integer).primaryKey() + t.column("name", .Text).notNull().collate(.localizedCaseInsensitiveCompare) + } + } + + migrator.registerMigration("addPersons") { db in + // Populate the persons table with random data + for _ in 0..<8 { + try Person(name: Person.randomName()).insert(db) + } + } + + try! migrator.migrate(dbQueue) +} diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/ExtensionDelegate.swift b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/ExtensionDelegate.swift new file mode 100644 index 000000000..1578e08ee --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/ExtensionDelegate.swift @@ -0,0 +1,8 @@ +import WatchKit + +class ExtensionDelegate: NSObject, WKExtensionDelegate { + + func applicationDidFinishLaunching() { + setupDatabase() + } +} diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Info.plist b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Info.plist new file mode 100644 index 000000000..cd1bdb2b0 --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + GRDBDemoWatchOS Extension + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSExtension + + NSExtensionAttributes + + WKAppBundleIdentifier + GRDB.GRDBDemoiOS.watchkitapp + + NSExtensionPointIdentifier + com.apple.watchkit + + WKExtensionDelegateClassName + $(PRODUCT_MODULE_NAME).ExtensionDelegate + + diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/InterfaceController.swift b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/InterfaceController.swift new file mode 100644 index 000000000..dfabde4b7 --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/InterfaceController.swift @@ -0,0 +1,25 @@ +import WatchKit +import GRDB + +class InterfaceController: WKInterfaceController { + + @IBOutlet var table: WKInterfaceTable! + + override func awakeWithContext(context: AnyObject?) { + super.awakeWithContext(context) + + let persons = dbQueue.inDatabase { db in + Person.order(SQLColumn("name")).fetchAll(db) + } + + table.setNumberOfRows(persons.count, withRowType: "Person") + for (i, person) in persons.enumerate() { + let row = table.rowControllerAtIndex(i) as! PersonRowController + row.nameLabel.setText(person.name) + } + } +} + +class PersonRowController: NSObject { + @IBOutlet var nameLabel: WKInterfaceLabel! +} diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Person.swift b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Person.swift new file mode 100644 index 000000000..32c97f849 --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS Extension/Person.swift @@ -0,0 +1,42 @@ +import GRDB + +class Person: Record { + var id: Int64? + var name: String + + init(name: String) { + self.name = name + super.init() + } + + // MARK: Record overrides + + override class func databaseTableName() -> String { + return "persons" + } + + required init(_ row: Row) { + id = row.value(named: "id") + name = row.value(named: "name") + super.init(row) + } + + override var persistentDictionary: [String : DatabaseValueConvertible?] { + return [ + "id": id, + "name": name] + } + + override func didInsertWithRowID(rowID: Int64, forColumn column: String?) { + id = rowID + } + + // MARK: Random + + private static let names = ["Arthur", "Anita", "Barbara", "Bernard", "Craig", "Chiara", "David", "Dean", "Éric", "Elena", "Fatima", "Frederik", "Gilbert", "Georgette", "Henriette", "Hassan", "Ignacio", "Irene", "Julie", "Jack", "Karl", "Kristel", "Louis", "Liz", "Masashi", "Mary", "Noam", "Nicole", "Ophelie", "Oleg", "Pascal", "Patricia", "Quentin", "Quinn", "Raoul", "Rachel", "Stephan", "Susie", "Tristan", "Tatiana", "Ursule", "Urbain", "Victor", "Violette", "Wilfried", "Wilhelmina", "Yvon", "Yann", "Zazie", "Zoé"] + + class func randomName() -> String { + return names[Int(arc4random_uniform(UInt32(names.count)))] + } + +} diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..dd221ba54 --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,55 @@ +{ + "images" : [ + { + "size" : "24x24", + "idiom" : "watch", + "scale" : "2x", + "role" : "notificationCenter", + "subtype" : "38mm" + }, + { + "size" : "27.5x27.5", + "idiom" : "watch", + "scale" : "2x", + "role" : "notificationCenter", + "subtype" : "42mm" + }, + { + "size" : "29x29", + "idiom" : "watch", + "role" : "companionSettings", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "watch", + "role" : "companionSettings", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "38mm" + }, + { + "size" : "86x86", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "38mm" + }, + { + "size" : "98x98", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "42mm" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Base.lproj/Interface.storyboard b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Base.lproj/Interface.storyboard new file mode 100644 index 000000000..f2d9c7099 --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Base.lproj/Interface.storyboard @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+
+
+
diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Info.plist b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Info.plist new file mode 100644 index 000000000..c16031546 --- /dev/null +++ b/DemoApps/GRDBDemoiOS/GRDBDemoWatchOS/Info.plist @@ -0,0 +1,35 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + GRDBDemoiOS + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + + WKCompanionAppBundleIdentifier + GRDB.GRDBDemoiOS + WKWatchKitApp + + + diff --git a/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj b/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj index 5054d002e..6942b67c4 100644 --- a/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj +++ b/DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj/project.pbxproj @@ -7,6 +7,15 @@ objects = { /* Begin PBXBuildFile section */ + 5624A6AA1D80B13300AD3DCE /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5624A6A81D80B13300AD3DCE /* Interface.storyboard */; }; + 5624A6AC1D80B13300AD3DCE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5624A6AB1D80B13300AD3DCE /* Assets.xcassets */; }; + 5624A6B31D80B13300AD3DCE /* GRDBDemoWatchOS Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 5624A6B21D80B13300AD3DCE /* GRDBDemoWatchOS Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 5624A6B81D80B13300AD3DCE /* InterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5624A6B71D80B13300AD3DCE /* InterfaceController.swift */; }; + 5624A6BA1D80B13300AD3DCE /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5624A6B91D80B13300AD3DCE /* ExtensionDelegate.swift */; }; + 5624A6BC1D80B13300AD3DCE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5624A6BB1D80B13300AD3DCE /* Assets.xcassets */; }; + 5624A6C11D80B13400AD3DCE /* GRDBDemoWatchOS.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 5624A6A61D80B13300AD3DCE /* GRDBDemoWatchOS.app */; }; + 5624A6F11D80B1FB00AD3DCE /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5624A6F01D80B1FB00AD3DCE /* Database.swift */; }; + 5624A6F31D80B23800AD3DCE /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5624A6F21D80B23800AD3DCE /* Person.swift */; }; 568C7A9A1CA6C63100796484 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568C7A991CA6C63100796484 /* AppDelegate.swift */; }; 568C7A9C1CA6C63100796484 /* PersonsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568C7A9B1CA6C63100796484 /* PersonsViewController.swift */; }; 568C7A9F1CA6C63100796484 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 568C7A9D1CA6C63100796484 /* Main.storyboard */; }; @@ -22,76 +31,97 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 5657AAFA1D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6B41D80B13300AD3DCE /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 568C7A8E1CA6C63100796484 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5624A6B11D80B13300AD3DCE; + remoteInfo = "GRDBDemoWatchOS Extension"; + }; + 5624A6BE1D80B13300AD3DCE /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 568C7A8E1CA6C63100796484 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5624A6A51D80B13300AD3DCE; + remoteInfo = GRDBDemoWatchOS; + }; + 5624A6D61D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = 560FC54D1CB003810014AA8E; remoteInfo = GRDBCipherOSX; }; - 5657AAFC1D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6D81D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = 560FC5B01CB00B880014AA8E; remoteInfo = GRDBCipherOSXTests; }; - 5657AAFE1D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6DA1D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = 5671566C1CB16729007DC145; remoteInfo = GRDBCipherOSXEncryptedTests; }; - 5657AB001D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6DC1D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = F3BA805A1CFB2BB2003DC1BA; remoteInfo = GRDBCustomSQLiteOSX; }; - 5657AB021D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6DE1D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = F3BA809B1CFB2F6F003DC1BA; remoteInfo = GRDBCustomSQLiteOSXTests; }; - 5657AB041D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6E01D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = 56AFCA231CB1A8BB00F48B96; remoteInfo = GRDBCipheriOS; }; - 5657AB061D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6E21D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = 56AFCA7F1CB1AA9900F48B96; remoteInfo = GRDBCipheriOSTests; }; - 5657AB081D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6E41D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = 56AFCAD71CB1ABC800F48B96; remoteInfo = GRDBCipheriOSEncryptedTests; }; - 5657AB0A1D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6E61D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = F3BA7FFE1CFB25E4003DC1BA; remoteInfo = GRDBCustomSQLiteiOS; }; - 5657AB0C1D107C20006283EF /* PBXContainerItemProxy */ = { + 5624A6E81D80B13400AD3DCE /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; proxyType = 2; remoteGlobalIDString = F3BA80411CFB2AD7003DC1BA; remoteInfo = GRDBCustomSQLiteiOSTests; }; + 5624A6EA1D80B13400AD3DCE /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 565490A01D5A4798005622CB; + remoteInfo = GRDBWatchOS; + }; 568C7ACE1CA6C6BF00796484 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 568C7AC51CA6C6BF00796484 /* GRDB.xcodeproj */; @@ -144,6 +174,28 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + 5624A6C01D80B13300AD3DCE /* Embed Watch Content */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "$(CONTENTS_FOLDER_PATH)/Watch"; + dstSubfolderSpec = 16; + files = ( + 5624A6C11D80B13400AD3DCE /* GRDBDemoWatchOS.app in Embed Watch Content */, + ); + name = "Embed Watch Content"; + runOnlyForDeploymentPostprocessing = 0; + }; + 5624A6ED1D80B13400AD3DCE /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 5624A6B31D80B13300AD3DCE /* GRDBDemoWatchOS Extension.appex in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; 568C7ADE1CA6C6D100796484 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -158,6 +210,17 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 5624A6A61D80B13300AD3DCE /* GRDBDemoWatchOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GRDBDemoWatchOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 5624A6A91D80B13300AD3DCE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Interface.storyboard; sourceTree = ""; }; + 5624A6AB1D80B13300AD3DCE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 5624A6AD1D80B13300AD3DCE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 5624A6B21D80B13300AD3DCE /* GRDBDemoWatchOS Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "GRDBDemoWatchOS Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + 5624A6B71D80B13300AD3DCE /* InterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InterfaceController.swift; sourceTree = ""; }; + 5624A6B91D80B13300AD3DCE /* ExtensionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionDelegate.swift; sourceTree = ""; }; + 5624A6BB1D80B13300AD3DCE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 5624A6BD1D80B13300AD3DCE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 5624A6F01D80B1FB00AD3DCE /* Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Database.swift; sourceTree = ""; }; + 5624A6F21D80B23800AD3DCE /* Person.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Person.swift; sourceTree = ""; }; 568C7A961CA6C63100796484 /* GRDBDemoiOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GRDBDemoiOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; 568C7A991CA6C63100796484 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 568C7A9B1CA6C63100796484 /* PersonsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonsViewController.swift; sourceTree = ""; }; @@ -174,6 +237,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 5624A6AF1D80B13300AD3DCE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 568C7A931CA6C63100796484 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -185,10 +255,35 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 5624A6A71D80B13300AD3DCE /* GRDBDemoWatchOS */ = { + isa = PBXGroup; + children = ( + 5624A6A81D80B13300AD3DCE /* Interface.storyboard */, + 5624A6AB1D80B13300AD3DCE /* Assets.xcassets */, + 5624A6AD1D80B13300AD3DCE /* Info.plist */, + ); + path = GRDBDemoWatchOS; + sourceTree = ""; + }; + 5624A6B61D80B13300AD3DCE /* GRDBDemoWatchOS Extension */ = { + isa = PBXGroup; + children = ( + 5624A6F01D80B1FB00AD3DCE /* Database.swift */, + 5624A6B71D80B13300AD3DCE /* InterfaceController.swift */, + 5624A6B91D80B13300AD3DCE /* ExtensionDelegate.swift */, + 5624A6F21D80B23800AD3DCE /* Person.swift */, + 5624A6BB1D80B13300AD3DCE /* Assets.xcassets */, + 5624A6BD1D80B13300AD3DCE /* Info.plist */, + ); + path = "GRDBDemoWatchOS Extension"; + sourceTree = ""; + }; 568C7A8D1CA6C63100796484 = { isa = PBXGroup; children = ( 568C7A981CA6C63100796484 /* GRDBDemoiOS */, + 5624A6A71D80B13300AD3DCE /* GRDBDemoWatchOS */, + 5624A6B61D80B13300AD3DCE /* GRDBDemoWatchOS Extension */, 568C7A971CA6C63100796484 /* Products */, ); sourceTree = ""; @@ -197,6 +292,8 @@ isa = PBXGroup; children = ( 568C7A961CA6C63100796484 /* GRDBDemoiOS.app */, + 5624A6A61D80B13300AD3DCE /* GRDBDemoWatchOS.app */, + 5624A6B21D80B13300AD3DCE /* GRDBDemoWatchOS Extension.appex */, ); name = Products; sourceTree = ""; @@ -224,18 +321,19 @@ 568C7AD31CA6C6BF00796484 /* GRDBTests.xctest */, 568C7AD51CA6C6BF00796484 /* GRDBOSXPerformanceTests.xctest */, 568C7AD11CA6C6BF00796484 /* GRDBOSXCrashTests.xctest */, - 5657AAFB1D107C20006283EF /* GRDBCipher.framework */, - 5657AAFD1D107C20006283EF /* GRDBTests.xctest */, - 5657AAFF1D107C20006283EF /* GRDBCipherOSXEncryptedTests.xctest */, - 5657AB011D107C20006283EF /* GRDBCustomSQLite.framework */, - 5657AB031D107C20006283EF /* GRDBCustomSQLiteOSXTests.xctest */, + 5624A6D71D80B13400AD3DCE /* GRDBCipher.framework */, + 5624A6D91D80B13400AD3DCE /* GRDBTests.xctest */, + 5624A6DB1D80B13400AD3DCE /* GRDBCipherOSXEncryptedTests.xctest */, + 5624A6DD1D80B13400AD3DCE /* GRDBCustomSQLite.framework */, + 5624A6DF1D80B13400AD3DCE /* GRDBCustomSQLiteOSXTests.xctest */, 568C7AD71CA6C6BF00796484 /* GRDB.framework */, 568C7AD91CA6C6BF00796484 /* GRDBTests.xctest */, - 5657AB051D107C20006283EF /* GRDBCipher.framework */, - 5657AB071D107C20006283EF /* GRDBTests.xctest */, - 5657AB091D107C20006283EF /* GRDBTests.xctest */, - 5657AB0B1D107C20006283EF /* GRDBCustomSQLite.framework */, - 5657AB0D1D107C20006283EF /* GRDBCustomSQLiteiOSTests.xctest */, + 5624A6E11D80B13400AD3DCE /* GRDBCipher.framework */, + 5624A6E31D80B13400AD3DCE /* GRDBTests.xctest */, + 5624A6E51D80B13400AD3DCE /* GRDBTests.xctest */, + 5624A6E71D80B13400AD3DCE /* GRDBCustomSQLite.framework */, + 5624A6E91D80B13400AD3DCE /* GRDBCustomSQLiteiOSTests.xctest */, + 5624A6EB1D80B13400AD3DCE /* GRDB.framework */, ); name = Products; sourceTree = ""; @@ -254,6 +352,40 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 5624A6A51D80B13300AD3DCE /* GRDBDemoWatchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5624A6EE1D80B13400AD3DCE /* Build configuration list for PBXNativeTarget "GRDBDemoWatchOS" */; + buildPhases = ( + 5624A6A41D80B13300AD3DCE /* Resources */, + 5624A6ED1D80B13400AD3DCE /* Embed App Extensions */, + ); + buildRules = ( + ); + dependencies = ( + 5624A6B51D80B13300AD3DCE /* PBXTargetDependency */, + ); + name = GRDBDemoWatchOS; + productName = GRDBDemoWatchOS; + productReference = 5624A6A61D80B13300AD3DCE /* GRDBDemoWatchOS.app */; + productType = "com.apple.product-type.application.watchapp2"; + }; + 5624A6B11D80B13300AD3DCE /* GRDBDemoWatchOS Extension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5624A6EC1D80B13400AD3DCE /* Build configuration list for PBXNativeTarget "GRDBDemoWatchOS Extension" */; + buildPhases = ( + 5624A6AE1D80B13300AD3DCE /* Sources */, + 5624A6AF1D80B13300AD3DCE /* Frameworks */, + 5624A6B01D80B13300AD3DCE /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "GRDBDemoWatchOS Extension"; + productName = "GRDBDemoWatchOS Extension"; + productReference = 5624A6B21D80B13300AD3DCE /* GRDBDemoWatchOS Extension.appex */; + productType = "com.apple.product-type.watchkit2-extension"; + }; 568C7A951CA6C63100796484 /* GRDBDemoiOS */ = { isa = PBXNativeTarget; buildConfigurationList = 568C7AA81CA6C63100796484 /* Build configuration list for PBXNativeTarget "GRDBDemoiOS" */; @@ -262,11 +394,13 @@ 568C7A931CA6C63100796484 /* Frameworks */, 568C7A941CA6C63100796484 /* Resources */, 568C7ADE1CA6C6D100796484 /* Embed Frameworks */, + 5624A6C01D80B13300AD3DCE /* Embed Watch Content */, ); buildRules = ( ); dependencies = ( 568C7ADD1CA6C6D100796484 /* PBXTargetDependency */, + 5624A6BF1D80B13300AD3DCE /* PBXTargetDependency */, ); name = GRDBDemoiOS; productName = GRDBDemoiOS; @@ -283,6 +417,13 @@ LastUpgradeCheck = 0800; ORGANIZATIONNAME = Pierlis; TargetAttributes = { + 5624A6A51D80B13300AD3DCE = { + CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = AMD8W895CT; + }; + 5624A6B11D80B13300AD3DCE = { + CreatedOnToolsVersion = 7.3.1; + }; 568C7A951CA6C63100796484 = { CreatedOnToolsVersion = 7.3; DevelopmentTeam = AMD8W895CT; @@ -310,79 +451,88 @@ projectRoot = ""; targets = ( 568C7A951CA6C63100796484 /* GRDBDemoiOS */, + 5624A6A51D80B13300AD3DCE /* GRDBDemoWatchOS */, + 5624A6B11D80B13300AD3DCE /* GRDBDemoWatchOS Extension */, ); }; /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 5657AAFB1D107C20006283EF /* GRDBCipher.framework */ = { + 5624A6D71D80B13400AD3DCE /* GRDBCipher.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; path = GRDBCipher.framework; - remoteRef = 5657AAFA1D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6D61D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AAFD1D107C20006283EF /* GRDBTests.xctest */ = { + 5624A6D91D80B13400AD3DCE /* GRDBTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = GRDBTests.xctest; - remoteRef = 5657AAFC1D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6D81D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AAFF1D107C20006283EF /* GRDBCipherOSXEncryptedTests.xctest */ = { + 5624A6DB1D80B13400AD3DCE /* GRDBCipherOSXEncryptedTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = GRDBCipherOSXEncryptedTests.xctest; - remoteRef = 5657AAFE1D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6DA1D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AB011D107C20006283EF /* GRDBCustomSQLite.framework */ = { + 5624A6DD1D80B13400AD3DCE /* GRDBCustomSQLite.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; path = GRDBCustomSQLite.framework; - remoteRef = 5657AB001D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6DC1D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AB031D107C20006283EF /* GRDBCustomSQLiteOSXTests.xctest */ = { + 5624A6DF1D80B13400AD3DCE /* GRDBCustomSQLiteOSXTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = GRDBCustomSQLiteOSXTests.xctest; - remoteRef = 5657AB021D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6DE1D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AB051D107C20006283EF /* GRDBCipher.framework */ = { + 5624A6E11D80B13400AD3DCE /* GRDBCipher.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; path = GRDBCipher.framework; - remoteRef = 5657AB041D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6E01D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AB071D107C20006283EF /* GRDBTests.xctest */ = { + 5624A6E31D80B13400AD3DCE /* GRDBTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = GRDBTests.xctest; - remoteRef = 5657AB061D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6E21D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AB091D107C20006283EF /* GRDBTests.xctest */ = { + 5624A6E51D80B13400AD3DCE /* GRDBTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = GRDBTests.xctest; - remoteRef = 5657AB081D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6E41D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AB0B1D107C20006283EF /* GRDBCustomSQLite.framework */ = { + 5624A6E71D80B13400AD3DCE /* GRDBCustomSQLite.framework */ = { isa = PBXReferenceProxy; fileType = wrapper.framework; path = GRDBCustomSQLite.framework; - remoteRef = 5657AB0A1D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6E61D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5657AB0D1D107C20006283EF /* GRDBCustomSQLiteiOSTests.xctest */ = { + 5624A6E91D80B13400AD3DCE /* GRDBCustomSQLiteiOSTests.xctest */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; path = GRDBCustomSQLiteiOSTests.xctest; - remoteRef = 5657AB0C1D107C20006283EF /* PBXContainerItemProxy */; + remoteRef = 5624A6E81D80B13400AD3DCE /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 5624A6EB1D80B13400AD3DCE /* GRDB.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = GRDB.framework; + remoteRef = 5624A6EA1D80B13400AD3DCE /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 568C7ACF1CA6C6BF00796484 /* GRDB.framework */ = { @@ -430,6 +580,23 @@ /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ + 5624A6A41D80B13300AD3DCE /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5624A6AC1D80B13300AD3DCE /* Assets.xcassets in Resources */, + 5624A6AA1D80B13300AD3DCE /* Interface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5624A6B01D80B13300AD3DCE /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5624A6BC1D80B13300AD3DCE /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 568C7A941CA6C63100796484 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -443,6 +610,17 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 5624A6AE1D80B13300AD3DCE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5624A6F11D80B1FB00AD3DCE /* Database.swift in Sources */, + 5624A6BA1D80B13300AD3DCE /* ExtensionDelegate.swift in Sources */, + 5624A6F31D80B23800AD3DCE /* Person.swift in Sources */, + 5624A6B81D80B13300AD3DCE /* InterfaceController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 568C7A921CA6C63100796484 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -460,6 +638,16 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 5624A6B51D80B13300AD3DCE /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 5624A6B11D80B13300AD3DCE /* GRDBDemoWatchOS Extension */; + targetProxy = 5624A6B41D80B13300AD3DCE /* PBXContainerItemProxy */; + }; + 5624A6BF1D80B13300AD3DCE /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 5624A6A51D80B13300AD3DCE /* GRDBDemoWatchOS */; + targetProxy = 5624A6BE1D80B13300AD3DCE /* PBXContainerItemProxy */; + }; 568C7ADD1CA6C6D100796484 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = GRDBiOS; @@ -468,6 +656,14 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ + 5624A6A81D80B13300AD3DCE /* Interface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 5624A6A91D80B13300AD3DCE /* Base */, + ); + name = Interface.storyboard; + sourceTree = ""; + }; 568C7A9D1CA6C63100796484 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -487,6 +683,70 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 5624A6C21D80B13400AD3DCE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + IBSC_MODULE = GRDBDemoWatchOS_Extension; + INFOPLIST_FILE = GRDBDemoWatchOS/Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = GRDB.GRDBDemoiOS.watchkitapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.2; + }; + name = Debug; + }; + 5624A6C31D80B13400AD3DCE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + IBSC_MODULE = GRDBDemoWatchOS_Extension; + INFOPLIST_FILE = GRDBDemoWatchOS/Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = GRDB.GRDBDemoiOS.watchkitapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.2; + }; + name = Release; + }; + 5624A6C41D80B13400AD3DCE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = "GRDBDemoWatchOS Extension/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = GRDB.GRDBDemoiOS.watchkitapp.watchkitextension; + PRODUCT_NAME = "${TARGET_NAME}"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.2; + }; + name = Debug; + }; + 5624A6C51D80B13400AD3DCE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = "GRDBDemoWatchOS Extension/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = GRDB.GRDBDemoiOS.watchkitapp.watchkitextension; + PRODUCT_NAME = "${TARGET_NAME}"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.2; + }; + name = Release; + }; 568C7AA61CA6C63100796484 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -570,6 +830,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -612,6 +873,24 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 5624A6EC1D80B13400AD3DCE /* Build configuration list for PBXNativeTarget "GRDBDemoWatchOS Extension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5624A6C41D80B13400AD3DCE /* Debug */, + 5624A6C51D80B13400AD3DCE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5624A6EE1D80B13400AD3DCE /* Build configuration list for PBXNativeTarget "GRDBDemoWatchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5624A6C21D80B13400AD3DCE /* Debug */, + 5624A6C31D80B13400AD3DCE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 568C7A911CA6C63100796484 /* Build configuration list for PBXProject "GRDBDemoiOS" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index c53399ff1..f288855f9 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GRDB.swift' - s.version = '0.79.4' + s.version = '0.80.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'A Swift application toolkit for SQLite databases.' s.homepage = 'https://github.com/groue/GRDB.swift' diff --git a/GRDB.xcodeproj/project.pbxproj b/GRDB.xcodeproj/project.pbxproj index 9356d9c97..1a7ee6c55 100755 --- a/GRDB.xcodeproj/project.pbxproj +++ b/GRDB.xcodeproj/project.pbxproj @@ -225,6 +225,56 @@ 564A50C81BFF4B7F00B3A3A2 /* CollationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */; }; 565049061CE32543000A97D8 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; }; 565049071CE32543000A97D8 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; }; + 565490B41D5A4820005622CB /* GRDB.h in Headers */ = {isa = PBXBuildFile; fileRef = DC3773F819C8CBB3004FCF85 /* GRDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 565490B51D5A4827005622CB /* GRDB-Bridging.h in Headers */ = {isa = PBXBuildFile; fileRef = DC2393C61ABE35F8003FF113 /* GRDB-Bridging.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 565490B61D5AE236005622CB /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238701B9C75030082EB20 /* Configuration.swift */; }; + 565490B71D5AE236005622CB /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238711B9C75030082EB20 /* Database.swift */; }; + 565490B81D5AE236005622CB /* DatabaseError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238731B9C75030082EB20 /* DatabaseError.swift */; }; + 565490B91D5AE236005622CB /* DatabasePool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37A31C8F625000949E71 /* DatabasePool.swift */; }; + 565490BA1D5AE236005622CB /* DatabaseQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238741B9C75030082EB20 /* DatabaseQueue.swift */; }; + 565490BB1D5AE236005622CB /* DatabaseReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563363BF1C942C04000BE133 /* DatabaseReader.swift */; }; + 565490BC1D5AE236005622CB /* DatabaseSchemaCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5695311E1C907A8C00CF1A2B /* DatabaseSchemaCache.swift */; }; + 565490BD1D5AE236005622CB /* DatabaseStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563363D71C95787F000BE133 /* DatabaseStore.swift */; }; + 565490BE1D5AE236005622CB /* DatabaseValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238751B9C75030082EB20 /* DatabaseValue.swift */; }; + 565490BF1D5AE236005622CB /* DatabaseValueConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D923E1C672C3E00F4F92B /* DatabaseValueConvertible.swift */; }; + 565490C01D5AE236005622CB /* DatabaseWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563363C31C942C37000BE133 /* DatabaseWriter.swift */; }; + 565490C11D5AE236005622CB /* FetchRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* FetchRequest.swift */; }; + 565490C21D5AE236005622CB /* Row.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238761B9C75030082EB20 /* Row.swift */; }; + 565490C31D5AE236005622CB /* RowAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567404871CEF84C8003ED5CC /* RowAdapter.swift */; }; + 565490C41D5AE236005622CB /* SchedulingWatchdog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56BB6EA81D3009B100A1CA52 /* SchedulingWatchdog.swift */; }; + 565490C51D5AE236005622CB /* SerializedDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37A61C8FF6E500949E71 /* SerializedDatabase.swift */; }; + 565490C61D5AE236005622CB /* Statement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238781B9C75030082EB20 /* Statement.swift */; }; + 565490C71D5AE236005622CB /* StatementColumnConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D923F1C672C3E00F4F92B /* StatementColumnConvertible.swift */; }; + 565490C81D5AE252005622CB /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1491C672E4000235C62 /* CGFloat.swift */; }; + 565490C91D5AE252005622CB /* DatabaseCoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14B1C672E4000235C62 /* DatabaseCoder.swift */; }; + 565490CA1D5AE252005622CB /* DatabaseDateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14C1C672E4000235C62 /* DatabaseDateComponents.swift */; }; + 565490CB1D5AE252005622CB /* (null) in Sources */ = {isa = PBXBuildFile; }; + 565490CC1D5AE252005622CB /* (null) in Sources */ = {isa = PBXBuildFile; }; + 565490CD1D5AE252005622CB /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* Date.swift */; }; + 565490CE1D5AE252005622CB /* NSNull.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1501C672E4000235C62 /* NSNull.swift */; }; + 565490CF1D5AE252005622CB /* NSNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1511C672E4000235C62 /* NSNumber.swift */; }; + 565490D01D5AE252005622CB /* NSString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1521C672E4000235C62 /* NSString.swift */; }; + 565490D11D5AE252005622CB /* NSURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1531C672E4000235C62 /* NSURL.swift */; }; + 565490D21D5AE252005622CB /* NSUUID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563ABAF61D18824F003B37F3 /* NSUUID.swift */; }; + 565490D31D5AE252005622CB /* (null) in Sources */ = {isa = PBXBuildFile; }; + 565490D41D5AE252005622CB /* (null) in Sources */ = {isa = PBXBuildFile; }; + 565490D51D5AE252005622CB /* RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1571C672E4000235C62 /* RawRepresentable.swift */; }; + 565490D61D5AE252005622CB /* StandardLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1581C672E4000235C62 /* StandardLibrary.swift */; }; + 565490D71D5AE252005622CB /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563445041C4A7FD7003D3DC6 /* Utils.swift */; }; + 565490D81D5AE252005622CB /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238921B9C750B0082EB20 /* DatabaseMigrator.swift */; }; + 565490D91D5AE252005622CB /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; }; + 565490DA1D5AE252005622CB /* QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */; }; + 565490DB1D5AE252005622CB /* SQLCollation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollation.swift */; }; + 565490DC1D5AE252005622CB /* SQLFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18A1C6B1A8700235C62 /* SQLFunction.swift */; }; + 565490DD1D5AE252005622CB /* SQLOperator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18B1C6B1A8700235C62 /* SQLOperator.swift */; }; + 565490DE1D5AE252005622CB /* SQLSelectQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18C1C6B1A8700235C62 /* SQLSelectQuery.swift */; }; + 565490DF1D5AE252005622CB /* SQLTableBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566AD8B11D5318F4002EC1A8 /* SQLTableBuilder.swift */; }; + 565490E01D5AE252005622CB /* FetchedRecordsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A7787C1C6A4DD600F507F6 /* FetchedRecordsController.swift */; }; + 565490E11D5AE252005622CB /* Persistable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92441C672C4B00F4F92B /* Persistable.swift */; }; + 565490E21D5AE252005622CB /* Record.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238A11B9C753B0082EB20 /* Record.swift */; }; + 565490E31D5AE252005622CB /* RowConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92451C672C4B00F4F92B /* RowConvertible.swift */; }; + 565490E41D5AE252005622CB /* TableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92461C672C4B00F4F92B /* TableMapping.swift */; }; + 565490E61D5AE282005622CB /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 565490E51D5AE282005622CB /* libsqlite3.tbd */; }; 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 */; }; @@ -1407,6 +1457,8 @@ 563ABAF61D18824F003B37F3 /* NSUUID.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSUUID.swift; sourceTree = ""; }; 564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollationTests.swift; sourceTree = ""; }; 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedRecordsControllerTests.swift; sourceTree = ""; }; + 565490A01D5A4798005622CB /* GRDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDB.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 565490E51D5AE282005622CB /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.2.sdk/usr/lib/libsqlite3.tbd; sourceTree = DEVELOPER_DIR; }; 56553C181C3E906C00522B5C /* GRDBOSXCrashTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXCrashTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5657AAA91D106E39006283EF /* NSDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDate.swift; sourceTree = ""; }; 5657AAB81D107001006283EF /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = ""; }; @@ -1607,6 +1659,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5654909C1D5A4798005622CB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 565490E61D5AE282005622CB /* libsqlite3.tbd in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 56553C111C3E906C00522B5C /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -2291,6 +2351,7 @@ DC3773E919C8CBB3004FCF85 = { isa = PBXGroup; children = ( + 565490E51D5AE282005622CB /* libsqlite3.tbd */, 56DBEC341C19A0020093A2EE /* CHANGELOG.md */, DC37744719C8F50B004FCF85 /* README.md */, 56E1524B1B43FD5B00EE27AA /* TODO.md */, @@ -2324,6 +2385,7 @@ F3BA80411CFB2AD7003DC1BA /* GRDBCustomSQLiteiOSTests.xctest */, F3BA805A1CFB2BB2003DC1BA /* GRDBCustomSQLite.framework */, F3BA809B1CFB2F6F003DC1BA /* GRDBCustomSQLiteOSXTests.xctest */, + 565490A01D5A4798005622CB /* GRDB.framework */, ); name = Products; sourceTree = ""; @@ -2409,6 +2471,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5654909D1D5A4798005622CB /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 565490B41D5A4820005622CB /* GRDB.h in Headers */, + 565490B51D5A4827005622CB /* GRDB-Bridging.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 56AFCA1C1CB1A8BB00F48B96 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -2519,6 +2590,24 @@ productReference = 560FC5B01CB00B880014AA8E /* GRDBTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 5654909F1D5A4798005622CB /* GRDBWatchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 565490B31D5A4798005622CB /* Build configuration list for PBXNativeTarget "GRDBWatchOS" */; + buildPhases = ( + 5654909B1D5A4798005622CB /* Sources */, + 5654909C1D5A4798005622CB /* Frameworks */, + 5654909D1D5A4798005622CB /* Headers */, + 5654909E1D5A4798005622CB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = GRDBWatchOS; + productName = GRDBWatchOS; + productReference = 565490A01D5A4798005622CB /* GRDB.framework */; + productType = "com.apple.product-type.framework"; + }; 56553BDA1C3E906C00522B5C /* GRDBOSXCrashTests */ = { isa = PBXNativeTarget; buildConfigurationList = 56553C151C3E906C00522B5C /* Build configuration list for PBXNativeTarget "GRDBOSXCrashTests" */; @@ -2768,6 +2857,9 @@ LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Gwendal Roué"; TargetAttributes = { + 5654909F1D5A4798005622CB = { + CreatedOnToolsVersion = 7.3.1; + }; 56E5D7C91B4D3FED00430942 = { CreatedOnToolsVersion = 7.0; LastSwiftMigration = 0800; @@ -2845,6 +2937,7 @@ 56AFCA841CB1ABC800F48B96 /* GRDBCipheriOSEncryptedTests */, F3BA7FFD1CFB25E4003DC1BA /* GRDBCustomSQLiteiOS */, F3BA80401CFB2AD7003DC1BA /* GRDBCustomSQLiteiOSTests */, + 5654909F1D5A4798005622CB /* GRDBWatchOS */, ); }; /* End PBXProject section */ @@ -2969,6 +3062,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5654909E1D5A4798005622CB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 56553C141C3E906C00522B5C /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -3285,6 +3385,60 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5654909B1D5A4798005622CB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 565490CE1D5AE252005622CB /* NSNull.swift in Sources */, + 565490E41D5AE252005622CB /* TableMapping.swift in Sources */, + 565490CF1D5AE252005622CB /* NSNumber.swift in Sources */, + 565490E21D5AE252005622CB /* Record.swift in Sources */, + 565490C11D5AE236005622CB /* FetchRequest.swift in Sources */, + 565490BD1D5AE236005622CB /* DatabaseStore.swift in Sources */, + 565490B91D5AE236005622CB /* DatabasePool.swift in Sources */, + 565490D81D5AE252005622CB /* DatabaseMigrator.swift in Sources */, + 565490C21D5AE236005622CB /* Row.swift in Sources */, + 565490C71D5AE236005622CB /* StatementColumnConvertible.swift in Sources */, + 565490D91D5AE252005622CB /* Migration.swift in Sources */, + 565490D51D5AE252005622CB /* RawRepresentable.swift in Sources */, + 565490C51D5AE236005622CB /* SerializedDatabase.swift in Sources */, + 565490D71D5AE252005622CB /* Utils.swift in Sources */, + 565490BF1D5AE236005622CB /* DatabaseValueConvertible.swift in Sources */, + 565490BB1D5AE236005622CB /* DatabaseReader.swift in Sources */, + 565490C91D5AE252005622CB /* DatabaseCoder.swift in Sources */, + 565490C31D5AE236005622CB /* RowAdapter.swift in Sources */, + 565490DD1D5AE252005622CB /* SQLOperator.swift in Sources */, + 565490DA1D5AE252005622CB /* QueryInterfaceRequest.swift in Sources */, + 565490CA1D5AE252005622CB /* DatabaseDateComponents.swift in Sources */, + 565490D01D5AE252005622CB /* NSString.swift in Sources */, + 565490D11D5AE252005622CB /* NSURL.swift in Sources */, + 565490E31D5AE252005622CB /* RowConvertible.swift in Sources */, + 565490DF1D5AE252005622CB /* SQLTableBuilder.swift in Sources */, + 565490B71D5AE236005622CB /* Database.swift in Sources */, + 565490C01D5AE236005622CB /* DatabaseWriter.swift in Sources */, + 565490C41D5AE236005622CB /* SchedulingWatchdog.swift in Sources */, + 565490CC1D5AE252005622CB /* (null) in Sources */, + 565490DB1D5AE252005622CB /* SQLCollation.swift in Sources */, + 565490C61D5AE236005622CB /* Statement.swift in Sources */, + 565490D41D5AE252005622CB /* (null) in Sources */, + 565490B61D5AE236005622CB /* Configuration.swift in Sources */, + 565490E11D5AE252005622CB /* Persistable.swift in Sources */, + 565490E01D5AE252005622CB /* FetchedRecordsController.swift in Sources */, + 565490C81D5AE252005622CB /* CGFloat.swift in Sources */, + 565490D21D5AE252005622CB /* NSUUID.swift in Sources */, + 565490DC1D5AE252005622CB /* SQLFunction.swift in Sources */, + 565490D31D5AE252005622CB /* (null) in Sources */, + 565490DE1D5AE252005622CB /* SQLSelectQuery.swift in Sources */, + 565490CB1D5AE252005622CB /* (null) in Sources */, + 565490D61D5AE252005622CB /* StandardLibrary.swift in Sources */, + 565490B81D5AE236005622CB /* DatabaseError.swift in Sources */, + 565490BC1D5AE236005622CB /* DatabaseSchemaCache.swift in Sources */, + 565490BA1D5AE236005622CB /* DatabaseQueue.swift in Sources */, + 565490CD1D5AE252005622CB /* Date.swift in Sources */, + 565490BE1D5AE236005622CB /* DatabaseValue.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 56553BDD1C3E906C00522B5C /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -4480,6 +4634,49 @@ }; name = Release; }; + 565490A51D5A4798005622CB /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ANALYZER_NONNULL = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_NO_COMMON_BLOCKS = YES; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.2; + }; + name = Debug; + }; + 565490A61D5A4798005622CB /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CLANG_ANALYZER_NONNULL = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_NO_COMMON_BLOCKS = YES; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.2; + }; + name = Release; + }; 56553C161C3E906C00522B5C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -5088,6 +5285,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 565490B31D5A4798005622CB /* Build configuration list for PBXNativeTarget "GRDBWatchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 565490A51D5A4798005622CB /* Debug */, + 565490A61D5A4798005622CB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 56553C151C3E906C00522B5C /* Build configuration list for PBXNativeTarget "GRDBOSXCrashTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBWatchOS.xcscheme b/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBWatchOS.xcscheme new file mode 100644 index 000000000..8a84429ff --- /dev/null +++ b/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBWatchOS.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GRDB/Core/Configuration.swift b/GRDB/Core/Configuration.swift index 01765f597..872ee04a2 100644 --- a/GRDB/Core/Configuration.swift +++ b/GRDB/Core/Configuration.swift @@ -9,6 +9,12 @@ import Foundation #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 65b4da84c..34d33240c 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -9,6 +9,12 @@ import Foundation #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif @@ -791,7 +797,7 @@ extension Database { // SQlite identifiers are case-insensitive, case-preserving (http://www.alberton.info/dbms_identifiers_and_case_sensitivity.html) return Row.fetchOne(self, - "SELECT sql FROM sqlite_master WHERE type = 'table' AND LOWER(name) = ?", + "SELECT * FROM (SELECT sql, type, name FROM sqlite_master UNION SELECT sql, type, name FROM sqlite_temp_master) WHERE type = 'table' AND LOWER(name) = ?", arguments: [tableName.lowercased()]) != nil } diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index e075a68ee..2bbf76245 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -7,6 +7,12 @@ #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 97e1b861e..779aeba08 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -9,6 +9,12 @@ import Foundation #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/DatabaseReader.swift b/GRDB/Core/DatabaseReader.swift index 1c9392ff5..701fd1c7d 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -7,6 +7,12 @@ #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/DatabaseValue.swift b/GRDB/Core/DatabaseValue.swift index 493a9be31..16b043137 100644 --- a/GRDB/Core/DatabaseValue.swift +++ b/GRDB/Core/DatabaseValue.swift @@ -9,6 +9,12 @@ import Foundation #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index 6a758d8f0..91e65ceca 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -9,6 +9,12 @@ import Foundation #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/RowAdapter.swift b/GRDB/Core/RowAdapter.swift index b0b7e24af..27c08b057 100644 --- a/GRDB/Core/RowAdapter.swift +++ b/GRDB/Core/RowAdapter.swift @@ -7,6 +7,12 @@ #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index 6b4fc97c6..ce3e5ba0c 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -9,6 +9,12 @@ import Foundation #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/StatementColumnConvertible.swift b/GRDB/Core/StatementColumnConvertible.swift index 1c1ff5fc2..ebe234127 100644 --- a/GRDB/Core/StatementColumnConvertible.swift +++ b/GRDB/Core/StatementColumnConvertible.swift @@ -7,6 +7,12 @@ #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift b/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift index 7b7e09f50..3e39df903 100644 --- a/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift +++ b/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift @@ -7,6 +7,12 @@ #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Core/Utils.swift b/GRDB/Core/Utils.swift index 0d94a3cf3..540b983fc 100644 --- a/GRDB/Core/Utils.swift +++ b/GRDB/Core/Utils.swift @@ -9,6 +9,12 @@ import Foundation #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/Migrations/Migration.swift b/GRDB/Migrations/Migration.swift index d65450d36..e47e12a1d 100644 --- a/GRDB/Migrations/Migration.swift +++ b/GRDB/Migrations/Migration.swift @@ -7,6 +7,12 @@ #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/GRDB/QueryInterface/QueryInterfaceRequest.swift b/GRDB/QueryInterface/QueryInterfaceRequest.swift index 53aad647b..740dc3a70 100644 --- a/GRDB/QueryInterface/QueryInterfaceRequest.swift +++ b/GRDB/QueryInterface/QueryInterfaceRequest.swift @@ -213,6 +213,22 @@ extension QueryInterfaceRequest { } +extension QueryInterfaceRequest { + + // MARK: Deleting + + /// Deletes matching rows; returns the number of deleted rows. + /// + /// - parameter db: A database connection. + /// - returns: The number of deleted rows + /// - throws: A DatabaseError is thrown whenever an SQLite error occurs. + @discardableResult public func deleteAll(_ db: Database) throws -> Int { + try query.makeDeleteStatement(db).execute() + return db.changesCount + } +} + + extension QueryInterfaceRequest { // MARK: QueryInterfaceRequest as subquery diff --git a/GRDB/QueryInterface/SQLSelectQuery.swift b/GRDB/QueryInterface/SQLSelectQuery.swift index bacc9d00e..c1d2fbfb3 100644 --- a/GRDB/QueryInterface/SQLSelectQuery.swift +++ b/GRDB/QueryInterface/SQLSelectQuery.swift @@ -7,6 +7,12 @@ #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif @@ -177,6 +183,35 @@ public struct _SQLSelectQuery { } } + func makeDeleteStatement(_ db: Database) -> UpdateStatement { + guard groupByExpressions.isEmpty else { + fatalError("Can't delete query with GROUP BY expression") + } + + guard havingExpression == nil else { + fatalError("Can't delete query with GROUP BY expression") + } + + guard limit == nil else { + fatalError("Can't delete query with limit") + } + + var sql = "DELETE" + var arguments: StatementArguments? = StatementArguments() + + if let source = source { + sql += " FROM " + source.sql(&arguments) + } + + if let whereExpression = whereExpression { + sql += " WHERE " + whereExpression.sql(&arguments) + } + + let statement = try! db.makeUpdateStatement(sql) + statement.arguments = arguments! + return statement + } + // SELECT COUNT(*) FROM (self) private var trivialCountQuery: _SQLSelectQuery { return _SQLSelectQuery( diff --git a/GRDB/Record/TableMapping.swift b/GRDB/Record/TableMapping.swift index a7311c15c..20f1f19a0 100644 --- a/GRDB/Record/TableMapping.swift +++ b/GRDB/Record/TableMapping.swift @@ -7,6 +7,12 @@ #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif @@ -117,7 +123,8 @@ extension TableMapping { // MARK: - Deleting by Single-Column Primary Key - /// Delete records identified by their primary keys. + /// Delete records identified by their primary keys; returns the number of + /// deleted rows. /// /// try Person.deleteAll(db, keys: [1, 2, 3]) /// @@ -125,7 +132,7 @@ extension TableMapping { /// - db: A database connection. /// - keys: A sequence of primary keys. /// - returns: The number of deleted rows - public static func deleteAll(_ db: Database, keys: Sequence) throws -> Int where Sequence.Iterator.Element: DatabaseValueConvertible { + @discardableResult public static func deleteAll(_ db: Database, keys: Sequence) throws -> Int where Sequence.Iterator.Element: DatabaseValueConvertible { guard let statement = try! makeDeleteByPrimaryKeyStatement(db, keys: keys) else { return 0 } @@ -133,7 +140,8 @@ extension TableMapping { return db.changesCount } - /// Delete a record, identified by its primary key. + /// Delete a record, identified by its primary key; returns whether a + /// database row was deleted. /// /// try Person.deleteOne(db, key: 123) /// @@ -141,7 +149,7 @@ extension TableMapping { /// - db: A database connection. /// - key: A primary key value. /// - returns: Whether a database row was deleted. - public static func deleteOne(_ db: Database, key: PrimaryKeyType?) throws -> Bool { + @discardableResult public static func deleteOne(_ db: Database, key: PrimaryKeyType?) throws -> Bool { guard let key = key else { return false } @@ -188,9 +196,10 @@ extension RowConvertible where Self: TableMapping { // MARK: - Fetching by Key - /// Returns a sequence of records, given an array of key dictionaries. + /// Returns a sequence of records identified by the provided unique keys + /// (primary key or any key with a unique index on it). /// - /// let persons = Person.fetch(db, keys: [["name": "Arthur"], ["name": "Barbara"]]) // DatabaseSequence + /// let persons = Person.fetch(db, keys: [["email": "a@example.com"], ["email": "b@example.com"]]) // DatabaseSequence /// /// The order of records in the returned sequence is undefined. /// @@ -205,9 +214,10 @@ extension RowConvertible where Self: TableMapping { return fetch(statement) } - /// Returns an array of records, given an array of key dictionaries. + /// Returns an array of records identified by the provided unique keys + /// (primary key or any key with a unique index on it). /// - /// let persons = Person.fetchAll(db, keys: [["name": "Arthur"], ["name": "Barbara"]]) // [Person] + /// let persons = Person.fetchAll(db, keys: [["email": "a@example.com"], ["email": "b@example.com"]]) // [Person] /// /// The order of records in the returned array is undefined. /// @@ -222,7 +232,8 @@ extension RowConvertible where Self: TableMapping { return fetchAll(statement) } - /// Returns a single record given a key dictionary. + /// Returns a single record identified by a unique key (the primary key or + /// any key with a unique index on it). /// /// let person = Person.fetchOne(db, key: ["name": Arthur"]) // Person? /// @@ -276,15 +287,16 @@ extension TableMapping { // MARK: - Deleting by Key - /// Delete records, given an array of key dictionaries. + /// Delete records identified by the provided unique keys (primary key or + /// any key with a unique index on it); returns the number of deleted rows. /// - /// try Person.deleteAll(db, keys: [["name": "Arthur"], ["name": "Barbara"]]) + /// try Person.deleteAll(db, keys: [["email": "a@example.com"], ["email": "b@example.com"]]) /// /// - parameters: /// - db: A database connection. /// - keys: An array of key dictionaries. /// - returns: The number of deleted rows - public static func deleteAll(_ db: Database, keys: [[String: DatabaseValueConvertible?]]) throws -> Int { + @discardableResult public static func deleteAll(_ db: Database, keys: [[String: DatabaseValueConvertible?]]) throws -> Int { guard let statement = try makeDeleteByKeyStatement(db, keys: keys) else { return 0 } @@ -292,7 +304,8 @@ extension TableMapping { return db.changesCount } - /// Delete a record, identified by a key dictionary. + /// Delete a record, identified by a unique key (the primary key or any key + /// with a unique index on it); returns whether a database row was deleted. /// /// Person.deleteOne(db, key: ["name": Arthur"]) /// @@ -300,7 +313,7 @@ extension TableMapping { /// - db: A database connection. /// - key: A dictionary of values. /// - returns: Whether a database row was deleted. - public static func deleteOne(_ db: Database, key: [String: DatabaseValueConvertible?]) throws -> Bool { + @discardableResult public static func deleteOne(_ db: Database, key: [String: DatabaseValueConvertible?]) throws -> Bool { return try deleteAll(db, keys: [key]) > 0 } diff --git a/README.md b/README.md index 68ebee3b5..e96daddbe 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ GRDB.swift [![Swift](https://img.shields.io/badge/swift-3-orange.svg?style=flat) ### A Swift application toolkit for SQLite databases. -**Requirements**: iOS 8.0+ / OSX 10.9+ • Xcode Version 8.0 beta 6 (8S201h) • Swift 3. +**Requirements**: iOS 8.0+ / OSX 10.9+ • Xcode Version 8.0 GM (8A218a) • Swift 3. -The Swift3 branch has no version. It is currently synced with v0.79.4 of the Swift 2.2 [main branch](https://github.com/groue/GRDB.swift). +The Swift3 branch has no version. It is currently synced with v0.80.0 of the Swift 2.2 [main branch](https://github.com/groue/GRDB.swift). Follow [@groue](http://twitter.com/groue) on Twitter for release announcements and usage tips. @@ -302,7 +302,7 @@ let dbQueue = try DatabaseQueue( configuration: config) ``` -See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Structs/Configuration.html) for more details. +See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Structs/Configuration.html) for more details. ## Database Pools @@ -382,7 +382,7 @@ let dbPool = try DatabasePool( configuration: config) ``` -See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Structs/Configuration.html) for more details. +See [Configuration](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Structs/Configuration.html) for more details. Database pools are more memory-hungry than database queues. See [Memory Management](#memory-management) for more information. @@ -1477,10 +1477,10 @@ for person in Person.fetch(db, sql, adapter: adapter) { For more information about row adapters, see the documentation of: -- [RowAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Protocols/RowAdapter.html): the protocol that lets you define your custom row adapters -- [ColumnMapping](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Structs/ColumnMapping.html): a row adapter that renames row columns -- [SuffixRowAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Structs/SuffixRowAdapter.html): a row adapter that hides the first columns of a row -- [ScopeAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Structs/ScopeAdapter.html): the row adapter that groups several adapters together to define scopes +- [RowAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Protocols/RowAdapter.html): the protocol that lets you define your custom row adapters +- [ColumnMapping](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Structs/ColumnMapping.html): a row adapter that renames row columns +- [SuffixRowAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Structs/SuffixRowAdapter.html): a row adapter that hides the first columns of a row +- [ScopeAdapter](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Structs/ScopeAdapter.html): the row adapter that groups several adapters together to define scopes ## Raw SQLite Pointers @@ -1771,9 +1771,9 @@ When given dictionaries, `fetchOne`, `deleteOne`, `fetchAll` and `deleteAll` acc ```swift // CREATE TABLE persons ( -// id INTEGER PRIMARY KEY, -- can fetch and delete by id -// email TEXT UNIQUE, -- can fetch and delete by email -// name TEXT -- nope +// id INTEGER PRIMARY KEY, -- unique id +// email TEXT UNIQUE, -- unique email +// name TEXT -- not unique // ) Person.fetchOne(db, key: ["id": 1]) // Person? Person.fetchOne(db, key: ["email": "arthur@example.com"]) // Person? @@ -2075,9 +2075,17 @@ The Query Interface **The query interface lets you write pure Swift instead of SQL:** ```swift +// Update database schema try db.create(table: "wines") { t in ... } -let count = Wine.filter(color == Color.red).fetchCount(db) + +// Fetch let wines = Wine.filter(origin == "Burgundy").order(price).fetchAll(db) + +// Count +let count = Wine.filter(color == Color.red).fetchCount(db) + +// Delete +try Wine.filter(corked == true).deleteAll(db) ``` Please bear in mind that the query interface can not generate all possible SQL queries. You may also *prefer* writing SQL, and this is just OK. From little snippets to full queries, your SQL skills are welcome: @@ -2086,6 +2094,7 @@ Please bear in mind that the query interface can not generate all possible SQL q try db.execute("CREATE TABLE wines (...)") let count = Wine.filter(sql: "color = ?", arguments: [Color.Red]).fetchCount(db) let wines = Wine.fetchAll(db, "SELECT * FROM wines WHERE origin = ? ORDER BY price", arguments: ["Burgundy"]) +try db.execute("DELETE FROM wines WHERE corked") ``` So don't miss the [SQL API](#sqlite-api). @@ -2098,6 +2107,7 @@ So don't miss the [SQL API](#sqlite-api). - [Fetching from Requests](#fetching-from-requests) - [Fetching by Primary Key](#fetching-by-primary-key) - [Fetching Aggregated Values](#fetching-aggregated-values) +- [Delete Requests](#delete-requests) ## Database Schema @@ -2616,7 +2626,7 @@ For multiple-column primary keys, provide a dictionary: Citizenship.fetchOne(db, key: ["personID": 1, "countryISOCode": "FR"]) // Citizenship? ``` -You can use generally use a dictionary for any **unique key** (primary key and columns involved in a unique index): +You can generally use a dictionary for any **unique key** (primary key and columns involved in a unique index): ```swift Person.fetchOne(db, key: ["email": "arthur@example.com"]) // Person? @@ -2655,6 +2665,60 @@ let maxHeight = row.value(atIndex: 1) as Double? ``` +## Delete Requests + +**Requests can delete records**, with the `deleteAll()` method: + +```swift +// DELETE FROM persons WHERE email IS NULL +let request = Person.filter(emailColumn == nil) +try request.deleteAll(db) +``` + +**Deleting records according to their primary key** is also quite common. It has a shortcut which accepts any single-column primary key: + +```swift +// DELETE FROM persons WHERE id = 1 +try Person.deleteOne(db, key: 1) + +// DELETE FROM persons WHERE id IN (1, 2, 3) +try Person.deleteAll(db, keys: [1, 2, 3]) + +// DELETE FROM persons WHERE isoCode = 'FR' +try Country.deleteOne(db, key: "FR") + +// DELETE FROM countries WHERE isoCode IN ('FR', 'US') +try Country.deleteAll(db, keys: ["FR", "US"]) +``` + +For multiple-column primary keys, provide a dictionary: + +```swift +// DELETE FROM citizenships WHERE personID = 1 AND countryISOCode = 'FR' +try Citizenship.deleteOne(db, key: ["personID": 1, "countryISOCode": "FR"]) +``` + +You can generally use a dictionary for any **unique key** (primary key and columns involved in a unique index): + +```swift +Person.deleteOne(db, key: ["email": "arthur@example.com"]) +``` + +When given dictionaries, `deleteOne` and `deleteAll` accept any set of columns that uniquely identify rows. These are the primary key columns, or any columns involved in a unique index: + +```swift +// CREATE TABLE persons ( +// id INTEGER PRIMARY KEY, -- unique id +// email TEXT UNIQUE, -- unique email +// name TEXT -- not unique +// ) +try Person.deleteOne(db, key: ["id": 1]) +try Person.deleteOne(db, key: ["email": "arthur@example.com"]) +try Person.deleteOne(db, key: ["name": "Arthur"]) // fatal error: table persons has no unique index on column name. +``` + + + Application Tools ================= @@ -3630,7 +3694,7 @@ let count2 = dbQueue.inDatabase { db in SQLite concurrency is a wiiide topic. -First have a detailed look at the full API of [DatabaseQueue](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Classes/DatabaseQueue.html) and [DatabasePool](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Classes/DatabasePool.html). Both adopt the [DatabaseReader](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Protocols/DatabaseReader.html) and [DatabaseWriter](http://cocoadocs.org/docsets/GRDB.swift/0.79.4/Protocols/DatabaseWriter.html) protocols, so that you can write code that targets both classes. +First have a detailed look at the full API of [DatabaseQueue](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Classes/DatabaseQueue.html) and [DatabasePool](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Classes/DatabasePool.html). Both adopt the [DatabaseReader](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Protocols/DatabaseReader.html) and [DatabaseWriter](http://cocoadocs.org/docsets/GRDB.swift/0.80.0/Protocols/DatabaseWriter.html) protocols, so that you can write code that targets both classes. If the built-in queues and pools do not fit your needs, or if you can not guarantee that a single queue or pool is accessing your database file, you may have a look at: diff --git a/Support/Info.plist b/Support/Info.plist index 66607ff3e..456e4f527 100644 --- a/Support/Info.plist +++ b/Support/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.79.4 + 0.80.0 CFBundleSignature ???? CFBundleVersion diff --git a/Support/module.modulemap b/Support/module.modulemap index 16936c916..a061671a4 100644 --- a/Support/module.modulemap +++ b/Support/module.modulemap @@ -19,3 +19,13 @@ module SQLiteiPhoneSimulator { header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h" export * } + +module SQLiteWatchOS { + header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/includesqlite3.h" + export * +} + +module SQLiteWatchSimulator { + header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/sqlite3.h" + export * +} diff --git a/TODO.md b/TODO.md index 4b99addf2..df8f9409e 100644 --- a/TODO.md +++ b/TODO.md @@ -13,6 +13,7 @@ - [ ] Swift3: move database event filtering into the TransactionObserver protocol - [ ] Swift3: conversion from Row to NSDictionary - [ ] Fatal Error when MutablePersistable.update(_:columns:) is given columns that do not exist in the database. +- [ ] Fix slow compilation time of SQLTableBuilderTests.swift - [ ] @hdlj: Extensibility of the Query Interface - [ ] @hdlj: FetchedRecordsController throttling - [ ] @hdlj: Check RAM pressure @@ -71,3 +72,5 @@ Reading list: - Amazing tip from Xcode labs: add a EXCLUDED_SOURCE_FILE_NAMES build setting to conditionally exclude sources for different configuration: https://twitter.com/zats/status/74386298602026496 - SQLITE_ENABLE_SQLLOG: http://mjtsai.com/blog/2016/07/19/sqlite_enable_sqllog/ - [Writing High-Performance Swift Code](https://github.com/apple/swift/blob/master/docs/OptimizationTips.rst) +- http://docs.diesel.rs/diesel/associations/index.html +- http://cocoamine.net/blog/2015/09/07/contentless-fts4-for-large-immutable-documents/ diff --git a/Tests/Private/DataMemoryTests.swift b/Tests/Private/DataMemoryTests.swift index ab697a12a..08a509b94 100644 --- a/Tests/Private/DataMemoryTests.swift +++ b/Tests/Private/DataMemoryTests.swift @@ -9,6 +9,12 @@ import XCTest #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/Tests/Public/Core/Database/DatabaseTests.swift b/Tests/Public/Core/Database/DatabaseTests.swift index 018e5af7b..ead549682 100644 --- a/Tests/Public/Core/Database/DatabaseTests.swift +++ b/Tests/Public/Core/Database/DatabaseTests.swift @@ -24,6 +24,21 @@ class DatabaseTests : GRDBTestCase { } } + func testCreateTemporaryTable() { + assertNoError { + let dbQueue = try makeDatabaseQueue() + try dbQueue.inDatabase { db in + XCTAssertFalse(db.tableExists("persons")) + try db.execute( + "CREATE TEMPORARY TABLE persons (" + + "id INTEGER PRIMARY KEY, " + + "name TEXT, " + + "age INT)") + XCTAssertTrue(db.tableExists("persons")) + } + } + } + func testMultipleStatementsWithoutArguments() { assertNoError { let dbQueue = try makeDatabaseQueue() diff --git a/Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleFetchTests.swift b/Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleFetchTests.swift index 6ac50d82a..359389b1b 100644 --- a/Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleFetchTests.swift +++ b/Tests/Public/Core/StatementColumnConvertible/StatementColumnConvertibleFetchTests.swift @@ -16,6 +16,12 @@ import XCTest #else import SQLiteiPhoneOS #endif + #elseif os(watchOS) + #if (arch(i386) || arch(x86_64)) + import SQLiteWatchSimulator + #else + import SQLiteWatchOS + #endif #endif #endif diff --git a/Tests/Public/QueryInterfaceRequest/QueryInterfaceRequestTests.swift b/Tests/Public/QueryInterfaceRequest/QueryInterfaceRequestTests.swift index 1e7ece611..3358e7346 100644 --- a/Tests/Public/QueryInterfaceRequest/QueryInterfaceRequestTests.swift +++ b/Tests/Public/QueryInterfaceRequest/QueryInterfaceRequestTests.swift @@ -485,4 +485,33 @@ class QueryInterfaceRequestTests: GRDBTestCase { sql(dbQueue, tableRequest.limit(1, offset: 2).limit(3)), "SELECT * FROM \"readers\" LIMIT 3") } + + + // MARK: - Delete + + func testDelete() { + assertNoError { + let dbQueue = try makeDatabaseQueue() + + try dbQueue.inDatabase { db in + try tableRequest.deleteAll(db) + XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"readers\"") + + try tableRequest.filter(Col.age == 42).deleteAll(db) + XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"readers\" WHERE (\"age\" = 42)") + + try tableRequest.filter(sql: "id = 1").deleteAll(db) + XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"readers\" WHERE id = 1") + + try tableRequest.select(Col.name).deleteAll(db) + XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"readers\"") + + try tableRequest.distinct().deleteAll(db) + XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"readers\"") + + try tableRequest.order(Col.name).deleteAll(db) + XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"readers\"") + } + } + } }