From 0d514b56f60ddb187ef8a85154d028e88fd1fc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Mon, 29 Jun 2020 18:45:58 +0200 Subject: [PATCH] Remove more references to FetchedRecordsController --- .../Issue156.playground/Contents.swift | 101 ------------------ .../Issue156.playground/contents.xcplayground | 4 - .../xcshareddata/xcschemes/GRDBOSX.xcscheme | 23 ---- GRDB.xcworkspace/contents.xcworkspacedata | 3 - 4 files changed, 131 deletions(-) delete mode 100644 Documentation/Playgrounds/Issue156.playground/Contents.swift delete mode 100644 Documentation/Playgrounds/Issue156.playground/contents.xcplayground diff --git a/Documentation/Playgrounds/Issue156.playground/Contents.swift b/Documentation/Playgrounds/Issue156.playground/Contents.swift deleted file mode 100644 index eadcc2129..000000000 --- a/Documentation/Playgrounds/Issue156.playground/Contents.swift +++ /dev/null @@ -1,101 +0,0 @@ -// Issue156 -// -// This playground exists as a test of issue #156, for which I'm not sure we -// have a test today. - -import Foundation -import GRDB -import PlaygroundSupport - -class TestDeleteAll: NSObject { - - let databasePool: DatabasePool - let fetchedRecordsController: FetchedRecordsController - - override init() { - // Init a databasePool & a fetchedRecordsController - - let databasePath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] + "/myDatabase.sqlite" - databasePool = try! DatabasePool(path: databasePath) - - var migrator = DatabaseMigrator() - migrator.registerMigration("1") { db in - try! db.create(table: MyRecord.databaseTableName) { t in - t.column(MyRecord.MyColumn.name, .text) - } - } - try! migrator.migrate(databasePool) - - fetchedRecordsController = try! FetchedRecordsController(databasePool, request: MyRecord.all()) - try! fetchedRecordsController.performFetch() - fetchedRecordsController.trackChanges { controller in - print("RecordsDidChange triggered: number of records = \(controller.fetchedRecords.count)\n") - } - - super.init() - run() - } - - func run() { - insertThreeRecords() - perform(#selector(deleteAllWithFilter), with: nil, afterDelay: 1) - perform(#selector(insertThreeRecords), with: nil, afterDelay: 2) - perform(#selector(deleteAll), with: nil, afterDelay: 3) - perform(#selector(insertThreeRecords), with: nil, afterDelay: 4) - } - - @objc - func insertThreeRecords() { - print("Insert 3 records") - let myRecord1 = MyRecord(myColumn: "1") - let myRecord2 = MyRecord(myColumn: "2") - let myRecord3 = MyRecord(myColumn: "3") - try! databasePool.writeInTransaction { db in - try myRecord1.save(db) - try myRecord2.save(db) - try myRecord3.save(db) - return .commit - } - } - - @objc - func deleteAllWithFilter() { - print("Delete all records with filter(1 == 1).deleteAll(db)") - _ = try! databasePool.write { db in - try MyRecord.filter(1 == 1).deleteAll(db) - } - } - - @objc - func deleteAll() { - print("Delete all records with deleteAll(db)") - _ = try! databasePool.write { db in - try MyRecord.deleteAll(db) - } - } - -} - -struct MyRecord: FetchableRecord, TableRecord, PersistableRecord { - - static let MyColumn = Column("MyColumn") - static var databaseTableName: String { String(describing: self) } - - let myColumn: String - - init(myColumn: String) { - self.myColumn = myColumn - } - - init(row: Row) { - self.myColumn = row[MyRecord.MyColumn] - } - - func encode(to container: inout PersistenceContainer) { - container[MyRecord.MyColumn] = myColumn - } -} - - -TestDeleteAll() -PlaygroundPage.current.needsIndefiniteExecution = true diff --git a/Documentation/Playgrounds/Issue156.playground/contents.xcplayground b/Documentation/Playgrounds/Issue156.playground/contents.xcplayground deleted file mode 100644 index 63b6dd8df..000000000 --- a/Documentation/Playgrounds/Issue156.playground/contents.xcplayground +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBOSX.xcscheme b/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBOSX.xcscheme index 6de72bd20..40919e68d 100644 --- a/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBOSX.xcscheme +++ b/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBOSX.xcscheme @@ -52,29 +52,6 @@ BlueprintName = "GRDBOSXTests" ReferencedContainer = "container:GRDB.xcodeproj"> - - - - - - - - - - - - - - - - diff --git a/GRDB.xcworkspace/contents.xcworkspacedata b/GRDB.xcworkspace/contents.xcworkspacedata index 244a3cb1c..f4df42a9e 100644 --- a/GRDB.xcworkspace/contents.xcworkspacedata +++ b/GRDB.xcworkspace/contents.xcworkspacedata @@ -13,9 +13,6 @@ - -