Merge branch 'throwables' into develop

This commit is contained in:
John Estropia
2019-01-22 16:38:57 +09:00
40 changed files with 1722 additions and 1639 deletions

View File

@@ -20,7 +20,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
application.statusBarStyle = .lightContent
return true
}
}

View File

@@ -25,7 +25,7 @@ private struct Static {
_ = try? dataStack.perform(
synchronous: { (transaction) in
transaction.deleteAll(From<TimeZone>())
try transaction.deleteAll(From<TimeZone>())
for name in NSTimeZone.knownTimeZoneNames {
@@ -164,17 +164,17 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
title: "All Time Zones",
fetch: { () -> [TimeZone] in
return Static.timeZonesStack.fetchAll(
return try! Static.timeZonesStack.fetchAll(
From<TimeZone>()
.orderBy(.ascending(\.name))
)!
)
}
),
(
title: "Time Zones in Asia",
fetch: { () -> [TimeZone] in
return Static.timeZonesStack.fetchAll(
return try! Static.timeZonesStack.fetchAll(
From<TimeZone>()
.where(
format: "%K BEGINSWITH[c] %@",
@@ -182,14 +182,14 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
"Asia"
)
.orderBy(.ascending(\.secondsFromGMT))
)!
)
}
),
(
title: "Time Zones in America and Europe",
fetch: { () -> [TimeZone] in
return Static.timeZonesStack.fetchAll(
return try! Static.timeZonesStack.fetchAll(
From<TimeZone>()
.where(
format: "%K BEGINSWITH[c] %@ OR %K BEGINSWITH[c] %@",
@@ -199,14 +199,14 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
"Europe"
)
.orderBy(.ascending(\.secondsFromGMT))
)!
)
}
),
(
title: "All Time Zones Except America",
fetch: { () -> [TimeZone] in
return Static.timeZonesStack.fetchAll(
return try! Static.timeZonesStack.fetchAll(
From<TimeZone>()
.where(
format: "%K BEGINSWITH[c] %@",
@@ -214,18 +214,18 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
"America"
)
.orderBy(.ascending(\.secondsFromGMT))
)!
)
}
),
(
title: "Time Zones with Summer Time",
fetch: { () -> [TimeZone] in
return Static.timeZonesStack.fetchAll(
return try! Static.timeZonesStack.fetchAll(
From<TimeZone>()
.where(\.hasDaylightSavingTime == true)
.orderBy(.ascending(\.name))
)!
)
}
)
]
@@ -235,28 +235,28 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
title: "Number of Time Zones",
query: { () -> Any in
return Static.timeZonesStack.queryValue(
return try! Static.timeZonesStack.queryValue(
From<TimeZone>()
.select(NSNumber.self, .count(\.name))
)! as Any
)!
}
),
(
title: "Abbreviation For Tokyo's Time Zone",
query: { () -> Any in
return Static.timeZonesStack.queryValue(
return try! Static.timeZonesStack.queryValue(
From<TimeZone>()
.select(String.self, .attribute(\.abbreviation))
.where(format: "%K ENDSWITH[c] %@", #keyPath(TimeZone.name), "Tokyo")
)! as Any
)!
}
),
(
title: "All Abbreviations",
query: { () -> Any in
return Static.timeZonesStack.queryAttributes(
return try! Static.timeZonesStack.queryAttributes(
From<TimeZone>()
.select(
NSDictionary.self,
@@ -264,14 +264,14 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
.attribute(\.abbreviation)
)
.orderBy(.ascending(\.name))
)!
)
}
),
(
title: "Number of Countries per Time Zone",
query: { () -> Any in
return Static.timeZonesStack.queryAttributes(
return try! Static.timeZonesStack.queryAttributes(
From<TimeZone>()
.select(
NSDictionary.self,
@@ -283,14 +283,14 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
.ascending(\.secondsFromGMT),
.ascending(\.name)
)
)!
)
}
),
(
title: "Number of Countries with Summer Time",
query: { () -> Any in
return Static.timeZonesStack.queryAttributes(
return try! Static.timeZonesStack.queryAttributes(
From<TimeZone>()
.select(
NSDictionary.self,
@@ -302,7 +302,7 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
.descending(\.hasDaylightSavingTime),
.ascending(\.name)
)
)!
)
}
)
]

View File

@@ -160,7 +160,7 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return ColorsDemo.palettes.numberOfObjectsInSection(section)
return ColorsDemo.palettes.numberOfObjects(in: section)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -208,7 +208,7 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return ColorsDemo.palettes.sectionInfoAtIndex(section).name
return ColorsDemo.palettes.sectionInfo(at: section).name
}
@@ -288,7 +288,7 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver
ColorsDemo.stack.perform(
asynchronous: { (transaction) in
transaction.deleteAll(From<Palette>())
try transaction.deleteAll(From<Palette>())
},
completion: { _ in }
)
@@ -316,7 +316,7 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver
ColorsDemo.stack.perform(
asynchronous: { (transaction) in
for palette in (transaction.fetchAll(From<Palette>()) ?? []) {
for palette in try transaction.fetchAll(From<Palette>()) {
palette.hue .= Palette.randomHue()
palette.colorName .= nil

View File

@@ -50,7 +50,7 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver {
required init?(coder aDecoder: NSCoder) {
if let palette = ColorsDemo.stack.fetchOne(From<Palette>().orderBy(.ascending(\.hue))) {
if let palette = try! ColorsDemo.stack.fetchOne(From<Palette>().orderBy(.ascending(\.hue))) {
self.monitor = ColorsDemo.stack.monitorObject(palette)
}
@@ -64,7 +64,7 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver {
}
)
let palette = ColorsDemo.stack.fetchOne(From<Palette>().orderBy(.ascending(\.hue)))!
let palette = try! ColorsDemo.stack.fetchOne(From<Palette>().orderBy(.ascending(\.hue)))!
self.monitor = ColorsDemo.stack.monitorObject(palette)
}

View File

@@ -116,7 +116,7 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger {
case 2?:
DispatchQueue.global(qos: .background).async {
_ = self.dataStack.fetchOne(From<Place>())
_ = try! self.dataStack.fetchOne(From<Place>())
}
default:

View File

@@ -79,7 +79,7 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD
func listMonitorDidChange(_ monitor: ListMonitor<NSManagedObject>) {
if self.lastSelectedIndexPath == nil,
let numberOfObjectsInSection = self.listMonitor?.numberOfObjectsInSection(0),
let numberOfObjectsInSection = self.listMonitor?.numberOfObjects(in: 0),
numberOfObjectsInSection > 0 {
self.tableView?.reloadData()
@@ -100,7 +100,7 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD
@objc dynamic func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.listMonitor?.numberOfObjectsInSection(0) ?? 0
return self.listMonitor?.numberOfObjects(in: 0) ?? 0
}
@objc dynamic func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -286,7 +286,7 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD
self.set(dataStack: dataStack, model: model, scrollToSelection: true)
let count = dataStack.queryValue(
let count = try! dataStack.queryValue(
From<NSManagedObject>(model.entityType)
.select(Int.self, .count(#keyPath(OrganismV1.dna))))!
if count > 0 {
@@ -378,7 +378,7 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD
if self.lastSelectedIndexPath == nil {
if listMonitor.numberOfObjectsInSection(0) > 0 {
if listMonitor.numberOfObjects(in: 0) > 0 {
self.setSelectedIndexPath(IndexPath(row: 0, section: 0), scrollToSelection: true)
}

View File

@@ -36,7 +36,7 @@ private struct Static {
_ = try? dataStack.perform(
synchronous: { (transaction) in
transaction.deleteAll(From<UserAccount>())
try transaction.deleteAll(From<UserAccount>())
let account1 = transaction.create(Into<MaleAccount>(maleConfiguration))
account1.accountType = "Facebook"
@@ -74,7 +74,7 @@ private struct Static {
_ = try? dataStack.perform(
synchronous: { (transaction) in
transaction.deleteAll(From<UserAccount>())
try transaction.deleteAll(From<UserAccount>())
let account1 = transaction.create(Into<MaleAccount>(maleConfiguration))
account1.accountType = "Twitter"
@@ -99,8 +99,8 @@ private struct Static {
class StackSetupDemoViewController: UITableViewController {
let accounts = [
Static.facebookStack.fetchAll(From(UserAccount.self)) ?? [],
Static.twitterStack.fetchAll(From(UserAccount.self)) ?? []
try! Static.facebookStack.fetchAll(From<UserAccount>()),
try! Static.twitterStack.fetchAll(From<UserAccount>())
]

View File

@@ -26,7 +26,7 @@ private struct Static {
)
)
var place = CoreStore.fetchOne(From<Place>())
var place = try! CoreStore.fetchOne(From<Place>())
if place == nil {
_ = try? CoreStore.perform(
@@ -36,7 +36,7 @@ private struct Static {
place.setInitialValues()
}
)
place = CoreStore.fetchOne(From<Place>())
place = try! CoreStore.fetchOne(From<Place>())
}
return CoreStore.monitorObject(place!)

View File

@@ -36,8 +36,7 @@ class BaseTestCase: XCTestCase {
// MARK: Internal
@nonobjc
@discardableResult
func prepareStack<T>(configurations: [ModelConfiguration] = [nil], _ closure: (_ dataStack: DataStack) -> T) -> T {
func prepareStack(configurations: [ModelConfiguration] = [nil], _ closure: (_ dataStack: DataStack) throws -> Void) {
let stack = DataStack(
xcodeModelName: "Model",
@@ -57,16 +56,16 @@ class BaseTestCase: XCTestCase {
)
)
}
try closure(stack)
}
catch let error as NSError {
XCTFail(error.coreStoreDumpString)
}
return closure(stack)
}
@nonobjc
func expectLogger<T>(_ expectations: [TestLogger.Expectation], closure: () -> T) -> T {
func expectLogger<T>(_ expectations: [TestLogger.Expectation], closure: () throws -> T) rethrows -> T {
CoreStore.logger = TestLogger(self.prepareLoggerExpectations(expectations))
defer {
@@ -74,7 +73,7 @@ class BaseTestCase: XCTestCase {
self.checkExpectationsImmediately()
CoreStore.logger = TestLogger([:])
}
return closure()
return try closure()
}
@nonobjc

View File

@@ -248,51 +248,54 @@ class DynamicModelTests: BaseTestDataTestCase {
let p1 = Where<Animal>({ $0.species == "Sparrow" })
XCTAssertEqual(p1.predicate, NSPredicate(format: "%K == %@", "species", "Sparrow"))
let bird = transaction.fetchOne(From<Animal>(), p1)
let bird = try transaction.fetchOne(From<Animal>(), p1)
XCTAssertNotNil(bird)
XCTAssertEqual(bird!.species.value, "Sparrow")
let p2 = Where<Dog>({ $0.nickname == "Spot" })
XCTAssertEqual(p2.predicate, NSPredicate(format: "%K == %@", "nickname", "Spot"))
let dog = transaction.fetchOne(From<Dog>().where(\.nickname == "Spot"))
let dog = try transaction.fetchOne(From<Dog>().where(\.nickname == "Spot"))
XCTAssertNotNil(dog)
XCTAssertEqual(dog!.nickname.value, "Spot")
XCTAssertEqual(dog!.species.value, "Dog")
let person = transaction.fetchOne(From<Person>())
let person = try transaction.fetchOne(From<Person>())
XCTAssertNotNil(person)
XCTAssertEqual(person!.pets.value.first, dog)
let p3 = Where<Dog>({ $0.age == 10 })
XCTAssertEqual(p3.predicate, NSPredicate(format: "%K == %d", "age", 10))
let totalAge = try transaction.queryValue(From<Dog>().select(Int.self, .sum(\Dog.age)))
XCTAssertEqual(totalAge, 1)
_ = transaction.fetchAll(
_ = try transaction.fetchAll(
From<Dog>()
.where(\Animal.species == "Dog" && \.age == 10)
)
_ = transaction.fetchAll(
_ = try transaction.fetchAll(
From<Dog>()
.where(\.age == 10 && \Animal.species == "Dog")
.orderBy(.ascending({ $0.species }))
)
_ = transaction.fetchAll(
_ = try transaction.fetchAll(
From<Dog>(),
Where<Dog>({ $0.age > 10 && $0.age <= 15 })
)
_ = transaction.fetchAll(
_ = try transaction.fetchAll(
From<Dog>(),
Where<Dog>({ $0.species == "Dog" && $0.age == 10 })
)
_ = transaction.fetchAll(
_ = try transaction.fetchAll(
From<Dog>(),
Where<Dog>({ $0.age == 10 && $0.species == "Dog" })
)
_ = transaction.fetchAll(
_ = try transaction.fetchAll(
From<Dog>(),
Where<Dog>({ $0.age > 10 && $0.age <= 15 })
)
_ = transaction.fetchAll(
_ = try transaction.fetchAll(
From<Dog>(),
(\Dog.age > 10 && \Dog.age <= 15)
)

File diff suppressed because it is too large Load Diff

View File

@@ -75,8 +75,7 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>()
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -90,11 +89,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config1")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -116,8 +115,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>()
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -131,8 +130,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config1")
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -146,11 +145,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config2")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -164,11 +163,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>()
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -182,11 +181,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config1")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -200,11 +199,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config2")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -226,8 +225,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>()
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -241,8 +240,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config1")
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -256,11 +255,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config2")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -274,8 +273,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>()
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -289,11 +288,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config1")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -307,11 +306,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config2")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -333,8 +332,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>()
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -348,8 +347,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config1")
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -363,11 +362,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config2")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -381,8 +380,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>()
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -396,11 +395,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config1")
let request = CoreStoreFetchRequest()
let storesFound = self.expectLogger([.logWarning]) {
let storesFound: Void? = try? self.expectLogger([.logError]) {
from.applyToFetchRequest(request, context: dataStack.mainContext)
try from.applyToFetchRequest(request, context: dataStack.mainContext)
}
XCTAssertFalse(storesFound)
XCTAssertNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)
@@ -414,8 +413,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config2")
let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores)

View File

@@ -69,7 +69,7 @@ final class GroupByTests: BaseTestCase {
let groupBy = GroupBy<NSManagedObject>(#keyPath(TestEntity1.testString))
let request = CoreStoreFetchRequest()
_ = From<TestEntity1>().applyToFetchRequest(request, context: dataStack.mainContext)
try From<TestEntity1>().applyToFetchRequest(request, context: dataStack.mainContext)
groupBy.applyToFetchRequest(request)
XCTAssertNotNil(request.propertiesToGroupBy)

View File

@@ -95,7 +95,7 @@ class ImportTests: BaseTestDataTestCase {
]
)
XCTAssertNil(object)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 0)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 0)
}
)
}
@@ -103,7 +103,7 @@ class ImportTests: BaseTestDataTestCase {
XCTFail()
}
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
}
}
@@ -137,9 +137,9 @@ class ImportTests: BaseTestDataTestCase {
catch _ as TestInsertError {
errorExpectation.fulfill()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
let object = transaction.fetchOne(From<TestEntity1>())
let object = try transaction.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertNil(object?.testEntityID)
XCTAssertNil(object?.testBoolean)
@@ -182,7 +182,7 @@ class ImportTests: BaseTestDataTestCase {
]
)
XCTAssertNotNil(object)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
XCTAssertNil(object?.testEntityID)
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
XCTAssertEqual(object?.testNumber, NSNumber(value: 1))
@@ -202,7 +202,7 @@ class ImportTests: BaseTestDataTestCase {
#keyPath(TestEntity1.testDate): self.dateFormatter.date(from: "2000-01-02T00:00:00Z")!
]
)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
XCTAssertNil(object?.testEntityID)
XCTAssertEqual(object?.testBoolean, NSNumber(value: false))
XCTAssertEqual(object?.testNumber, NSNumber(value: 2))
@@ -254,7 +254,7 @@ class ImportTests: BaseTestDataTestCase {
sourceArray: sourceArray
)
XCTAssertEqual(objects.count, 1)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
let object = objects[0]
let dictionary = sourceArray[1]
@@ -316,9 +316,9 @@ class ImportTests: BaseTestDataTestCase {
catch _ as TestInsertError {
errorExpectation.fulfill()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
let object = transaction.fetchOne(From<TestEntity1>())
let object = try transaction.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertNil(object?.testEntityID)
XCTAssertNil(object?.testBoolean)
@@ -372,7 +372,7 @@ class ImportTests: BaseTestDataTestCase {
sourceArray: sourceArray
)
XCTAssertEqual(objects.count, sourceArray.count)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 2)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 2)
for i in 0 ..< sourceArray.count {
@@ -424,7 +424,7 @@ class ImportTests: BaseTestDataTestCase {
]
)
XCTAssertNil(object)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 5)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 5)
}
do {
@@ -442,20 +442,19 @@ class ImportTests: BaseTestDataTestCase {
]
)
XCTAssertNil(object)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 5)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 5)
let existingObjects = transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertNotNil(existingObjects)
XCTAssertEqual(existingObjects?.count, 1)
let existingObjects = try transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertEqual(existingObjects.count, 1)
let existingObject = existingObjects?[0]
XCTAssertEqual(existingObject?.testEntityID, NSNumber(value: 105))
XCTAssertEqual(existingObject?.testBoolean, NSNumber(value: true))
XCTAssertEqual(existingObject?.testNumber, NSNumber(value: 5))
XCTAssertEqual(existingObject?.testDecimal, NSDecimalNumber(string: "5"))
XCTAssertEqual(existingObject?.testString, "nil:TestEntity1:5")
XCTAssertEqual(existingObject?.testData, ("nil:TestEntity1:5" as NSString).data(using: String.Encoding.utf8.rawValue)!)
XCTAssertEqual(existingObject?.testDate, self.dateFormatter.date(from: "2000-01-05T00:00:00Z")!)
let existingObject = existingObjects[0]
XCTAssertEqual(existingObject.testEntityID, NSNumber(value: 105))
XCTAssertEqual(existingObject.testBoolean, NSNumber(value: true))
XCTAssertEqual(existingObject.testNumber, NSNumber(value: 5))
XCTAssertEqual(existingObject.testDecimal, NSDecimalNumber(string: "5"))
XCTAssertEqual(existingObject.testString, "nil:TestEntity1:5")
XCTAssertEqual(existingObject.testData, ("nil:TestEntity1:5" as NSString).data(using: String.Encoding.utf8.rawValue)!)
XCTAssertEqual(existingObject.testDate, self.dateFormatter.date(from: "2000-01-05T00:00:00Z")!)
}
}
)
@@ -504,7 +503,7 @@ class ImportTests: BaseTestDataTestCase {
)
XCTAssertEqual(objects.count, 1)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 6)
let object = objects[0]
let dictionary = sourceArray[1]
@@ -618,9 +617,9 @@ class ImportTests: BaseTestDataTestCase {
catch _ as TestInsertError {
errorExpectation.fulfill()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 6)
let object = transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 106))
let object = try transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 106))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 106))
XCTAssertNil(object?.testBoolean)
@@ -657,21 +656,19 @@ class ImportTests: BaseTestDataTestCase {
catch _ as TestUpdateError {
errorExpectation.fulfill()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 6)
let existingObjects = transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertNotNil(existingObjects)
XCTAssertEqual(existingObjects?.count, 1)
let existingObjects = try transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertEqual(existingObjects.count, 1)
let existingObject = existingObjects?[0]
XCTAssertNotNil(existingObject)
XCTAssertEqual(existingObject?.testEntityID, NSNumber(value: 105))
XCTAssertEqual(existingObject?.testBoolean, NSNumber(value: true))
XCTAssertEqual(existingObject?.testNumber, NSNumber(value: 5))
XCTAssertEqual(existingObject?.testDecimal, NSDecimalNumber(string: "5"))
XCTAssertEqual(existingObject?.testString, "nil:TestEntity1:5")
XCTAssertEqual(existingObject?.testData, ("nil:TestEntity1:5" as NSString).data(using: String.Encoding.utf8.rawValue)!)
XCTAssertEqual(existingObject?.testDate, self.dateFormatter.date(from: "2000-01-05T00:00:00Z")!)
let existingObject = existingObjects[0]
XCTAssertEqual(existingObject.testEntityID, NSNumber(value: 105))
XCTAssertEqual(existingObject.testBoolean, NSNumber(value: true))
XCTAssertEqual(existingObject.testNumber, NSNumber(value: 5))
XCTAssertEqual(existingObject.testDecimal, NSDecimalNumber(string: "5"))
XCTAssertEqual(existingObject.testString, "nil:TestEntity1:5")
XCTAssertEqual(existingObject.testData, ("nil:TestEntity1:5" as NSString).data(using: String.Encoding.utf8.rawValue)!)
XCTAssertEqual(existingObject.testDate, self.dateFormatter.date(from: "2000-01-05T00:00:00Z")!)
}
self.checkExpectationsImmediately()
}
@@ -710,7 +707,7 @@ class ImportTests: BaseTestDataTestCase {
]
)
XCTAssertNotNil(object)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 106))
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
@@ -735,7 +732,7 @@ class ImportTests: BaseTestDataTestCase {
]
)
XCTAssertNotNil(object)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 106))
XCTAssertEqual(object?.testBoolean, NSNumber(value: false))
@@ -745,11 +742,10 @@ class ImportTests: BaseTestDataTestCase {
XCTAssertEqual(object?.testData, ("nil:TestEntity1:7" as NSString).data(using: String.Encoding.utf8.rawValue)!)
XCTAssertEqual(object?.testDate, self.dateFormatter.date(from: "2000-01-07T00:00:00Z")!)
let existingObjects = transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 106))
XCTAssertNotNil(existingObjects)
XCTAssertEqual(existingObjects?.count, 1)
let existingObjects = try transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 106))
XCTAssertEqual(existingObjects.count, 1)
let existingObject = existingObjects?[0]
let existingObject = existingObjects[0]
XCTAssertEqual(existingObject, object)
}
}
@@ -799,7 +795,7 @@ class ImportTests: BaseTestDataTestCase {
sourceArray: sourceArray
)
XCTAssertEqual(objects.count, 1)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 6)
let object = objects[0]
let dictionary = sourceArray[1]
@@ -864,10 +860,10 @@ class ImportTests: BaseTestDataTestCase {
catch _ as TestIDError {
errorExpectation.fulfill()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 5)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 5)
XCTAssertNil(transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 106)))
XCTAssertNil(transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 107)))
XCTAssertNil(try transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 106)))
XCTAssertNil(try transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 107)))
}
transaction.unsafeContext().reset()
self.checkExpectationsImmediately()
@@ -910,7 +906,7 @@ class ImportTests: BaseTestDataTestCase {
errorExpectation.fulfill()
let object = transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 106))
let object = try transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 106))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 106))
XCTAssertNil(object?.testBoolean)
@@ -951,9 +947,9 @@ class ImportTests: BaseTestDataTestCase {
catch _ as TestUpdateError {
errorExpectation.fulfill()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 5)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 5)
let object = transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
let object = try transaction.fetchOne(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 105))
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
@@ -963,11 +959,10 @@ class ImportTests: BaseTestDataTestCase {
XCTAssertEqual(object?.testData, ("nil:TestEntity1:5" as NSString).data(using: String.Encoding.utf8.rawValue)!)
XCTAssertEqual(object?.testDate, self.dateFormatter.date(from: "2000-01-05T00:00:00Z")!)
let existingObjects = transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertNotNil(existingObjects)
XCTAssertEqual(existingObjects?.count, 1)
let existingObjects = try transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertEqual(existingObjects.count, 1)
let existingObject = existingObjects?[0]
let existingObject = existingObjects[0]
XCTAssertEqual(existingObject, object)
}
transaction.context.reset()
@@ -1018,7 +1013,7 @@ class ImportTests: BaseTestDataTestCase {
sourceArray: sourceArray
)
XCTAssertEqual(objects.count, sourceArray.count)
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 6)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 6)
for i in 0 ..< sourceArray.count {
let object = objects[i]
@@ -1032,11 +1027,10 @@ class ImportTests: BaseTestDataTestCase {
XCTAssertEqual(object.testData, dictionary[(#keyPath(TestEntity1.testData))] as? Data)
XCTAssertEqual(object.testDate, dictionary[(#keyPath(TestEntity1.testDate))] as? Date)
}
let existingObjects = transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertNotNil(existingObjects)
XCTAssertEqual(existingObjects?.count, 1)
let existingObjects = try transaction.fetchAll(From<TestEntity1>(), Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 105))
XCTAssertEqual(existingObjects.count, 1)
let existingObject = existingObjects?[0]
let existingObject = existingObjects[0]
XCTAssertEqual(existingObject, objects[0])
}
)

View File

@@ -76,7 +76,7 @@ class ListObserverTests: BaseTestDataTestCase {
XCTAssertEqual(
((note.userInfo as NSDictionary?) ?? [:]),
[
"sectionInfo": monitor.sectionInfoAtIndex(0),
"sectionInfo": monitor.sectionInfo(at: 0),
"sectionIndex": 0
] as NSDictionary
)
@@ -178,9 +178,9 @@ class ListObserverTests: BaseTestDataTestCase {
XCTAssertTrue(monitor.hasSections())
XCTAssertEqual(monitor.numberOfSections(), 2)
XCTAssertTrue(monitor.hasObjects())
XCTAssertTrue(monitor.hasObjectsInSection(0))
XCTAssertEqual(monitor.numberOfObjectsInSection(0), 2)
XCTAssertEqual(monitor.numberOfObjectsInSection(1), 3)
XCTAssertTrue(monitor.hasObjects(in: 0))
XCTAssertEqual(monitor.numberOfObjects(in: 0), 2)
XCTAssertEqual(monitor.numberOfObjects(in: 1), 3)
var events = 0
@@ -268,7 +268,7 @@ class ListObserverTests: BaseTestDataTestCase {
stack.perform(
asynchronous: { (transaction) -> Bool in
if let object = transaction.fetchOne(
if let object = try transaction.fetchOne(
From<TestEntity1>(),
Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 101)) {
@@ -282,7 +282,7 @@ class ListObserverTests: BaseTestDataTestCase {
XCTFail()
}
if let object = transaction.fetchOne(
if let object = try transaction.fetchOne(
From<TestEntity1>(),
Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 102)) {
@@ -394,7 +394,7 @@ class ListObserverTests: BaseTestDataTestCase {
stack.perform(
asynchronous: { (transaction) -> Bool in
if let object = transaction.fetchOne(
if let object = try transaction.fetchOne(
From<TestEntity1>(),
Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 102)) {
@@ -526,7 +526,7 @@ class ListObserverTests: BaseTestDataTestCase {
stack.perform(
asynchronous: { (transaction) -> Bool in
let count = transaction.deleteAll(
let count = try transaction.deleteAll(
From<TestEntity1>(),
Where<TestEntity1>(#keyPath(TestEntity1.testBoolean), isEqualTo: false)
)

View File

@@ -41,7 +41,7 @@ class ObjectObserverTests: BaseTestDataTestCase {
self.prepareTestDataForStack(stack)
guard let object = stack.fetchOne(
guard let object = try stack.fetchOne(
From<TestEntity1>(),
Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 101)) else {
@@ -138,7 +138,7 @@ class ObjectObserverTests: BaseTestDataTestCase {
self.prepareTestDataForStack(stack)
guard let object = stack.fetchOne(
guard let object = try stack.fetchOne(
From<TestEntity1>(),
Where<TestEntity1>(#keyPath(TestEntity1.testEntityID), isEqualTo: 101)) else {

View File

@@ -47,7 +47,7 @@ class QueryTests: BaseTestDataTestCase {
]
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Bool>(#keyPath(TestEntity1.testBoolean)),
queryClauses
@@ -57,7 +57,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int8>(#keyPath(TestEntity1.testNumber)),
queryClauses
@@ -67,7 +67,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int16>(#keyPath(TestEntity1.testNumber)),
queryClauses
@@ -77,7 +77,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int32>(#keyPath(TestEntity1.testNumber)),
queryClauses
@@ -87,7 +87,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int64>(#keyPath(TestEntity1.testNumber)),
queryClauses
@@ -97,7 +97,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int>(#keyPath(TestEntity1.testNumber)),
queryClauses
@@ -107,7 +107,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Double>(#keyPath(TestEntity1.testNumber)),
queryClauses
@@ -117,7 +117,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Float>(#keyPath(TestEntity1.testNumber)),
queryClauses
@@ -127,7 +127,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSNumber>(#keyPath(TestEntity1.testNumber)),
queryClauses
@@ -137,7 +137,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDecimalNumber>(#keyPath(TestEntity1.testDecimal)),
queryClauses
@@ -147,7 +147,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, String>(#keyPath(TestEntity1.testString)),
queryClauses
@@ -157,7 +157,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSString>(#keyPath(TestEntity1.testString)),
queryClauses
@@ -167,7 +167,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Data>(#keyPath(TestEntity1.testData)),
queryClauses
@@ -177,7 +177,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSData>(#keyPath(TestEntity1.testData)),
queryClauses
@@ -187,7 +187,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Date>(#keyPath(TestEntity1.testDate)),
queryClauses
@@ -197,7 +197,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDate>(#keyPath(TestEntity1.testDate)),
queryClauses
@@ -207,7 +207,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSManagedObjectID>(#keyPath(TestEntity1.testDate)),
queryClauses
@@ -232,7 +232,7 @@ class QueryTests: BaseTestDataTestCase {
]
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Bool>(.average(#keyPath(TestEntity1.testBoolean))),
queryClauses
@@ -242,7 +242,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int8>(.average(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -252,7 +252,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int16>(.average(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -262,7 +262,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int32>(.average(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -272,7 +272,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int64>(.average(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -282,7 +282,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int>(.average(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -292,7 +292,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Double>(.average(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -302,7 +302,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Float>(.average(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -312,7 +312,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSNumber>(.average(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -322,7 +322,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDecimalNumber>(.average(#keyPath(TestEntity1.testDecimal))),
queryClauses
@@ -332,7 +332,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, String>(.average(#keyPath(TestEntity1.testString))),
queryClauses
@@ -341,7 +341,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSString>(.average(#keyPath(TestEntity1.testString))),
queryClauses
@@ -350,7 +350,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Data>(.average(#keyPath(TestEntity1.testData))),
queryClauses
@@ -359,7 +359,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSData>(.average(#keyPath(TestEntity1.testData))),
queryClauses
@@ -368,7 +368,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Date>(.average(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -377,7 +377,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDate>(.average(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -386,7 +386,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSManagedObjectID>(#keyPath(TestEntity1.testEntityID)),
queryClauses
@@ -410,7 +410,7 @@ class QueryTests: BaseTestDataTestCase {
]
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Bool>(.count(#keyPath(TestEntity1.testBoolean))),
queryClauses
@@ -420,7 +420,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int8>(.count(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -430,7 +430,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int16>(.count(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -440,7 +440,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int32>(.count(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -450,7 +450,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int64>(.count(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -460,7 +460,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int>(.count(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -470,7 +470,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Double>(.count(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -480,7 +480,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Float>(.count(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -490,7 +490,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSNumber>(.count(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -500,7 +500,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDecimalNumber>(.count(#keyPath(TestEntity1.testDecimal))),
queryClauses
@@ -509,7 +509,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, String>(.count(#keyPath(TestEntity1.testString))),
queryClauses
@@ -518,7 +518,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSString>(.count(#keyPath(TestEntity1.testString))),
queryClauses
@@ -527,7 +527,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Data>(.count(#keyPath(TestEntity1.testData))),
queryClauses
@@ -536,7 +536,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSData>(.count(#keyPath(TestEntity1.testData))),
queryClauses
@@ -545,7 +545,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Date>(.count(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -554,7 +554,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDate>(.count(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -563,7 +563,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSManagedObjectID>(.count(#keyPath(TestEntity1.testEntityID))),
queryClauses
@@ -587,7 +587,7 @@ class QueryTests: BaseTestDataTestCase {
]
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Bool>(.maximum(#keyPath(TestEntity1.testBoolean))),
queryClauses
@@ -597,7 +597,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int8>(.maximum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -607,7 +607,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int16>(.maximum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -617,7 +617,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int32>(.maximum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -627,7 +627,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int64>(.maximum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -637,7 +637,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int>(.maximum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -647,7 +647,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Double>(.maximum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -657,7 +657,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Float>(.maximum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -667,7 +667,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSNumber>(.maximum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -677,7 +677,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDecimalNumber>(.maximum(#keyPath(TestEntity1.testDecimal))),
queryClauses
@@ -687,7 +687,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, String>(.maximum(#keyPath(TestEntity1.testString))),
queryClauses
@@ -697,7 +697,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSString>(.maximum(#keyPath(TestEntity1.testString))),
queryClauses
@@ -707,7 +707,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Data>(.maximum(#keyPath(TestEntity1.testData))),
queryClauses
@@ -717,7 +717,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSData>(.maximum(#keyPath(TestEntity1.testData))),
queryClauses
@@ -727,7 +727,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Date>(.maximum(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -737,7 +737,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDate>(.maximum(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -747,7 +747,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSManagedObjectID>(.maximum(#keyPath(TestEntity1.testEntityID))),
queryClauses
@@ -771,7 +771,7 @@ class QueryTests: BaseTestDataTestCase {
]
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Bool>(.minimum(#keyPath(TestEntity1.testBoolean))),
queryClauses
@@ -781,7 +781,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int8>(.minimum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -791,7 +791,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int16>(.minimum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -801,7 +801,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int32>(.minimum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -811,7 +811,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int64>(.minimum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -821,7 +821,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int>(.minimum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -831,7 +831,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Double>(.minimum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -841,7 +841,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Float>(.minimum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -851,7 +851,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSNumber>(.minimum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -861,7 +861,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDecimalNumber>(.minimum(#keyPath(TestEntity1.testDecimal))),
queryClauses
@@ -871,7 +871,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, String>(.minimum(#keyPath(TestEntity1.testString))),
queryClauses
@@ -881,7 +881,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSString>(.minimum(#keyPath(TestEntity1.testString))),
queryClauses
@@ -891,7 +891,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Data>(.minimum(#keyPath(TestEntity1.testData))),
queryClauses
@@ -901,7 +901,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSData>(.minimum(#keyPath(TestEntity1.testData))),
queryClauses
@@ -911,7 +911,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Date>(.minimum(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -921,7 +921,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDate>(.minimum(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -931,7 +931,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSManagedObjectID>(.minimum(#keyPath(TestEntity1.testEntityID))),
queryClauses
@@ -955,7 +955,7 @@ class QueryTests: BaseTestDataTestCase {
]
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Bool>(.sum(#keyPath(TestEntity1.testBoolean))),
queryClauses
@@ -965,7 +965,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int8>(.sum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -975,7 +975,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int16>(.sum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -985,7 +985,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int32>(.sum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -995,7 +995,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int64>(.sum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -1005,7 +1005,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int>(.sum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -1015,7 +1015,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Double>(.sum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -1025,7 +1025,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Float>(.sum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -1035,7 +1035,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSNumber>(.sum(#keyPath(TestEntity1.testNumber))),
queryClauses
@@ -1045,7 +1045,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDecimalNumber>(.sum(#keyPath(TestEntity1.testDecimal))),
queryClauses
@@ -1055,7 +1055,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, String>(.sum(#keyPath(TestEntity1.testString))),
queryClauses
@@ -1064,7 +1064,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSString>(.sum(#keyPath(TestEntity1.testString))),
queryClauses
@@ -1073,7 +1073,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Data>(.sum(#keyPath(TestEntity1.testData))),
queryClauses
@@ -1082,7 +1082,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSData>(.sum(#keyPath(TestEntity1.testData))),
queryClauses
@@ -1091,7 +1091,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Date>(.sum(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -1100,7 +1100,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDate>(.sum(#keyPath(TestEntity1.testDate))),
queryClauses
@@ -1109,7 +1109,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSManagedObjectID>(.sum(#keyPath(TestEntity1.testEntityID))),
queryClauses
@@ -1133,7 +1133,7 @@ class QueryTests: BaseTestDataTestCase {
]
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Bool>(.objectID()),
queryClauses
@@ -1142,7 +1142,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int8>(.objectID()),
queryClauses
@@ -1151,7 +1151,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int16>(.objectID()),
queryClauses
@@ -1160,7 +1160,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int32>(.objectID()),
queryClauses
@@ -1169,7 +1169,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int64>(.objectID()),
queryClauses
@@ -1178,7 +1178,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Int>(.objectID()),
queryClauses
@@ -1187,7 +1187,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Double>(.objectID()),
queryClauses
@@ -1196,7 +1196,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Float>(.objectID()),
queryClauses
@@ -1205,7 +1205,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSNumber>(.objectID()),
queryClauses
@@ -1214,7 +1214,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDecimalNumber>(.objectID()),
queryClauses
@@ -1223,7 +1223,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, String>(.objectID()),
queryClauses
@@ -1232,7 +1232,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSString>(.objectID()),
queryClauses
@@ -1241,7 +1241,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Data>(.objectID()),
queryClauses
@@ -1250,7 +1250,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSData>(.objectID()),
queryClauses
@@ -1259,7 +1259,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, Date>(.objectID()),
queryClauses
@@ -1268,7 +1268,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSDate>(.objectID()),
queryClauses
@@ -1277,7 +1277,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let value = stack.queryValue(
let value = try stack.queryValue(
from,
Select<TestEntity1, NSManagedObjectID>(.objectID()),
queryClauses
@@ -1302,7 +1302,7 @@ class QueryTests: BaseTestDataTestCase {
]
do {
let values = stack.queryAttributes(
let values = try stack.queryAttributes(
from,
Select<TestEntity1, NSDictionary>(
#keyPath(TestEntity1.testBoolean),
@@ -1353,7 +1353,7 @@ class QueryTests: BaseTestDataTestCase {
let queryClauses: [QueryClause] = []
do {
let values = stack.queryAttributes(
let values = try stack.queryAttributes(
from,
Select<TestEntity1, NSDictionary>(
.sum(#keyPath(TestEntity1.testBoolean)),
@@ -1380,7 +1380,7 @@ class QueryTests: BaseTestDataTestCase {
}
do {
let values = stack.queryAttributes(
let values = try stack.queryAttributes(
from,
Select(
.sum(#keyPath(TestEntity1.testBoolean), as: "testSum"),

View File

@@ -69,9 +69,9 @@ final class TransactionTests: BaseTestCase {
self.checkExpectationsImmediately()
XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext)
@@ -84,14 +84,14 @@ final class TransactionTests: BaseTestCase {
do {
let updateExpectation = self.expectation(description: "update")
let hasChanges: Bool = try! stack.perform(
let hasChanges: Bool = try stack.perform(
synchronous: { (transaction) in
defer {
updateExpectation.fulfill()
}
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
// TODO: convert fetch methods to throwing methods
XCTFail()
try transaction.cancel()
@@ -107,9 +107,9 @@ final class TransactionTests: BaseTestCase {
self.checkExpectationsImmediately()
XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit")
@@ -128,7 +128,7 @@ final class TransactionTests: BaseTestCase {
deleteExpectation.fulfill()
}
let object = transaction.fetchOne(From<TestEntity1>())
let object = try transaction.fetchOne(From<TestEntity1>())
transaction.delete(object)
return transaction.hasChanges
}
@@ -141,9 +141,9 @@ final class TransactionTests: BaseTestCase {
}
self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
let object = stack.fetchOne(From<TestEntity1>())
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNil(object)
}
}
@@ -184,10 +184,10 @@ final class TransactionTests: BaseTestCase {
}
self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = stack.fetchOne(From<TestEntity1>("Config1"))
let object = try stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
@@ -206,7 +206,7 @@ final class TransactionTests: BaseTestCase {
updateExpectation.fulfill()
}
guard let object = transaction.fetchOne(From<TestEntity1>("Config1")) else {
guard let object = try transaction.fetchOne(From<TestEntity1>("Config1")) else {
XCTFail()
try transaction.cancel()
@@ -226,10 +226,10 @@ final class TransactionTests: BaseTestCase {
}
self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = stack.fetchOne(From<TestEntity1>("Config1"))
let object = try stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit")
@@ -248,7 +248,7 @@ final class TransactionTests: BaseTestCase {
deleteExpectation.fulfill()
}
let object = transaction.fetchOne(From<TestEntity1>("Config1"))
let object = try transaction.fetchOne(From<TestEntity1>("Config1"))
transaction.delete(object)
return transaction.hasChanges
@@ -262,8 +262,8 @@ final class TransactionTests: BaseTestCase {
}
self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 0)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
}
}
}
@@ -294,9 +294,9 @@ final class TransactionTests: BaseTestCase {
)
self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
let object = stack.fetchOne(From<TestEntity1>())
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNil(object)
}
let testDate = Date()
@@ -329,7 +329,7 @@ final class TransactionTests: BaseTestCase {
updateDiscardExpectation.fulfill()
}
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail()
try transaction.cancel()
@@ -343,9 +343,9 @@ final class TransactionTests: BaseTestCase {
)
self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
@@ -362,7 +362,7 @@ final class TransactionTests: BaseTestCase {
deleteDiscardExpectation.fulfill()
}
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail()
try transaction.cancel()
@@ -374,9 +374,9 @@ final class TransactionTests: BaseTestCase {
)
self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
@@ -520,19 +520,26 @@ final class TransactionTests: BaseTestCase {
success: { (hasChanges) in
XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
createExpectation.fulfill()
do {
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
createExpectation.fulfill()
}
catch {
XCTFail()
}
},
failure: { _ in
@@ -546,7 +553,7 @@ final class TransactionTests: BaseTestCase {
stack.perform(
asynchronous: { (transaction) -> Bool in
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail()
try transaction.cancel()
@@ -560,16 +567,23 @@ final class TransactionTests: BaseTestCase {
success: { (hasChanges) in
XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit")
XCTAssertEqual(object?.testNumber, 200)
XCTAssertEqual(object?.testDate, Date.distantFuture)
updateExpectation.fulfill()
do {
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit")
XCTAssertEqual(object?.testNumber, 200)
XCTAssertEqual(object?.testDate, Date.distantFuture)
updateExpectation.fulfill()
}
catch {
XCTFail()
}
},
failure: { _ in
@@ -583,7 +597,7 @@ final class TransactionTests: BaseTestCase {
stack.perform(
asynchronous: { (transaction) -> Bool in
let object = transaction.fetchOne(From<TestEntity1>())
let object = try transaction.fetchOne(From<TestEntity1>())
transaction.delete(object)
return transaction.hasChanges
@@ -591,12 +605,19 @@ final class TransactionTests: BaseTestCase {
success: { (hasChanges) in
XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0)
let object = stack.fetchOne(From<TestEntity1>())
XCTAssertNil(object)
deleteExpectation.fulfill()
do {
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNil(object)
deleteExpectation.fulfill()
}
catch {
XCTFail()
}
},
failure: { _ in
@@ -631,17 +652,24 @@ final class TransactionTests: BaseTestCase {
success: { (hasChanges) in
XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
createExpectation.fulfill()
do {
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = try stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
createExpectation.fulfill()
}
catch {
XCTFail()
}
},
failure: { _ in
@@ -655,7 +683,7 @@ final class TransactionTests: BaseTestCase {
stack.perform(
asynchronous: { (transaction) -> Bool in
guard let object = transaction.fetchOne(From<TestEntity1>("Config1")) else {
guard let object = try transaction.fetchOne(From<TestEntity1>("Config1")) else {
XCTFail()
try transaction.cancel()
@@ -669,17 +697,24 @@ final class TransactionTests: BaseTestCase {
success: { (hasChanges) in
XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit")
XCTAssertEqual(object?.testNumber, 200)
XCTAssertEqual(object?.testDate, Date.distantFuture)
updateExpectation.fulfill()
do {
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = try stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit")
XCTAssertEqual(object?.testNumber, 200)
XCTAssertEqual(object?.testDate, Date.distantFuture)
updateExpectation.fulfill()
}
catch {
XCTFail()
}
},
failure: { _ in
@@ -693,7 +728,7 @@ final class TransactionTests: BaseTestCase {
stack.perform(
asynchronous: { (transaction) -> Bool in
let object = transaction.fetchOne(From<TestEntity1>("Config1"))
let object = try transaction.fetchOne(From<TestEntity1>("Config1"))
transaction.delete(object)
return transaction.hasChanges
@@ -701,11 +736,21 @@ final class TransactionTests: BaseTestCase {
success: { (hasChanges) in
XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 0)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
deleteExpectation.fulfill()
do {
let configCount = try stack.fetchCount(From<TestEntity1>("Config1"))
XCTAssertEqual(configCount, 0)
let defaultCount = try stack.fetchCount(From<TestEntity1>(nil))
XCTAssertEqual(defaultCount, 0)
deleteExpectation.fulfill()
}
catch {
XCTFail()
}
},
failure: { _ in
@@ -754,8 +799,8 @@ final class TransactionTests: BaseTestCase {
stack.perform(
asynchronous: { (transaction) -> Bool in
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(transaction.fetchOne(From<TestEntity1>()))
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(try transaction.fetchOne(From<TestEntity1>()))
let object = transaction.create(Into<TestEntity1>())
object.testEntityID = NSNumber(value: 1)
@@ -782,7 +827,7 @@ final class TransactionTests: BaseTestCase {
stack.perform(
asynchronous: { (transaction) -> Void in
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail()
return
@@ -811,9 +856,9 @@ final class TransactionTests: BaseTestCase {
stack.perform(
asynchronous: { (transaction) -> Void in
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail()
try transaction.cancel()
@@ -835,15 +880,22 @@ final class TransactionTests: BaseTestCase {
failure: { (error) in
XCTAssertEqual(error, CoreStoreError.userCancelled)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
deleteDiscardExpectation.fulfill()
do {
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
deleteDiscardExpectation.fulfill()
}
catch {
XCTFail()
}
}
)
}
@@ -878,9 +930,9 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext)
@@ -897,7 +949,7 @@ final class TransactionTests: BaseTestCase {
}
do {
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail()
return
@@ -911,9 +963,9 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
let object = stack.fetchOne(From<TestEntity1>())
let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit")
@@ -927,7 +979,7 @@ final class TransactionTests: BaseTestCase {
}
do {
let object = transaction.fetchOne(From<TestEntity1>())
let object = try transaction.fetchOne(From<TestEntity1>())
transaction.delete(object)
do {
@@ -935,8 +987,8 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(stack.fetchOne(From<TestEntity1>()))
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(try stack.fetchOne(From<TestEntity1>()))
}
catch {
@@ -967,10 +1019,10 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = stack.fetchOne(From<TestEntity1>("Config1"))
let object = try stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
@@ -984,7 +1036,7 @@ final class TransactionTests: BaseTestCase {
}
do {
guard let object = transaction.fetchOne(From<TestEntity1>("Config1")) else {
guard let object = try transaction.fetchOne(From<TestEntity1>("Config1")) else {
XCTFail()
return
@@ -998,10 +1050,10 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = stack.fetchOne(From<TestEntity1>("Config1"))
let object = try stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit")
@@ -1015,7 +1067,7 @@ final class TransactionTests: BaseTestCase {
}
do {
let object = transaction.fetchOne(From<TestEntity1>("Config1"))
let object = try transaction.fetchOne(From<TestEntity1>("Config1"))
transaction.delete(object)
do {
@@ -1023,8 +1075,8 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 0)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
}
catch {
@@ -1050,11 +1102,11 @@ final class TransactionTests: BaseTestCase {
transaction.rollback()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(transaction.fetchOne(From<TestEntity1>()))
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(try transaction.fetchOne(From<TestEntity1>()))
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(stack.fetchOne(From<TestEntity1>()))
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(try stack.fetchOne(From<TestEntity1>()))
}
let testDate = Date()
@@ -1079,7 +1131,7 @@ final class TransactionTests: BaseTestCase {
do {
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail()
return
@@ -1090,8 +1142,8 @@ final class TransactionTests: BaseTestCase {
transaction.rollback()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1)
if let object = transaction.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
if let object = try transaction.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(object.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object.testString, "string1")
@@ -1103,8 +1155,8 @@ final class TransactionTests: BaseTestCase {
XCTFail()
}
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
if let object = stack.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
if let object = try stack.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(object.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object.testString, "string1")
@@ -1119,7 +1171,7 @@ final class TransactionTests: BaseTestCase {
do {
guard let object = transaction.fetchOne(From<TestEntity1>()) else {
guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail()
return
@@ -1128,8 +1180,8 @@ final class TransactionTests: BaseTestCase {
transaction.rollback()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1)
if let object = transaction.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
if let object = try transaction.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(object.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object.testString, "string1")
@@ -1141,8 +1193,8 @@ final class TransactionTests: BaseTestCase {
XCTFail()
}
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1)
if let object = stack.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
if let object = try stack.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(object.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object.testString, "string1")

View File

@@ -151,7 +151,7 @@ public extension BaseDataTransaction {
return nil
}
if let object = self.fetchOne(From(entityType), Where<D>(uniqueIDKeyPath, isEqualTo: uniqueIDValue)) {
if let object = try self.fetchOne(From(entityType), Where<D>(uniqueIDKeyPath, isEqualTo: uniqueIDValue)) {
guard entityType.shouldUpdate(from: source, in: self) else {
@@ -215,7 +215,8 @@ public extension BaseDataTransaction {
importSourceByID = try autoreleasepool { try preProcess(importSourceByID) }
var existingObjectsByID = Dictionary<D.UniqueIDType, D>()
self.fetchAll(From(entityType), Where<D>(entityType.uniqueIDKeyPath, isMemberOf: sortedIDs))?
try self
.fetchAll(From(entityType), Where<D>(entityType.uniqueIDKeyPath, isMemberOf: sortedIDs))
.forEach { existingObjectsByID[$0.uniqueIDValue] = $0 }
var processedObjectIDs = Set<D.UniqueIDType>()

View File

@@ -39,13 +39,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- returns: the number of `DynamicObject`s deleted
*/
@discardableResult
public func deleteAll<D>(_ from: From<D>, _ deleteClauses: DeleteClause...) -> Int? {
public func deleteAll<D>(_ from: From<D>, _ deleteClauses: DeleteClause...) throws -> Int {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to delete from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.deleteAll(from, deleteClauses)
return try self.context.deleteAll(from, deleteClauses)
}
/**
@@ -56,13 +56,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- returns: the number of `DynamicObject`s deleted
*/
@discardableResult
public func deleteAll<D>(_ from: From<D>, _ deleteClauses: [DeleteClause]) -> Int? {
public func deleteAll<D>(_ from: From<D>, _ deleteClauses: [DeleteClause]) throws -> Int {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to delete from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.deleteAll(from, deleteClauses)
return try self.context.deleteAll(from, deleteClauses)
}
/**
@@ -74,14 +74,14 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- returns: the number of `DynamicObject`s deleted
*/
@discardableResult
public func deleteAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
public func deleteAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to delete from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.deleteAll(clauseChain.from, clauseChain.fetchClauses)
return try self.context.deleteAll(clauseChain.from, clauseChain.fetchClauses)
}
@@ -136,15 +136,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D? {
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchOne(from, fetchClauses)
return try self.context.fetchOne(from, fetchClauses)
}
/**
@@ -152,15 +153,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D? {
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchOne(from, fetchClauses)
return try self.context.fetchOne(from, fetchClauses)
}
/**
@@ -173,15 +175,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchOne(clauseChain)
return try self.context.fetchOne(clauseChain)
}
/**
@@ -189,15 +192,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]? {
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchAll(from, fetchClauses)
return try self.context.fetchAll(from, fetchClauses)
}
/**
@@ -205,15 +209,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]? {
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchAll(from, fetchClauses)
return try self.context.fetchAll(from, fetchClauses)
}
/**
@@ -226,15 +231,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]? {
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchAll(clauseChain)
return try self.context.fetchAll(clauseChain)
}
/**
@@ -242,15 +248,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int? {
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchCount(from, fetchClauses)
return try self.context.fetchCount(from, fetchClauses)
}
/**
@@ -258,15 +265,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int? {
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchCount(from, fetchClauses)
return try self.context.fetchCount(from, fetchClauses)
}
/**
@@ -279,15 +287,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchCount(clauseChain)
return try self.context.fetchCount(clauseChain)
}
/**
@@ -295,15 +304,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchObjectID(from, fetchClauses)
return try self.context.fetchObjectID(from, fetchClauses)
}
/**
@@ -311,15 +321,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchObjectID(from, fetchClauses)
return try self.context.fetchObjectID(from, fetchClauses)
}
/**
@@ -332,15 +343,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchObjectID(clauseChain)
return try self.context.fetchObjectID(clauseChain)
}
/**
@@ -348,15 +360,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchObjectIDs(from, fetchClauses)
return try self.context.fetchObjectIDs(from, fetchClauses)
}
/**
@@ -364,15 +377,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchObjectIDs(from, fetchClauses)
return try self.context.fetchObjectIDs(from, fetchClauses)
}
/**
@@ -385,15 +399,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.fetchObjectIDs(clauseChain)
return try self.context.fetchObjectIDs(clauseChain)
}
@@ -407,15 +422,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U? {
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.queryValue(from, selectClause, queryClauses)
return try self.context.queryValue(from, selectClause, queryClauses)
}
/**
@@ -426,15 +442,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U? {
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.queryValue(from, selectClause, queryClauses)
return try self.context.queryValue(from, selectClause, queryClauses)
}
/**
@@ -449,15 +466,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
- returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType {
public func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.queryValue(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
return try self.context.queryValue(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
}
/**
@@ -469,14 +487,15 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.queryAttributes(from, selectClause, queryClauses)
return try self.context.queryAttributes(from, selectClause, queryClauses)
}
/**
@@ -488,14 +507,15 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.queryAttributes(from, selectClause, queryClauses)
return try self.context.queryAttributes(from, selectClause, queryClauses)
}
/**
@@ -520,14 +540,15 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
```
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request.
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary {
public func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary {
CoreStore.assert(
self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.context.queryAttributes(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
return try self.context.queryAttributes(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
}

View File

@@ -93,7 +93,8 @@ public extension CSBaseDataTransaction {
self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.swiftTransaction.context.fetchOne(from, fetchClauses)
return (try? self.swiftTransaction.context.fetchOne(from, fetchClauses))?
.flatMap({ $0 })
}
/**
@@ -110,7 +111,8 @@ public extension CSBaseDataTransaction {
self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.swiftTransaction.context.fetchAll(from, fetchClauses)
return (try? self.swiftTransaction.context.fetchAll(from, fetchClauses))
.flatMap({ $0 })
}
/**
@@ -127,9 +129,8 @@ public extension CSBaseDataTransaction {
self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.swiftTransaction.context
.fetchCount(from, fetchClauses)
.flatMap { NSNumber(value: $0) }
return (try? self.swiftTransaction.context.fetchCount(from, fetchClauses))
.flatMap({ NSNumber(value: $0) })
}
/**
@@ -146,7 +147,8 @@ public extension CSBaseDataTransaction {
self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
)
return self.swiftTransaction.context.fetchObjectID(from, fetchClauses)
return (try? self.swiftTransaction.context.fetchObjectID(from, fetchClauses))
.flatMap({ $0 })
}
/**
@@ -166,7 +168,8 @@ public extension CSBaseDataTransaction {
self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.swiftTransaction.context.queryValue(from, selectClause, queryClauses)
return (try? self.swiftTransaction.context.queryValue(from, selectClause, queryClauses))
.flatMap({ $0 })
}
/**
@@ -186,6 +189,7 @@ public extension CSBaseDataTransaction {
self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue."
)
return self.swiftTransaction.context.queryAttributes(from, selectClause, queryClauses)
return (try? self.swiftTransaction.context.queryAttributes(from, selectClause, queryClauses))
.flatMap({ $0 })
}
}

View File

@@ -93,7 +93,8 @@ public extension CSDataStack {
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchOne(from, fetchClauses)
return (try? self.bridgeToSwift.mainContext.fetchOne(from, fetchClauses))?
.flatMap({ $0 })
}
/**
@@ -110,7 +111,8 @@ public extension CSDataStack {
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchAll(from, fetchClauses)
return (try? self.bridgeToSwift.mainContext.fetchAll(from, fetchClauses))
.flatMap({ $0 })
}
/**
@@ -127,9 +129,8 @@ public extension CSDataStack {
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext
.fetchCount(from, fetchClauses)
.flatMap { NSNumber(value: $0) }
return (try? self.bridgeToSwift.mainContext.fetchCount(from, fetchClauses))
.flatMap({ NSNumber(value: $0) })
}
/**
@@ -146,7 +147,8 @@ public extension CSDataStack {
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchObjectID(from, fetchClauses)
return (try? self.bridgeToSwift.mainContext.fetchObjectID(from, fetchClauses))?
.flatMap({ $0 })
}
/**
@@ -163,7 +165,8 @@ public extension CSDataStack {
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.fetchObjectIDs(from, fetchClauses)
return (try? self.bridgeToSwift.mainContext.fetchObjectIDs(from, fetchClauses))
.flatMap({ $0 })
}
/**
@@ -183,7 +186,8 @@ public extension CSDataStack {
Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.queryValue(from, selectClause, queryClauses)
return (try? self.bridgeToSwift.mainContext.queryValue(from, selectClause, queryClauses))
.flatMap({ $0 })
}
/**
@@ -203,6 +207,7 @@ public extension CSDataStack {
Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.bridgeToSwift.mainContext.queryAttributes(from, selectClause, queryClauses)
return (try? self.bridgeToSwift.mainContext.queryAttributes(from, selectClause, queryClauses))
.flatMap({ $0 })
}
}

View File

@@ -247,6 +247,14 @@ extension CoreStoreError: CoreStoreSwiftType, _ObjectiveCBridgeableError {
case .userCancelled:
self = .userCancelled
case .persistentStoreNotFound:
guard let entity = info["entity"] as? DynamicObject.Type else {
self = .unknown
return
}
self = .persistentStoreNotFound(entity: entity)
}
}
}

View File

@@ -132,7 +132,7 @@ public final class CSListMonitor: NSObject {
@objc
public func hasObjectsInSection(_ section: Int) -> Bool {
return self.bridgeToSwift.hasObjectsInSection(section)
return self.bridgeToSwift.hasObjects(in: section)
}
/**
@@ -155,7 +155,7 @@ public final class CSListMonitor: NSObject {
@objc
public func objectsInSection(_ section: Int) -> [NSManagedObject] {
return self.bridgeToSwift.objectsInSection(section)
return self.bridgeToSwift.objects(in: section)
}
/**
@@ -167,7 +167,7 @@ public final class CSListMonitor: NSObject {
@objc
public func objectsInSafeSection(safeSectionIndex section: Int) -> [NSManagedObject]? {
return self.bridgeToSwift.objectsInSection(safeSectionIndex: section)
return self.bridgeToSwift.objects(safelyIn: section)
}
/**
@@ -201,7 +201,7 @@ public final class CSListMonitor: NSObject {
@objc
public func numberOfObjectsInSection(_ section: Int) -> Int {
return self.bridgeToSwift.numberOfObjectsInSection(section)
return self.bridgeToSwift.numberOfObjects(in: section)
}
/**
@@ -214,7 +214,7 @@ public final class CSListMonitor: NSObject {
public func numberOfObjectsInSafeSection(safeSectionIndex section: Int) -> NSNumber? {
return self.bridgeToSwift
.numberOfObjectsInSection(safeSectionIndex: section)
.numberOfObjects(safelyIn: section)
.flatMap { NSNumber(value: $0) }
}
@@ -227,7 +227,7 @@ public final class CSListMonitor: NSObject {
@objc
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
return self.bridgeToSwift.sectionInfoAtIndex(section)
return self.bridgeToSwift.sectionInfo(at: section)
}
/**
@@ -239,7 +239,7 @@ public final class CSListMonitor: NSObject {
@objc
public func sectionInfoAtSafeSectionIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? {
return self.bridgeToSwift.sectionInfoAtIndex(safeSectionIndex: section)
return self.bridgeToSwift.sectionInfo(safelyAt: section)
}
/**
@@ -263,7 +263,7 @@ public final class CSListMonitor: NSObject {
@objc
public func targetSectionForSectionIndexTitle(title: String, index: Int) -> Int {
return self.bridgeToSwift.targetSectionForSectionIndex(title: title, index: index)
return self.bridgeToSwift.targetSection(forSectionIndexTitle: title, at: index)
}
/**
@@ -287,7 +287,7 @@ public final class CSListMonitor: NSObject {
public func indexOf(_ object: NSManagedObject) -> NSNumber? {
return self.bridgeToSwift
.indexOf(object)
.index(of: object)
.flatMap { NSNumber(value: $0) }
}
@@ -300,7 +300,7 @@ public final class CSListMonitor: NSObject {
@objc
public func indexPathOf(_ object: NSManagedObject) -> IndexPath? {
return self.bridgeToSwift.indexPathOf(object)
return self.bridgeToSwift.indexPath(of: object)
}

View File

@@ -152,6 +152,10 @@ extension CoreStoreError: CustomDebugStringConvertible, CoreStoreDebugStringConv
case .userCancelled:
firstLine = ".userCancelled"
case .persistentStoreNotFound(let entity):
firstLine = ".persistentStoreNotFound"
info.append(("entity", entity))
}
return createFormattedString(

View File

@@ -113,7 +113,7 @@ public extension CoreStore {
```
CoreStore.monitorList(
{ (monitor) in
createAsynchronously: { (monitor) in
self.monitor = monitor
},
From<MyPersonEntity>()
@@ -123,7 +123,6 @@ public extension CoreStore {
```
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
*/
public static func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
@@ -212,7 +211,7 @@ public extension CoreStore {
Asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType` built from a chain of clauses.
```
CoreStore.monitorSectionedList(
{ (monitor) in
createAsynchronously: { (monitor) in
self.monitor = monitor
},
From<MyPersonEntity>()
@@ -221,8 +220,8 @@ public extension CoreStore {
.orderBy(.ascending(\.age))
)
```
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType`
*/
public static func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {

View File

@@ -80,11 +80,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D? {
public static func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
return self.defaultStack.fetchOne(from, fetchClauses)
return try self.defaultStack.fetchOne(from, fetchClauses)
}
/**
@@ -92,11 +93,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D? {
public static func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
return self.defaultStack.fetchOne(from, fetchClauses)
return try self.defaultStack.fetchOne(from, fetchClauses)
}
/**
@@ -109,11 +111,12 @@ public extension CoreStore {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
public static func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? {
return self.defaultStack.fetchOne(clauseChain)
return try self.defaultStack.fetchOne(clauseChain)
}
/**
@@ -121,11 +124,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]? {
public static func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
return self.defaultStack.fetchAll(from, fetchClauses)
return try self.defaultStack.fetchAll(from, fetchClauses)
}
/**
@@ -133,11 +137,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]? {
public static func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
return self.defaultStack.fetchAll(from, fetchClauses)
return try self.defaultStack.fetchAll(from, fetchClauses)
}
/**
@@ -150,11 +155,12 @@ public extension CoreStore {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]? {
public static func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
return self.defaultStack.fetchAll(clauseChain)
return try self.defaultStack.fetchAll(clauseChain)
}
/**
@@ -162,11 +168,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int? {
public static func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
return self.defaultStack.fetchCount(from, fetchClauses)
return try self.defaultStack.fetchCount(from, fetchClauses)
}
/**
@@ -174,11 +181,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int? {
public static func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
return self.defaultStack.fetchCount(from, fetchClauses)
return try self.defaultStack.fetchCount(from, fetchClauses)
}
/**
@@ -191,11 +199,12 @@ public extension CoreStore {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
public static func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
return self.defaultStack.fetchCount(clauseChain)
return try self.defaultStack.fetchCount(clauseChain)
}
/**
@@ -203,11 +212,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
public static func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
return self.defaultStack.fetchObjectID(from, fetchClauses)
return try self.defaultStack.fetchObjectID(from, fetchClauses)
}
/**
@@ -215,11 +225,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
public static func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
return self.defaultStack.fetchObjectID(from, fetchClauses)
return try self.defaultStack.fetchObjectID(from, fetchClauses)
}
/**
@@ -232,11 +243,12 @@ public extension CoreStore {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
public static func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
return self.defaultStack.fetchObjectID(clauseChain)
return try self.defaultStack.fetchObjectID(clauseChain)
}
/**
@@ -244,11 +256,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
public static func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
return try self.defaultStack.fetchObjectIDs(from, fetchClauses)
}
/**
@@ -256,11 +269,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
public static func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
return try self.defaultStack.fetchObjectIDs(from, fetchClauses)
}
/**
@@ -273,11 +287,12 @@ public extension CoreStore {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
public static func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
return self.defaultStack.fetchObjectIDs(clauseChain)
return try self.defaultStack.fetchObjectIDs(clauseChain)
}
/**
@@ -288,11 +303,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U? {
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
return self.defaultStack.queryValue(from, selectClause, queryClauses)
return try self.defaultStack.queryValue(from, selectClause, queryClauses)
}
/**
@@ -303,11 +319,12 @@ public extension CoreStore {
- parameter from: a `From` clause indicating the entity type
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U? {
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
return self.defaultStack.queryValue(from, selectClause, queryClauses)
return try self.defaultStack.queryValue(from, selectClause, queryClauses)
}
/**
@@ -322,11 +339,12 @@ public extension CoreStore {
)
```
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
- returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType {
public static func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType {
return self.defaultStack.queryValue(clauseChain)
return try self.defaultStack.queryValue(clauseChain)
}
/**
@@ -338,10 +356,11 @@ public extension CoreStore {
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
return try self.defaultStack.queryAttributes(from, selectClause, queryClauses)
}
/**
@@ -353,10 +372,11 @@ public extension CoreStore {
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
return try self.defaultStack.queryAttributes(from, selectClause, queryClauses)
}
/**
@@ -381,9 +401,10 @@ public extension CoreStore {
```
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request.
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public static func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary {
public static func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary {
return self.defaultStack.queryAttributes(clauseChain)
return try self.defaultStack.queryAttributes(clauseChain)
}
}

View File

@@ -73,6 +73,11 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
The transaction was cancelled by the user.
*/
case userCancelled
/**
Attempted to perform a fetch but could not find any related persistent store.
*/
case persistentStoreNotFound(entity: DynamicObject.Type)
// MARK: CustomNSError
@@ -109,6 +114,9 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
case .userCancelled:
return CoreStoreErrorCode.userCancelled.rawValue
case .persistentStoreNotFound:
return CoreStoreErrorCode.persistentStoreNotFound.rawValue
}
}
@@ -154,6 +162,11 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
case .userCancelled:
return [:]
case .persistentStoreNotFound(let entity):
return [
"entity": entity
]
}
}
@@ -195,6 +208,9 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
case (.userCancelled, .userCancelled):
return true
case (.persistentStoreNotFound(let entity1), .persistentStoreNotFound(let entity2)):
return entity1 == entity2
default:
return false
@@ -233,6 +249,9 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
case .userError(let error):
hasher.combine(error as NSError)
case .persistentStoreNotFound(let entity):
hasher.combine(ObjectIdentifier(entity))
case .userCancelled:
break
}
@@ -303,6 +322,11 @@ public enum CoreStoreErrorCode: Int {
The transaction was cancelled by the user.
*/
case userCancelled
/**
Attempted to perform a fetch but could not find any related persistent store.
*/
case persistentStoreNotFound
}

View File

@@ -49,7 +49,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
@nonobjc
internal init<D>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<D>, sectionBy: SectionBy<D>? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) {
_ = from.applyToFetchRequest(
_ = try? from.applyToFetchRequest(
fetchRequest,
context: context,
applyAffectedStores: false
@@ -58,7 +58,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
self.reapplyAffectedStores = { fetchRequest, context in
return from.applyAffectedStoresForFetchedRequest(fetchRequest, context: context)
try from.applyAffectedStoresForFetchedRequest(fetchRequest, context: context)
}
super.init(
@@ -71,14 +71,8 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
@nonobjc
internal func performFetchFromSpecifiedStores() throws {
if !self.reapplyAffectedStores(self.fetchRequest, self.managedObjectContext) {
CoreStore.log(
.warning,
message: "Attempted to perform a fetch on an \(cs_typeName(self)) but could not find any persistent store for the entity \(cs_typeName(self.fetchRequest.entityName))"
)
}
try self.reapplyAffectedStores(self.fetchRequest, self.managedObjectContext)
try self.performFetch()
}
@@ -97,5 +91,5 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
// MARK: Private
@nonobjc
private let reapplyAffectedStores: (_ fetchRequest: NSFetchRequest<NSManagedObject>, _ context: NSManagedObjectContext) -> Bool
private let reapplyAffectedStores: (_ fetchRequest: NSFetchRequest<NSManagedObject>, _ context: NSManagedObjectContext) throws -> Void
}

View File

@@ -152,7 +152,7 @@ public extension DataStack {
```
dataStack.monitorList(
{ (monitor) in
createAsynchronously: { (monitor) in
self.monitor = monitor
},
From<MyPersonEntity>()
@@ -162,7 +162,6 @@ public extension DataStack {
```
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
*/
public func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
@@ -288,7 +287,7 @@ public extension DataStack {
Asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType` built from a chain of clauses.
```
dataStack.monitorSectionedList(
{ (monitor) in
createAsynchronously: { (monitor) in
self.monitor = monitor
},
From<MyPersonEntity>()
@@ -297,8 +296,8 @@ public extension DataStack {
.orderBy(.ascending(\.age))
)
```
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType`
*/
public func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {

View File

@@ -82,15 +82,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D? {
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchOne(from, fetchClauses)
return try self.mainContext.fetchOne(from, fetchClauses)
}
/**
@@ -98,15 +99,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D? {
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchOne(from, fetchClauses)
return try self.mainContext.fetchOne(from, fetchClauses)
}
/**
@@ -119,15 +121,16 @@ extension DataStack: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchOne(clauseChain)
return try self.mainContext.fetchOne(clauseChain)
}
/**
@@ -135,15 +138,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]? {
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchAll(from, fetchClauses)
return try self.mainContext.fetchAll(from, fetchClauses)
}
/**
@@ -151,15 +155,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]? {
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchAll(from, fetchClauses)
return try self.mainContext.fetchAll(from, fetchClauses)
}
/**
@@ -172,15 +177,16 @@ extension DataStack: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]? {
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchAll(clauseChain)
return try self.mainContext.fetchAll(clauseChain)
}
/**
@@ -188,15 +194,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int? {
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchCount(from, fetchClauses)
return try self.mainContext.fetchCount(from, fetchClauses)
}
/**
@@ -204,15 +211,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int? {
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchCount(from, fetchClauses)
return try self.mainContext.fetchCount(from, fetchClauses)
}
/**
@@ -225,15 +233,16 @@ extension DataStack: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchCount(clauseChain)
return try self.mainContext.fetchCount(clauseChain)
}
/**
@@ -241,15 +250,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchObjectID(from, fetchClauses)
return try self.mainContext.fetchObjectID(from, fetchClauses)
}
/**
@@ -257,15 +267,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchObjectID(from, fetchClauses)
return try self.mainContext.fetchObjectID(from, fetchClauses)
}
/**
@@ -278,15 +289,16 @@ extension DataStack: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchObjectID(clauseChain)
return try self.mainContext.fetchObjectID(clauseChain)
}
/**
@@ -294,15 +306,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchObjectIDs(from, fetchClauses)
return try self.mainContext.fetchObjectIDs(from, fetchClauses)
}
/**
@@ -310,15 +323,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchObjectIDs(from, fetchClauses)
return try self.mainContext.fetchObjectIDs(from, fetchClauses)
}
/**
@@ -331,15 +345,16 @@ extension DataStack: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
CoreStore.assert(
Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.fetchObjectIDs(clauseChain)
return try self.mainContext.fetchObjectIDs(clauseChain)
}
@@ -353,15 +368,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U? {
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
CoreStore.assert(
Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.queryValue(from, selectClause, queryClauses)
return try self.mainContext.queryValue(from, selectClause, queryClauses)
}
/**
@@ -372,15 +388,16 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter from: a `From` clause indicating the entity type
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U? {
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
CoreStore.assert(
Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.queryValue(from, selectClause, queryClauses)
return try self.mainContext.queryValue(from, selectClause, queryClauses)
}
/**
@@ -395,15 +412,16 @@ extension DataStack: FetchableSource, QueryableSource {
)
```
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
- returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType {
public func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType {
CoreStore.assert(
Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.queryValue(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
return try self.mainContext.queryValue(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
}
/**
@@ -415,14 +433,15 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
CoreStore.assert(
Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.queryAttributes(from, selectClause, queryClauses)
return try self.mainContext.queryAttributes(from, selectClause, queryClauses)
}
/**
@@ -434,14 +453,15 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
CoreStore.assert(
Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.queryAttributes(from, selectClause, queryClauses)
return try self.mainContext.queryAttributes(from, selectClause, queryClauses)
}
/**
@@ -466,14 +486,15 @@ extension DataStack: FetchableSource, QueryableSource {
```
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request.
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary {
public func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary {
CoreStore.assert(
Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread."
)
return self.mainContext.queryAttributes(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
return try self.mainContext.queryAttributes(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
}

View File

@@ -71,18 +71,20 @@ public protocol FetchableSource: class {
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D?
func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D?
/**
Fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D?
func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D?
/**
Fetches the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
@@ -94,27 +96,30 @@ public protocol FetchableSource: class {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType?
func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType?
/**
Fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]?
func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D]
/**
Fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]?
func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D]
/**
Fetches all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
@@ -126,27 +131,30 @@ public protocol FetchableSource: class {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]?
func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType]
/**
Fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int?
func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int
/**
Fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int?
func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int
/**
Fetches the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
@@ -158,27 +166,30 @@ public protocol FetchableSource: class {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int?
func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int
/**
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID?
func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID?
/**
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID?
func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID?
/**
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
@@ -190,27 +201,30 @@ public protocol FetchableSource: class {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID?
func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID?
/**
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]?
func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID]
/**
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- parameter from: a `From` clause indicating the entity type
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]?
func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID]
/**
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
@@ -222,9 +236,10 @@ public protocol FetchableSource: class {
)
```
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]?
func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID]
/**
The internal `NSManagedObjectContext` managed by this `FetchableSource`. Using this context directly should typically be avoided, and is provided by CoreStore only for extremely specialized cases.

View File

@@ -139,29 +139,40 @@ public struct From<D: DynamicObject> {
self.findPersistentStores = findPersistentStores
}
internal func applyToFetchRequest<ResultType>(_ fetchRequest: NSFetchRequest<ResultType>, context: NSManagedObjectContext, applyAffectedStores: Bool = true) -> Bool {
internal func applyToFetchRequest<U>(_ fetchRequest: NSFetchRequest<U>, context: NSManagedObjectContext, applyAffectedStores: Bool = true) throws {
fetchRequest.entity = context.parentStack!.entityDescription(for: EntityIdentifier(self.entityClass))!
guard applyAffectedStores else {
return true
return
}
if self.applyAffectedStoresForFetchedRequest(fetchRequest, context: context) {
return true
do {
try self.applyAffectedStoresForFetchedRequest(fetchRequest, context: context)
}
catch let error as CoreStoreError {
CoreStore.log(
error,
"Attempted to perform a fetch but could not find any persistent store for the entity \(cs_typeName(fetchRequest.entityName))"
)
throw error
}
catch {
throw error
}
CoreStore.log(
.warning,
message: "Attempted to perform a fetch but could not find any persistent store for the entity \(cs_typeName(fetchRequest.entityName))"
)
return false
}
internal func applyAffectedStoresForFetchedRequest<U>(_ fetchRequest: NSFetchRequest<U>, context: NSManagedObjectContext) -> Bool {
internal func applyAffectedStoresForFetchedRequest<U>(_ fetchRequest: NSFetchRequest<U>, context: NSManagedObjectContext) throws {
let stores = self.findPersistentStores(context)
fetchRequest.affectedStores = stores
return stores?.isEmpty == false
if stores?.isEmpty == false {
return
}
throw CoreStoreError.persistentStoreNotFound(entity: self.entityClass)
}

View File

@@ -136,7 +136,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
*/
public subscript(safeSectionIndex sectionIndex: Int, safeItemIndex itemIndex: Int) -> ObjectType? {
guard let section = self.sectionInfoAtIndex(safeSectionIndex: sectionIndex) else {
guard let section = self.sectionInfo(safelyAt: sectionIndex) else {
return nil
}
@@ -202,9 +202,9 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
- parameter section: the section index. Using an index outside the valid range will return `false`.
- returns: `true` if at least one object in the specified section exists, `false` otherwise
*/
public func hasObjectsInSection(_ section: Int) -> Bool {
public func hasObjects(in section: Int) -> Bool {
return self.numberOfObjectsInSection(safeSectionIndex: section)! > 0
return self.numberOfObjects(safelyIn: section)! > 0
}
/**
@@ -241,9 +241,9 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
- parameter section: the section index. Using an index outside the valid range will raise an exception.
- returns: the number of objects in the specified section
*/
public func numberOfObjectsInSection(_ section: Int) -> Int {
public func numberOfObjects(in section: Int) -> Int {
return self.sectionInfoAtIndex(section).numberOfObjects
return self.sectionInfo(at: section).numberOfObjects
}
/**
@@ -252,9 +252,9 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
- parameter section: the section index. Using an index outside the valid range will return `nil`.
- returns: the number of objects in the specified section
*/
public func numberOfObjectsInSection(safeSectionIndex section: Int) -> Int? {
public func numberOfObjects(safelyIn section: Int) -> Int? {
return self.sectionInfoAtIndex(safeSectionIndex: section)?.numberOfObjects
return self.sectionInfo(safelyAt: section)?.numberOfObjects
}
/**
@@ -263,7 +263,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
- parameter section: the section index. Using an index outside the valid range will raise an exception.
- returns: the `NSFetchedResultsSectionInfo` for the specified section
*/
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
public func sectionInfo(at section: Int) -> NSFetchedResultsSectionInfo {
CoreStore.assert(
!self.isPendingRefetch || Thread.isMainThread,
@@ -278,7 +278,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
- parameter section: the section index. Using an index outside the valid range will return `nil`.
- returns: the `NSFetchedResultsSectionInfo` for the specified section, or `nil` if the section index is out of bounds.
*/
public func sectionInfoAtIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? {
public func sectionInfo(safelyAt section: Int) -> NSFetchedResultsSectionInfo? {
CoreStore.assert(
!self.isPendingRefetch || Thread.isMainThread,
@@ -312,17 +312,17 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
/**
Returns the target section for a specified "Section Index" title and index.
- parameter title: the title of the Section Index
- parameter index: the index of the Section Index
- parameter sectionIndexTitle: the title of the Section Index
- parameter sectionIndex: the index of the Section Index
- returns: the target section for the specified "Section Index" title and index.
*/
public func targetSectionForSectionIndex(title: String, index: Int) -> Int {
public func targetSection(forSectionIndexTitle sectionIndexTitle: String, at sectionIndex: Int) -> Int {
CoreStore.assert(
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.fetchedResultsController.section(forSectionIndexTitle: title, at: index)
return self.fetchedResultsController.section(forSectionIndexTitle: sectionIndexTitle, at: sectionIndex)
}
/**
@@ -345,7 +345,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
- parameter object: the `DynamicObject` to search the index of
- returns: the index of the `DynamicObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
*/
public func indexOf(_ object: ObjectType) -> Int? {
public func index(of object: ObjectType) -> Int? {
CoreStore.assert(
!self.isPendingRefetch || Thread.isMainThread,
@@ -364,7 +364,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
- parameter object: the `DynamicObject` to search the index of
- returns: the `IndexPath` of the `DynamicObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
*/
public func indexPathOf(_ object: ObjectType) -> IndexPath? {
public func indexPath(of object: ObjectType) -> IndexPath? {
CoreStore.assert(
!self.isPendingRefetch || Thread.isMainThread,
@@ -1164,6 +1164,57 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
try! self.fetchedResultsController.performFetchFromSpecifiedStores()
}
}
// MARK: Deprecated
@available(*, deprecated, renamed: "hasObjects(in:)")
public func hasObjectsInSection(_ section: Int) -> Bool {
return self.hasObjects(in: section)
}
@available(*, deprecated, renamed: "numberOfObjects(in:)")
public func numberOfObjectsInSection(_ section: Int) -> Int {
return self.numberOfObjects(in: section)
}
@available(*, deprecated, renamed: "numberOfObjects(safelyIn:)")
public func numberOfObjectsInSection(safeSectionIndex section: Int) -> Int? {
return self.numberOfObjects(safelyIn: section)
}
@available(*, deprecated, renamed: "sectionInfo(at:)")
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
return self.sectionInfo(at: section)
}
@available(*, deprecated, renamed: "sectionInfo(safelyAt:)")
public func sectionInfoAtIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? {
return self.sectionInfo(safelyAt: section)
}
@available(*, deprecated, renamed: "targetSection(forSectionIndexTitle:at:)")
public func targetSectionForSectionIndex(title: String, index: Int) -> Int {
return self.targetSection(forSectionIndexTitle: title, at: index)
}
@available(*, deprecated, renamed: "index(of:)")
public func indexOf(_ object: ObjectType) -> Int? {
return self.index(of: object)
}
@available(*, deprecated, renamed: "indexPath(of:)")
public func indexPathOf(_ object: ObjectType) -> IndexPath? {
return self.indexPath(of: object)
}
}
@@ -1192,9 +1243,9 @@ extension ListMonitor where ListMonitor.ObjectType: NSManagedObject {
- parameter section: the section index. Using an index outside the valid range will raise an exception.
- returns: all objects in the specified section
*/
public func objectsInSection(_ section: Int) -> [ObjectType] {
public func objects(in section: Int) -> [ObjectType] {
return (self.sectionInfoAtIndex(section).objects as! [ObjectType]?) ?? []
return (self.sectionInfo(at: section).objects as! [ObjectType]?) ?? []
}
/**
@@ -1203,9 +1254,24 @@ extension ListMonitor where ListMonitor.ObjectType: NSManagedObject {
- parameter section: the section index. Using an index outside the valid range will return `nil`.
- returns: all objects in the specified section
*/
public func objectsInSection(safeSectionIndex section: Int) -> [ObjectType]? {
public func objects(safelyIn section: Int) -> [ObjectType]? {
return self.sectionInfoAtIndex(safeSectionIndex: section)?.objects as! [ObjectType]?
return self.sectionInfo(safelyAt: section)?.objects as! [ObjectType]?
}
// MARK: Deprecated
@available(*, deprecated, renamed: "objects(in:)")
public func objectsInSection(_ section: Int) -> [ObjectType] {
return self.objects(in: section)
}
@available(*, deprecated, renamed: "objects(safelyIn:)")
public func objectsInSection(safeSectionIndex section: Int) -> [ObjectType]? {
return self.objects(safelyIn: section)
}
}
@@ -1236,9 +1302,9 @@ extension ListMonitor where ListMonitor.ObjectType: CoreStoreObject {
- parameter section: the section index. Using an index outside the valid range will raise an exception.
- returns: all objects in the specified section
*/
public func objectsInSection(_ section: Int) -> [ObjectType] {
public func objects(in section: Int) -> [ObjectType] {
return (self.sectionInfoAtIndex(section).objects ?? [])
return (self.sectionInfo(at: section).objects ?? [])
.map({ ObjectType.cs_fromRaw(object: $0 as! NSManagedObject) })
}
@@ -1248,11 +1314,26 @@ extension ListMonitor where ListMonitor.ObjectType: CoreStoreObject {
- parameter section: the section index. Using an index outside the valid range will return `nil`.
- returns: all objects in the specified section
*/
public func objectsInSection(safeSectionIndex section: Int) -> [ObjectType]? {
public func objects(safelyIn section: Int) -> [ObjectType]? {
return (self.sectionInfoAtIndex(safeSectionIndex: section)?.objects)?
return (self.sectionInfo(safelyAt: section)?.objects)?
.map({ ObjectType.cs_fromRaw(object: $0 as! NSManagedObject) })
}
// MARK: Deprecated
@available(*, deprecated, renamed: "objects(in:)")
public func objectsInSection(_ section: Int) -> [ObjectType] {
return self.objects(in: section)
}
@available(*, deprecated, renamed: "objects(safelyIn:)")
public func objectsInSection(safeSectionIndex section: Int) -> [ObjectType]? {
return self.objects(safelyIn: section)
}
}

View File

@@ -34,139 +34,107 @@ internal extension NSManagedObjectContext {
// MARK: Internal
@nonobjc
internal func fetchOne(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> NSManagedObject? {
internal func fetchOne(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> NSManagedObject? {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 1
fetchRequest.resultType = .managedObjectResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchOne(fetchRequest.dynamicCast())
return try self.fetchOne(fetchRequest.dynamicCast())
}
@nonobjc
internal func fetchAll<T: NSManagedObject>(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> [T]? {
internal func fetchAll<T: NSManagedObject>(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> [T] {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
fetchRequest.resultType = .managedObjectResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchAll(fetchRequest.dynamicCast())
return try self.fetchAll(fetchRequest.dynamicCast())
}
@nonobjc
internal func fetchCount(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> Int? {
internal func fetchCount(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> Int {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchCount(fetchRequest.dynamicCast())
return try self.fetchCount(fetchRequest.dynamicCast())
}
@nonobjc
internal func fetchObjectID(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
internal func fetchObjectID(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> NSManagedObjectID? {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 1
fetchRequest.resultType = .managedObjectIDResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchObjectID(fetchRequest.dynamicCast())
return try self.fetchObjectID(fetchRequest.dynamicCast())
}
@nonobjc
internal func fetchObjectIDs(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> [NSManagedObjectID]? {
internal func fetchObjectIDs(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> [NSManagedObjectID] {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
fetchRequest.resultType = .managedObjectIDResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchObjectIDs(fetchRequest.dynamicCast())
return try self.fetchObjectIDs(fetchRequest.dynamicCast())
}
@nonobjc
internal func deleteAll(_ from: CSFrom, _ deleteClauses: [CSDeleteClause]) -> Int? {
internal func deleteAll(_ from: CSFrom, _ deleteClauses: [CSDeleteClause]) throws -> Int {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
fetchRequest.resultType = .managedObjectResultType
fetchRequest.returnsObjectsAsFaults = true
fetchRequest.includesPropertyValues = false
deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.deleteAll(fetchRequest.dynamicCast())
return try self.deleteAll(fetchRequest.dynamicCast())
}
@nonobjc
internal func queryValue(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> Any? {
internal func queryValue(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) throws -> Any? {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
selectClause.applyToFetchRequest(fetchRequest)
queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.queryValue(selectClause.selectTerms, fetchRequest: fetchRequest.dynamicCast())
return try self.queryValue(selectClause.selectTerms, fetchRequest: fetchRequest.dynamicCast())
}
@nonobjc
internal func queryAttributes(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) -> [[String: Any]]? {
internal func queryAttributes(_ from: CSFrom, _ selectClause: CSSelect, _ queryClauses: [CSQueryClause]) throws -> [[String: Any]] {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
selectClause.applyToFetchRequest(fetchRequest)
queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.queryAttributes(fetchRequest.dynamicCast())
return try self.queryAttributes(fetchRequest.dynamicCast())
}
}

View File

@@ -101,152 +101,130 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
}
@nonobjc
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D? {
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
return self.fetchOne(from, fetchClauses)
return try self.fetchOne(from, fetchClauses)
}
@nonobjc
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D? {
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 1
fetchRequest.resultType = .managedObjectResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchOne(fetchRequest.dynamicCast()).flatMap(from.entityClass.cs_fromRaw)
return try self.fetchOne(fetchRequest.dynamicCast()).flatMap(from.entityClass.cs_fromRaw)
}
@nonobjc
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? {
return self.fetchOne(clauseChain.from, clauseChain.fetchClauses)
return try self.fetchOne(clauseChain.from, clauseChain.fetchClauses)
}
@nonobjc
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]? {
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
return self.fetchAll(from, fetchClauses)
return try self.fetchAll(from, fetchClauses)
}
@nonobjc
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]? {
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
fetchRequest.resultType = .managedObjectResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
let entityClass = from.entityClass
return self.fetchAll(fetchRequest.dynamicCast())?.map(entityClass.cs_fromRaw)
return try self.fetchAll(fetchRequest.dynamicCast()).map(entityClass.cs_fromRaw)
}
@nonobjc
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]? {
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
return self.fetchAll(clauseChain.from, clauseChain.fetchClauses)
return try self.fetchAll(clauseChain.from, clauseChain.fetchClauses)
}
@nonobjc
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int? {
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
return self.fetchCount(from, fetchClauses)
return try self.fetchCount(from, fetchClauses)
}
@nonobjc
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int? {
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
try from.applyToFetchRequest(fetchRequest, context: self)
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchCount(fetchRequest.dynamicCast())
return try self.fetchCount(fetchRequest.dynamicCast())
}
@nonobjc
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
return self.fetchCount(clauseChain.from, clauseChain.fetchClauses)
return try self.fetchCount(clauseChain.from, clauseChain.fetchClauses)
}
@nonobjc
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
return self.fetchObjectID(from, fetchClauses)
return try self.fetchObjectID(from, fetchClauses)
}
@nonobjc
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 1
fetchRequest.resultType = .managedObjectIDResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchObjectID(fetchRequest.dynamicCast())
return try self.fetchObjectID(fetchRequest.dynamicCast())
}
// TODO: docs
@nonobjc
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
return self.fetchObjectID(clauseChain.from, clauseChain.fetchClauses)
return try self.fetchObjectID(clauseChain.from, clauseChain.fetchClauses)
}
@nonobjc
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
return self.fetchObjectIDs(from, fetchClauses)
return try self.fetchObjectIDs(from, fetchClauses)
}
@nonobjc
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
fetchRequest.resultType = .managedObjectIDResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.fetchObjectIDs(fetchRequest.dynamicCast())
return try self.fetchObjectIDs(fetchRequest.dynamicCast())
}
// TODO: docs
@nonobjc
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
return self.fetchObjectIDs(clauseChain.from, clauseChain.fetchClauses)
return try self.fetchObjectIDs(clauseChain.from, clauseChain.fetchClauses)
}
@nonobjc
internal func fetchObjectIDs(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) -> [NSManagedObjectID]? {
internal func fetchObjectIDs(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) throws -> [NSManagedObjectID] {
var fetchResults: [NSManagedObjectID]?
var fetchError: Error?
@@ -261,77 +239,70 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
fetchError = error
}
}
if fetchResults == nil {
CoreStore.log(
CoreStoreError(fetchError),
"Failed executing fetch request."
)
return nil
if let fetchResults = fetchResults {
return fetchResults
}
return fetchResults
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
}
// MARK: QueryableSource
@nonobjc
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U? {
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
return self.queryValue(from, selectClause, queryClauses)
return try self.queryValue(from, selectClause, queryClauses)
}
@nonobjc
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U? {
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
selectClause.applyToFetchRequest(fetchRequest)
queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.queryValue(selectClause.selectTerms, fetchRequest: fetchRequest)
return try self.queryValue(selectClause.selectTerms, fetchRequest: fetchRequest)
}
@nonobjc
public func queryValue<B>(_ clauseChain: B) -> B.ResultType? where B: QueryChainableBuilderType, B.ResultType: QueryableAttributeType {
public func queryValue<B>(_ clauseChain: B) throws -> B.ResultType? where B: QueryChainableBuilderType, B.ResultType: QueryableAttributeType {
return self.queryValue(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
return try self.queryValue(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
}
@nonobjc
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
return self.queryAttributes(from, selectClause, queryClauses)
return try self.queryAttributes(from, selectClause, queryClauses)
}
@nonobjc
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
selectClause.applyToFetchRequest(fetchRequest)
queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.queryAttributes(fetchRequest)
return try self.queryAttributes(fetchRequest)
}
public func queryAttributes<B>(_ clauseChain: B) -> [[String : Any]]? where B : QueryChainableBuilderType, B.ResultType == NSDictionary {
public func queryAttributes<B>(_ clauseChain: B) throws -> [[String : Any]] where B : QueryChainableBuilderType, B.ResultType == NSDictionary {
return self.queryAttributes(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
return try self.queryAttributes(clauseChain.from, clauseChain.select, clauseChain.queryClauses)
}
@@ -347,22 +318,18 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
// MARK: Deleting
@nonobjc
internal func deleteAll<D>(_ from: From<D>, _ deleteClauses: [FetchClause]) -> Int? {
internal func deleteAll<D>(_ from: From<D>, _ deleteClauses: [FetchClause]) throws -> Int {
let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0
fetchRequest.resultType = .managedObjectResultType
fetchRequest.returnsObjectsAsFaults = true
fetchRequest.includesPropertyValues = false
deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else {
return nil
}
return self.deleteAll(fetchRequest.dynamicCast())
return try self.deleteAll(fetchRequest.dynamicCast())
}
@@ -383,7 +350,7 @@ internal extension NSManagedObjectContext {
// MARK: Fetching
@nonobjc
internal func fetchOne<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) -> D? {
internal func fetchOne<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) throws -> D? {
var fetchResults: [D]?
var fetchError: Error?
@@ -398,19 +365,20 @@ internal extension NSManagedObjectContext {
fetchError = error
}
}
if fetchResults == nil {
CoreStore.log(
CoreStoreError(fetchError),
"Failed executing fetch request."
)
return nil
if let fetchResults = fetchResults {
return fetchResults.first
}
return fetchResults?.first
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
}
@nonobjc
internal func fetchAll<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) -> [D]? {
internal func fetchAll<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) throws -> [D] {
var fetchResults: [D]?
var fetchError: Error?
@@ -425,19 +393,20 @@ internal extension NSManagedObjectContext {
fetchError = error
}
}
if fetchResults == nil {
CoreStore.log(
CoreStoreError(fetchError),
"Failed executing fetch request."
)
return nil
if let fetchResults = fetchResults {
return fetchResults
}
return fetchResults
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
}
@nonobjc
internal func fetchCount(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Int? {
internal func fetchCount(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) throws -> Int {
var count = 0
var countError: Error?
@@ -453,18 +422,19 @@ internal extension NSManagedObjectContext {
}
}
if count == NSNotFound {
let coreStoreError = CoreStoreError(countError)
CoreStore.log(
CoreStoreError(countError),
coreStoreError,
"Failed executing count request."
)
return nil
throw coreStoreError
}
return count
}
@nonobjc
internal func fetchObjectID(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) -> NSManagedObjectID? {
internal func fetchObjectID(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) throws -> NSManagedObjectID? {
var fetchResults: [NSManagedObjectID]?
var fetchError: Error?
@@ -479,22 +449,23 @@ internal extension NSManagedObjectContext {
fetchError = error
}
}
if fetchResults == nil {
CoreStore.log(
CoreStoreError(fetchError),
"Failed executing fetch request."
)
return nil
if let fetchResults = fetchResults {
return fetchResults.first
}
return fetchResults?.first
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
}
// MARK: Querying
@nonobjc
internal func queryValue<D, U: QueryableAttributeType>(_ selectTerms: [SelectTerm<D>], fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> U? {
internal func queryValue<D, U: QueryableAttributeType>(_ selectTerms: [SelectTerm<D>], fetchRequest: NSFetchRequest<NSFetchRequestResult>) throws -> U? {
var fetchResults: [Any]?
var fetchError: Error?
@@ -518,16 +489,16 @@ internal extension NSManagedObjectContext {
}
return nil
}
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
CoreStoreError(fetchError),
coreStoreError,
"Failed executing fetch request."
)
return nil
throw coreStoreError
}
@nonobjc
internal func queryValue<D>(_ selectTerms: [SelectTerm<D>], fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Any? {
internal func queryValue<D>(_ selectTerms: [SelectTerm<D>], fetchRequest: NSFetchRequest<NSFetchRequestResult>) throws -> Any? {
var fetchResults: [Any]?
var fetchError: Error?
@@ -551,16 +522,16 @@ internal extension NSManagedObjectContext {
}
return nil
}
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
CoreStoreError(fetchError),
coreStoreError,
"Failed executing fetch request."
)
return nil
throw coreStoreError
}
@nonobjc
internal func queryAttributes(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> [[String: Any]]? {
internal func queryAttributes(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) throws -> [[String: Any]] {
var fetchResults: [Any]?
var fetchError: Error?
@@ -579,19 +550,19 @@ internal extension NSManagedObjectContext {
return NSDictionary.cs_fromQueryResultsNativeType(fetchResults)
}
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
CoreStoreError(fetchError),
coreStoreError,
"Failed executing fetch request."
)
return nil
throw coreStoreError
}
// MARK: Deleting
@nonobjc
internal func deleteAll<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) -> Int? {
internal func deleteAll<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) throws -> Int {
var numberOfDeletedObjects: Int?
var fetchError: Error?
@@ -614,14 +585,15 @@ internal extension NSManagedObjectContext {
}
}
}
if numberOfDeletedObjects == nil {
CoreStore.log(
CoreStoreError(fetchError),
"Failed executing fetch request."
)
return nil
if let numberOfDeletedObjects = numberOfDeletedObjects {
return numberOfDeletedObjects
}
return numberOfDeletedObjects
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing delete request."
)
throw coreStoreError
}
}

View File

@@ -42,9 +42,10 @@ public protocol QueryableSource: class {
- parameter from: a `From` clause indicating the entity type
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U?
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U?
/**
Queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
@@ -54,9 +55,10 @@ public protocol QueryableSource: class {
- parameter from: a `From` clause indicating the entity type
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U?
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U?
/**
Queries a property value or aggregate as specified by the `QueryChainableBuilderType` built from a chain of clauses.
@@ -70,9 +72,10 @@ public protocol QueryableSource: class {
)
```
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
- returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType
func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType
/**
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
@@ -83,8 +86,9 @@ public protocol QueryableSource: class {
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]?
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]]
/**
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
@@ -95,8 +99,9 @@ public protocol QueryableSource: class {
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]?
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]]
/**
Queries a dictionary of attribute values or as specified by the `QueryChainableBuilderType` built from a chain of clauses.
@@ -120,8 +125,9 @@ public protocol QueryableSource: class {
```
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request.
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
*/
func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary
func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary
/**
The internal `NSManagedObjectContext` managed by this `QueryableSource`. Using this context directly should typically be avoided, and is provided by CoreStore only for extremely specialized cases.

View File

@@ -298,6 +298,9 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
}
}
// MARK: - SelectTerm where D: NSManagedObject
extension SelectTerm where D: NSManagedObject {
/**
@@ -366,6 +369,9 @@ extension SelectTerm where D: NSManagedObject {
}
}
// MARK: - SelectTerm where D: CoreStoreObject
extension SelectTerm where D: CoreStoreObject {
/**

View File

@@ -142,8 +142,23 @@ public extension UnsafeDataTransaction {
createAsynchronously: createAsynchronously
)
}
// TODO: docs
/**
Asynchronously creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
```
dataStack.monitorList(
createAsynchronously: { (monitor) in
self.monitor = monitor
},
From<MyPersonEntity>()
.where(\.age > 18)
.orderBy(.ascending(\.age))
)
```
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
*/
public func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
self.monitorList(
@@ -267,8 +282,8 @@ public extension UnsafeDataTransaction {
.orderBy(.ascending(\.age))
)
```
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType`
*/
public func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {

View File

@@ -541,7 +541,7 @@ public extension Sequence where Iterator.Element: WhereClauseType {
public extension Where {
@available(*, deprecated: 4.0, renamed: "&&?")
@available(*, deprecated, renamed: "&&?")
public static func && (left: Where<D>, right: Where<D>?) -> Where<D> {
if let right = right {
@@ -551,7 +551,7 @@ public extension Where {
return left
}
@available(*, deprecated: 4.0, renamed: "&&?")
@available(*, deprecated, renamed: "&&?")
public static func && (left: Where<D>?, right: Where<D>) -> Where<D> {
if let left = left {
@@ -561,7 +561,7 @@ public extension Where {
return right
}
@available(*, deprecated: 4.0, renamed: "||?")
@available(*, deprecated, renamed: "||?")
public static func || (left: Where<D>, right: Where<D>?) -> Where<D> {
if let right = right {
@@ -571,7 +571,7 @@ public extension Where {
return left
}
@available(*, deprecated: 4.0, renamed: "||?")
@available(*, deprecated, renamed: "||?")
public static func || (left: Where<D>?, right: Where<D>) -> Where<D> {
if let left = left {