fetches, queries, and deletes are now throwable methods

This commit is contained in:
John Estropia
2019-01-15 20:40:15 +09:00
parent 5777831565
commit 682472c1bd
30 changed files with 1239 additions and 1352 deletions

View File

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

View File

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

View File

@@ -160,7 +160,7 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 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 { 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? { 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( ColorsDemo.stack.perform(
asynchronous: { (transaction) in asynchronous: { (transaction) in
transaction.deleteAll(From<Palette>()) try transaction.deleteAll(From<Palette>())
}, },
completion: { _ in } completion: { _ in }
) )
@@ -316,7 +316,7 @@ class ListObserverDemoViewController: UITableViewController, ListSectionObserver
ColorsDemo.stack.perform( ColorsDemo.stack.perform(
asynchronous: { (transaction) in asynchronous: { (transaction) in
for palette in (transaction.fetchAll(From<Palette>()) ?? []) { for palette in try transaction.fetchAll(From<Palette>()) {
palette.hue .= Palette.randomHue() palette.hue .= Palette.randomHue()
palette.colorName .= nil palette.colorName .= nil

View File

@@ -50,7 +50,7 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver {
required init?(coder aDecoder: NSCoder) { 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) 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) self.monitor = ColorsDemo.stack.monitorObject(palette)
} }

View File

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

View File

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

View File

@@ -36,7 +36,7 @@ private struct Static {
_ = try? dataStack.perform( _ = try? dataStack.perform(
synchronous: { (transaction) in synchronous: { (transaction) in
transaction.deleteAll(From<UserAccount>()) try transaction.deleteAll(From<UserAccount>())
let account1 = transaction.create(Into<MaleAccount>(maleConfiguration)) let account1 = transaction.create(Into<MaleAccount>(maleConfiguration))
account1.accountType = "Facebook" account1.accountType = "Facebook"
@@ -74,7 +74,7 @@ private struct Static {
_ = try? dataStack.perform( _ = try? dataStack.perform(
synchronous: { (transaction) in synchronous: { (transaction) in
transaction.deleteAll(From<UserAccount>()) try transaction.deleteAll(From<UserAccount>())
let account1 = transaction.create(Into<MaleAccount>(maleConfiguration)) let account1 = transaction.create(Into<MaleAccount>(maleConfiguration))
account1.accountType = "Twitter" account1.accountType = "Twitter"
@@ -99,8 +99,8 @@ private struct Static {
class StackSetupDemoViewController: UITableViewController { class StackSetupDemoViewController: UITableViewController {
let accounts = [ let accounts = [
Static.facebookStack.fetchAll(From(UserAccount.self)) ?? [], try! Static.facebookStack.fetchAll(From<UserAccount>()),
Static.twitterStack.fetchAll(From(UserAccount.self)) ?? [] 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 { if place == nil {
_ = try? CoreStore.perform( _ = try? CoreStore.perform(
@@ -36,7 +36,7 @@ private struct Static {
place.setInitialValues() place.setInitialValues()
} }
) )
place = CoreStore.fetchOne(From<Place>()) place = try! CoreStore.fetchOne(From<Place>())
} }
return CoreStore.monitorObject(place!) return CoreStore.monitorObject(place!)

View File

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

View File

@@ -248,51 +248,51 @@ class DynamicModelTests: BaseTestDataTestCase {
let p1 = Where<Animal>({ $0.species == "Sparrow" }) let p1 = Where<Animal>({ $0.species == "Sparrow" })
XCTAssertEqual(p1.predicate, NSPredicate(format: "%K == %@", "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) XCTAssertNotNil(bird)
XCTAssertEqual(bird!.species.value, "Sparrow") XCTAssertEqual(bird!.species.value, "Sparrow")
let p2 = Where<Dog>({ $0.nickname == "Spot" }) let p2 = Where<Dog>({ $0.nickname == "Spot" })
XCTAssertEqual(p2.predicate, NSPredicate(format: "%K == %@", "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) XCTAssertNotNil(dog)
XCTAssertEqual(dog!.nickname.value, "Spot") XCTAssertEqual(dog!.nickname.value, "Spot")
XCTAssertEqual(dog!.species.value, "Dog") XCTAssertEqual(dog!.species.value, "Dog")
let person = transaction.fetchOne(From<Person>()) let person = try transaction.fetchOne(From<Person>())
XCTAssertNotNil(person) XCTAssertNotNil(person)
XCTAssertEqual(person!.pets.value.first, dog) XCTAssertEqual(person!.pets.value.first, dog)
let p3 = Where<Dog>({ $0.age == 10 }) let p3 = Where<Dog>({ $0.age == 10 })
XCTAssertEqual(p3.predicate, NSPredicate(format: "%K == %d", "age", 10)) XCTAssertEqual(p3.predicate, NSPredicate(format: "%K == %d", "age", 10))
_ = transaction.fetchAll( _ = try transaction.fetchAll(
From<Dog>() From<Dog>()
.where(\Animal.species == "Dog" && \.age == 10) .where(\Animal.species == "Dog" && \.age == 10)
) )
_ = transaction.fetchAll( _ = try transaction.fetchAll(
From<Dog>() From<Dog>()
.where(\.age == 10 && \Animal.species == "Dog") .where(\.age == 10 && \Animal.species == "Dog")
.orderBy(.ascending({ $0.species })) .orderBy(.ascending({ $0.species }))
) )
_ = transaction.fetchAll( _ = try transaction.fetchAll(
From<Dog>(), From<Dog>(),
Where<Dog>({ $0.age > 10 && $0.age <= 15 }) Where<Dog>({ $0.age > 10 && $0.age <= 15 })
) )
_ = transaction.fetchAll( _ = try transaction.fetchAll(
From<Dog>(), From<Dog>(),
Where<Dog>({ $0.species == "Dog" && $0.age == 10 }) Where<Dog>({ $0.species == "Dog" && $0.age == 10 })
) )
_ = transaction.fetchAll( _ = try transaction.fetchAll(
From<Dog>(), From<Dog>(),
Where<Dog>({ $0.age == 10 && $0.species == "Dog" }) Where<Dog>({ $0.age == 10 && $0.species == "Dog" })
) )
_ = transaction.fetchAll( _ = try transaction.fetchAll(
From<Dog>(), From<Dog>(),
Where<Dog>({ $0.age > 10 && $0.age <= 15 }) Where<Dog>({ $0.age > 10 && $0.age <= 15 })
) )
_ = transaction.fetchAll( _ = try transaction.fetchAll(
From<Dog>(), From<Dog>(),
(\Dog.age > 10 && \Dog.age <= 15) (\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 from = From<TestEntity1>()
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) try from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -90,11 +89,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config1") let from = From<TestEntity1>("Config1")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -116,8 +115,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>() let from = From<TestEntity1>()
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -131,8 +130,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config1") let from = From<TestEntity1>("Config1")
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -146,11 +145,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config2") let from = From<TestEntity1>("Config2")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -164,11 +163,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>() let from = From<TestEntity2>()
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -182,11 +181,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config1") let from = From<TestEntity2>("Config1")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -200,11 +199,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config2") let from = From<TestEntity2>("Config2")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -226,8 +225,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>() let from = From<TestEntity1>()
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -241,8 +240,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config1") let from = From<TestEntity1>("Config1")
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -256,11 +255,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config2") let from = From<TestEntity1>("Config2")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -274,8 +273,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>() let from = From<TestEntity2>()
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -289,11 +288,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config1") let from = From<TestEntity2>("Config1")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -307,11 +306,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config2") let from = From<TestEntity2>("Config2")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -333,8 +332,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>() let from = From<TestEntity1>()
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -348,8 +347,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config1") let from = From<TestEntity1>("Config1")
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -363,11 +362,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity1>("Config2") let from = From<TestEntity1>("Config2")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -381,8 +380,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>() let from = From<TestEntity2>()
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -396,11 +395,11 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config1") let from = From<TestEntity2>("Config1")
let request = CoreStoreFetchRequest() 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.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)
@@ -414,8 +413,8 @@ final class FromTests: BaseTestCase {
let from = From<TestEntity2>("Config2") let from = From<TestEntity2>("Config2")
let request = CoreStoreFetchRequest() let request = CoreStoreFetchRequest()
let storesFound = from.applyToFetchRequest(request, context: dataStack.mainContext) let storesFound: Void? = try? from.applyToFetchRequest(request, context: dataStack.mainContext)
XCTAssertTrue(storesFound) XCTAssertNotNil(storesFound)
XCTAssertNotNil(request.entity) XCTAssertNotNil(request.entity)
XCTAssertNotNil(request.safeAffectedStores) XCTAssertNotNil(request.safeAffectedStores)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -69,9 +69,9 @@ final class TransactionTests: BaseTestCase {
self.checkExpectationsImmediately() self.checkExpectationsImmediately()
XCTAssertTrue(hasChanges) 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext) XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext) XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext)
@@ -84,14 +84,14 @@ final class TransactionTests: BaseTestCase {
do { do {
let updateExpectation = self.expectation(description: "update") let updateExpectation = self.expectation(description: "update")
let hasChanges: Bool = try! stack.perform( let hasChanges: Bool = try stack.perform(
synchronous: { (transaction) in synchronous: { (transaction) in
defer { defer {
updateExpectation.fulfill() 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 // TODO: convert fetch methods to throwing methods
XCTFail() XCTFail()
try transaction.cancel() try transaction.cancel()
@@ -107,9 +107,9 @@ final class TransactionTests: BaseTestCase {
self.checkExpectationsImmediately() self.checkExpectationsImmediately()
XCTAssertTrue(hasChanges) 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit") XCTAssertEqual(object?.testString, "string1_edit")
@@ -128,7 +128,7 @@ final class TransactionTests: BaseTestCase {
deleteExpectation.fulfill() deleteExpectation.fulfill()
} }
let object = transaction.fetchOne(From<TestEntity1>()) let object = try transaction.fetchOne(From<TestEntity1>())
transaction.delete(object) transaction.delete(object)
return transaction.hasChanges return transaction.hasChanges
} }
@@ -141,9 +141,9 @@ final class TransactionTests: BaseTestCase {
} }
self.checkExpectationsImmediately() 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) XCTAssertNil(object)
} }
} }
@@ -184,10 +184,10 @@ final class TransactionTests: BaseTestCase {
} }
self.checkExpectationsImmediately() self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0) 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1") XCTAssertEqual(object?.testString, "string1")
@@ -206,7 +206,7 @@ final class TransactionTests: BaseTestCase {
updateExpectation.fulfill() updateExpectation.fulfill()
} }
guard let object = transaction.fetchOne(From<TestEntity1>("Config1")) else { guard let object = try transaction.fetchOne(From<TestEntity1>("Config1")) else {
XCTFail() XCTFail()
try transaction.cancel() try transaction.cancel()
@@ -226,10 +226,10 @@ final class TransactionTests: BaseTestCase {
} }
self.checkExpectationsImmediately() self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0) 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit") XCTAssertEqual(object?.testString, "string1_edit")
@@ -248,7 +248,7 @@ final class TransactionTests: BaseTestCase {
deleteExpectation.fulfill() deleteExpectation.fulfill()
} }
let object = transaction.fetchOne(From<TestEntity1>("Config1")) let object = try transaction.fetchOne(From<TestEntity1>("Config1"))
transaction.delete(object) transaction.delete(object)
return transaction.hasChanges return transaction.hasChanges
@@ -262,8 +262,8 @@ final class TransactionTests: BaseTestCase {
} }
self.checkExpectationsImmediately() self.checkExpectationsImmediately()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 0) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 0)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
} }
} }
} }
@@ -294,9 +294,9 @@ final class TransactionTests: BaseTestCase {
) )
self.checkExpectationsImmediately() 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) XCTAssertNil(object)
} }
let testDate = Date() let testDate = Date()
@@ -329,7 +329,7 @@ final class TransactionTests: BaseTestCase {
updateDiscardExpectation.fulfill() updateDiscardExpectation.fulfill()
} }
guard let object = transaction.fetchOne(From<TestEntity1>()) else { guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail() XCTFail()
try transaction.cancel() try transaction.cancel()
@@ -343,9 +343,9 @@ final class TransactionTests: BaseTestCase {
) )
self.checkExpectationsImmediately() 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1") XCTAssertEqual(object?.testString, "string1")
@@ -362,7 +362,7 @@ final class TransactionTests: BaseTestCase {
deleteDiscardExpectation.fulfill() deleteDiscardExpectation.fulfill()
} }
guard let object = transaction.fetchOne(From<TestEntity1>()) else { guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail() XCTFail()
try transaction.cancel() try transaction.cancel()
@@ -374,9 +374,9 @@ final class TransactionTests: BaseTestCase {
) )
self.checkExpectationsImmediately() 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1") XCTAssertEqual(object?.testString, "string1")
@@ -521,18 +521,25 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(hasChanges) XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1) do {
let object = stack.fetchOne(From<TestEntity1>()) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertNotNil(object)
XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertEqual(object?.testString, "string1") XCTAssertNotNil(object)
XCTAssertEqual(object?.testNumber, 100) XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.testDate, testDate) XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext)
createExpectation.fulfill()
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1")
XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
createExpectation.fulfill()
}
catch {
XCTFail()
}
}, },
failure: { _ in failure: { _ in
@@ -546,7 +553,7 @@ final class TransactionTests: BaseTestCase {
stack.perform( stack.perform(
asynchronous: { (transaction) -> Bool in asynchronous: { (transaction) -> Bool in
guard let object = transaction.fetchOne(From<TestEntity1>()) else { guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail() XCTFail()
try transaction.cancel() try transaction.cancel()
@@ -561,15 +568,22 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(hasChanges) XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1) do {
let object = stack.fetchOne(From<TestEntity1>()) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertEqual(object?.testString, "string1_edit") XCTAssertNotNil(object)
XCTAssertEqual(object?.testNumber, 200) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testDate, Date.distantFuture) XCTAssertEqual(object?.testString, "string1_edit")
updateExpectation.fulfill() XCTAssertEqual(object?.testNumber, 200)
XCTAssertEqual(object?.testDate, Date.distantFuture)
updateExpectation.fulfill()
}
catch {
XCTFail()
}
}, },
failure: { _ in failure: { _ in
@@ -583,7 +597,7 @@ final class TransactionTests: BaseTestCase {
stack.perform( stack.perform(
asynchronous: { (transaction) -> Bool in asynchronous: { (transaction) -> Bool in
let object = transaction.fetchOne(From<TestEntity1>()) let object = try transaction.fetchOne(From<TestEntity1>())
transaction.delete(object) transaction.delete(object)
return transaction.hasChanges return transaction.hasChanges
@@ -592,11 +606,18 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(hasChanges) XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0) do {
let object = stack.fetchOne(From<TestEntity1>()) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(object)
deleteExpectation.fulfill() let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertNil(object)
deleteExpectation.fulfill()
}
catch {
XCTFail()
}
}, },
failure: { _ in failure: { _ in
@@ -632,16 +653,23 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(hasChanges) XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1) do {
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = stack.fetchOne(From<TestEntity1>("Config1")) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertNotNil(object) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1") let object = try stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertEqual(object?.testNumber, 100) XCTAssertNotNil(object)
XCTAssertEqual(object?.testDate, testDate) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
createExpectation.fulfill() XCTAssertEqual(object?.testString, "string1")
XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
createExpectation.fulfill()
}
catch {
XCTFail()
}
}, },
failure: { _ in failure: { _ in
@@ -655,7 +683,7 @@ final class TransactionTests: BaseTestCase {
stack.perform( stack.perform(
asynchronous: { (transaction) -> Bool in asynchronous: { (transaction) -> Bool in
guard let object = transaction.fetchOne(From<TestEntity1>("Config1")) else { guard let object = try transaction.fetchOne(From<TestEntity1>("Config1")) else {
XCTFail() XCTFail()
try transaction.cancel() try transaction.cancel()
@@ -670,16 +698,23 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(hasChanges) XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1) do {
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
let object = stack.fetchOne(From<TestEntity1>("Config1")) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertNotNil(object) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit") let object = try stack.fetchOne(From<TestEntity1>("Config1"))
XCTAssertEqual(object?.testNumber, 200) XCTAssertNotNil(object)
XCTAssertEqual(object?.testDate, Date.distantFuture) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
updateExpectation.fulfill() XCTAssertEqual(object?.testString, "string1_edit")
XCTAssertEqual(object?.testNumber, 200)
XCTAssertEqual(object?.testDate, Date.distantFuture)
updateExpectation.fulfill()
}
catch {
XCTFail()
}
}, },
failure: { _ in failure: { _ in
@@ -693,7 +728,7 @@ final class TransactionTests: BaseTestCase {
stack.perform( stack.perform(
asynchronous: { (transaction) -> Bool in asynchronous: { (transaction) -> Bool in
let object = transaction.fetchOne(From<TestEntity1>("Config1")) let object = try transaction.fetchOne(From<TestEntity1>("Config1"))
transaction.delete(object) transaction.delete(object)
return transaction.hasChanges return transaction.hasChanges
@@ -702,10 +737,17 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(hasChanges) XCTAssertTrue(hasChanges)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 0) do {
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0)
deleteExpectation.fulfill() XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 0)
XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
deleteExpectation.fulfill()
}
catch {
XCTFail()
}
}, },
failure: { _ in failure: { _ in
@@ -754,8 +796,8 @@ final class TransactionTests: BaseTestCase {
stack.perform( stack.perform(
asynchronous: { (transaction) -> Bool in asynchronous: { (transaction) -> Bool in
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 0) XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(transaction.fetchOne(From<TestEntity1>())) XCTAssertNil(try transaction.fetchOne(From<TestEntity1>()))
let object = transaction.create(Into<TestEntity1>()) let object = transaction.create(Into<TestEntity1>())
object.testEntityID = NSNumber(value: 1) object.testEntityID = NSNumber(value: 1)
@@ -782,7 +824,7 @@ final class TransactionTests: BaseTestCase {
stack.perform( stack.perform(
asynchronous: { (transaction) -> Void in asynchronous: { (transaction) -> Void in
guard let object = transaction.fetchOne(From<TestEntity1>()) else { guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail() XCTFail()
return return
@@ -811,9 +853,9 @@ final class TransactionTests: BaseTestCase {
stack.perform( stack.perform(
asynchronous: { (transaction) -> Void in 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() XCTFail()
try transaction.cancel() try transaction.cancel()
@@ -835,15 +877,22 @@ final class TransactionTests: BaseTestCase {
failure: { (error) in failure: { (error) in
XCTAssertEqual(error, CoreStoreError.userCancelled) XCTAssertEqual(error, CoreStoreError.userCancelled)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1) do {
let object = stack.fetchOne(From<TestEntity1>()) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) let object = try stack.fetchOne(From<TestEntity1>())
XCTAssertEqual(object?.testString, "string1") XCTAssertNotNil(object)
XCTAssertEqual(object?.testNumber, 100) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testDate, testDate) XCTAssertEqual(object?.testString, "string1")
deleteDiscardExpectation.fulfill() XCTAssertEqual(object?.testNumber, 100)
XCTAssertEqual(object?.testDate, testDate)
deleteDiscardExpectation.fulfill()
}
catch {
XCTFail()
}
} }
) )
} }
@@ -878,9 +927,9 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges) XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait() 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext) XCTAssertEqual(object?.fetchSource()?.unsafeContext(), stack.mainContext)
XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext) XCTAssertEqual(object?.querySource()?.unsafeContext(), stack.mainContext)
@@ -897,7 +946,7 @@ final class TransactionTests: BaseTestCase {
} }
do { do {
guard let object = transaction.fetchOne(From<TestEntity1>()) else { guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail() XCTFail()
return return
@@ -911,9 +960,9 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges) XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait() 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit") XCTAssertEqual(object?.testString, "string1_edit")
@@ -927,7 +976,7 @@ final class TransactionTests: BaseTestCase {
} }
do { do {
let object = transaction.fetchOne(From<TestEntity1>()) let object = try transaction.fetchOne(From<TestEntity1>())
transaction.delete(object) transaction.delete(object)
do { do {
@@ -935,8 +984,8 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges) XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait() try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(stack.fetchOne(From<TestEntity1>())) XCTAssertNil(try stack.fetchOne(From<TestEntity1>()))
} }
catch { catch {
@@ -967,10 +1016,10 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges) XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait() try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0) 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1") XCTAssertEqual(object?.testString, "string1")
@@ -984,7 +1033,7 @@ final class TransactionTests: BaseTestCase {
} }
do { do {
guard let object = transaction.fetchOne(From<TestEntity1>("Config1")) else { guard let object = try transaction.fetchOne(From<TestEntity1>("Config1")) else {
XCTFail() XCTFail()
return return
@@ -998,10 +1047,10 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges) XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait() try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 1) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 1)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0) 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) XCTAssertNotNil(object)
XCTAssertEqual(object?.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object?.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object?.testString, "string1_edit") XCTAssertEqual(object?.testString, "string1_edit")
@@ -1015,7 +1064,7 @@ final class TransactionTests: BaseTestCase {
} }
do { do {
let object = transaction.fetchOne(From<TestEntity1>("Config1")) let object = try transaction.fetchOne(From<TestEntity1>("Config1"))
transaction.delete(object) transaction.delete(object)
do { do {
@@ -1023,8 +1072,8 @@ final class TransactionTests: BaseTestCase {
XCTAssertTrue(transaction.hasChanges) XCTAssertTrue(transaction.hasChanges)
try transaction.commitAndWait() try transaction.commitAndWait()
XCTAssertEqual(stack.fetchCount(From<TestEntity1>("Config1")), 0) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>("Config1")), 0)
XCTAssertEqual(stack.fetchCount(From<TestEntity1>(nil)), 0) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>(nil)), 0)
} }
catch { catch {
@@ -1050,11 +1099,11 @@ final class TransactionTests: BaseTestCase {
transaction.rollback() transaction.rollback()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 0) XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(transaction.fetchOne(From<TestEntity1>())) XCTAssertNil(try transaction.fetchOne(From<TestEntity1>()))
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 0) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 0)
XCTAssertNil(stack.fetchOne(From<TestEntity1>())) XCTAssertNil(try stack.fetchOne(From<TestEntity1>()))
} }
let testDate = Date() let testDate = Date()
@@ -1079,7 +1128,7 @@ final class TransactionTests: BaseTestCase {
do { do {
guard let object = transaction.fetchOne(From<TestEntity1>()) else { guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail() XCTFail()
return return
@@ -1090,8 +1139,8 @@ final class TransactionTests: BaseTestCase {
transaction.rollback() transaction.rollback()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1) XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
if let object = transaction.fetchOne(From<TestEntity1>()) { if let object = try transaction.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(object.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object.testString, "string1") XCTAssertEqual(object.testString, "string1")
@@ -1103,8 +1152,8 @@ final class TransactionTests: BaseTestCase {
XCTFail() XCTFail()
} }
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
if let object = stack.fetchOne(From<TestEntity1>()) { if let object = try stack.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(object.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object.testString, "string1") XCTAssertEqual(object.testString, "string1")
@@ -1119,7 +1168,7 @@ final class TransactionTests: BaseTestCase {
do { do {
guard let object = transaction.fetchOne(From<TestEntity1>()) else { guard let object = try transaction.fetchOne(From<TestEntity1>()) else {
XCTFail() XCTFail()
return return
@@ -1128,8 +1177,8 @@ final class TransactionTests: BaseTestCase {
transaction.rollback() transaction.rollback()
XCTAssertEqual(transaction.fetchCount(From<TestEntity1>()), 1) XCTAssertEqual(try transaction.fetchCount(From<TestEntity1>()), 1)
if let object = transaction.fetchOne(From<TestEntity1>()) { if let object = try transaction.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(object.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object.testString, "string1") XCTAssertEqual(object.testString, "string1")
@@ -1141,8 +1190,8 @@ final class TransactionTests: BaseTestCase {
XCTFail() XCTFail()
} }
XCTAssertEqual(stack.fetchCount(From<TestEntity1>()), 1) XCTAssertEqual(try stack.fetchCount(From<TestEntity1>()), 1)
if let object = stack.fetchOne(From<TestEntity1>()) { if let object = try stack.fetchOne(From<TestEntity1>()) {
XCTAssertEqual(object.testEntityID, NSNumber(value: 1)) XCTAssertEqual(object.testEntityID, NSNumber(value: 1))
XCTAssertEqual(object.testString, "string1") XCTAssertEqual(object.testString, "string1")

View File

@@ -151,7 +151,7 @@ public extension BaseDataTransaction {
return nil 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 { guard entityType.shouldUpdate(from: source, in: self) else {
@@ -215,7 +215,8 @@ public extension BaseDataTransaction {
importSourceByID = try autoreleasepool { try preProcess(importSourceByID) } importSourceByID = try autoreleasepool { try preProcess(importSourceByID) }
var existingObjectsByID = Dictionary<D.UniqueIDType, D>() 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 } .forEach { existingObjectsByID[$0.uniqueIDValue] = $0 }
var processedObjectIDs = Set<D.UniqueIDType>() var processedObjectIDs = Set<D.UniqueIDType>()

View File

@@ -39,13 +39,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- returns: the number of `DynamicObject`s deleted - returns: the number of `DynamicObject`s deleted
*/ */
@discardableResult @discardableResult
public func deleteAll<D>(_ from: From<D>, _ deleteClauses: DeleteClause...) -> Int? { public func deleteAll<D>(_ from: From<D>, _ deleteClauses: DeleteClause...) throws -> Int {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to delete from a \(cs_typeName(self)) outside its designated queue." "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 - returns: the number of `DynamicObject`s deleted
*/ */
@discardableResult @discardableResult
public func deleteAll<D>(_ from: From<D>, _ deleteClauses: [DeleteClause]) -> Int? { public func deleteAll<D>(_ from: From<D>, _ deleteClauses: [DeleteClause]) throws -> Int {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to delete from a \(cs_typeName(self)) outside its designated queue." "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 - returns: the number of `DynamicObject`s deleted
*/ */
@discardableResult @discardableResult
public func deleteAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? { public func deleteAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to delete from a \(cs_typeName(self)) outside its designated queue." "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)
} }
@@ -297,13 +297,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? { public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -313,13 +313,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? { public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -334,13 +334,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - 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`
*/ */
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? { public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
) )
return self.context.fetchObjectID(clauseChain) return try self.context.fetchObjectID(clauseChain)
} }
/** /**
@@ -350,13 +350,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? { public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -366,13 +366,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? { public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -387,13 +387,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - 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`
*/ */
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? { public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
CoreStore.assert( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
) )
return self.context.fetchObjectIDs(clauseChain) return try self.context.fetchObjectIDs(clauseChain)
} }
@@ -409,13 +409,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -428,13 +428,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -451,13 +451,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request. - 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`
*/ */
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( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -470,13 +470,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -489,13 +489,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue." "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)
} }
/** /**
@@ -521,13 +521,13 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request. - 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` - returns: the result of the the query as specified by the `QueryChainableBuilderType`
*/ */
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( CoreStore.assert(
self.isRunningInAllowedQueue(), self.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue." "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(), self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "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(), self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "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(), self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "Attempted to fetch from a \(cs_typeName(self)) outside its designated queue."
) )
return self.swiftTransaction.context return (try? self.swiftTransaction.context.fetchCount(from, fetchClauses))
.fetchCount(from, fetchClauses) .flatMap({ NSNumber(value: $0) })
.flatMap { NSNumber(value: $0) }
} }
/** /**
@@ -146,7 +147,8 @@ public extension CSBaseDataTransaction {
self.swiftTransaction.isRunningInAllowedQueue(), self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to fetch from a \(cs_typeName(self)) outside its designated queue." "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(), self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue." "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(), self.swiftTransaction.isRunningInAllowedQueue(),
"Attempted to query from a \(cs_typeName(self)) outside its designated queue." "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, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "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, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "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, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
) )
return self.bridgeToSwift.mainContext return (try? self.bridgeToSwift.mainContext.fetchCount(from, fetchClauses))
.fetchCount(from, fetchClauses) .flatMap({ NSNumber(value: $0) })
.flatMap { NSNumber(value: $0) }
} }
/** /**
@@ -146,7 +147,8 @@ public extension CSDataStack {
Thread.isMainThread, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "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, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "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, Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread." "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, Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread." "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

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

View File

@@ -205,9 +205,9 @@ public extension CoreStore {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
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)
} }
/** /**
@@ -217,9 +217,9 @@ public extension CoreStore {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
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)
} }
/** /**
@@ -234,9 +234,9 @@ public extension CoreStore {
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - 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`
*/ */
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)
} }
/** /**
@@ -246,9 +246,9 @@ public extension CoreStore {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
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)
} }
/** /**
@@ -258,9 +258,9 @@ public extension CoreStore {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
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)
} }
/** /**
@@ -275,9 +275,9 @@ public extension CoreStore {
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - 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`
*/ */
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)
} }
/** /**
@@ -290,9 +290,9 @@ public extension CoreStore {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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)
} }
/** /**
@@ -305,9 +305,9 @@ public extension CoreStore {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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)
} }
/** /**
@@ -324,9 +324,9 @@ public extension CoreStore {
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request. - 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`
*/ */
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)
} }
/** /**
@@ -339,9 +339,9 @@ public extension CoreStore {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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)
} }
/** /**
@@ -354,9 +354,9 @@ public extension CoreStore {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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)
} }
/** /**
@@ -382,8 +382,8 @@ public extension CoreStore {
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request. - 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` - returns: the result of the the query as specified by the `QueryChainableBuilderType`
*/ */
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

@@ -49,7 +49,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
@nonobjc @nonobjc
internal init<D>(context: NSManagedObjectContext, fetchRequest: NSFetchRequest<NSManagedObject>, from: From<D>, sectionBy: SectionBy<D>? = nil, applyFetchClauses: @escaping (_ fetchRequest: NSFetchRequest<NSManagedObject>) -> Void) { 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, fetchRequest,
context: context, context: context,
applyAffectedStores: false applyAffectedStores: false
@@ -58,7 +58,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
self.reapplyAffectedStores = { fetchRequest, context in self.reapplyAffectedStores = { fetchRequest, context in
return try rom.applyAffectedStoresForFetchedRequest(fetchRequest, context: context) try from.applyAffectedStoresForFetchedRequest(fetchRequest, context: context)
} }
super.init( super.init(
@@ -91,5 +91,5 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
// MARK: Private // MARK: Private
@nonobjc @nonobjc
private let reapplyAffectedStores: (_ fetchRequest: NSFetchRequest<NSManagedObject>, _ context: NSManagedObjectContext) throws -> Bool private let reapplyAffectedStores: (_ fetchRequest: NSFetchRequest<NSManagedObject>, _ context: NSManagedObjectContext) throws -> Void
} }

View File

@@ -243,13 +243,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? { public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
CoreStore.assert( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -259,13 +259,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? { public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
CoreStore.assert( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -280,13 +280,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - 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`
*/ */
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? { public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
CoreStore.assert( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
) )
return self.mainContext.fetchObjectID(clauseChain) return try self.mainContext.fetchObjectID(clauseChain)
} }
/** /**
@@ -296,13 +296,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? { public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
CoreStore.assert( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -312,13 +312,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? { public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
CoreStore.assert( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -333,13 +333,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - 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`
*/ */
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? { public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
CoreStore.assert( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to fetch from a \(cs_typeName(self)) outside the main thread." "Attempted to fetch from a \(cs_typeName(self)) outside the main thread."
) )
return self.mainContext.fetchObjectIDs(clauseChain) return try self.mainContext.fetchObjectIDs(clauseChain)
} }
@@ -355,13 +355,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -374,13 +374,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -397,13 +397,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request. - 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`
*/ */
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( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -416,13 +416,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -435,13 +435,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread." "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)
} }
/** /**
@@ -467,13 +467,13 @@ extension DataStack: FetchableSource, QueryableSource {
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request. - 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` - returns: the result of the the query as specified by the `QueryChainableBuilderType`
*/ */
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( CoreStore.assert(
Thread.isMainThread, Thread.isMainThread,
"Attempted to query from a \(cs_typeName(self)) outside the main thread." "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

@@ -169,7 +169,7 @@ public protocol FetchableSource: class {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
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. Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -178,7 +178,7 @@ public protocol FetchableSource: class {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
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. Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
@@ -192,7 +192,7 @@ public protocol FetchableSource: class {
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - 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`
*/ */
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. Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -201,7 +201,7 @@ public protocol FetchableSource: class {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
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. Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
@@ -210,7 +210,7 @@ public protocol FetchableSource: class {
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - 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
*/ */
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. Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
@@ -224,7 +224,7 @@ public protocol FetchableSource: class {
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - 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`
*/ */
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. 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

@@ -96,10 +96,10 @@ internal extension NSManagedObjectContext {
} }
@nonobjc @nonobjc
internal func deleteAll(_ from: CSFrom, _ deleteClauses: [CSDeleteClause]) -> Int? { internal func deleteAll(_ from: CSFrom, _ deleteClauses: [CSDeleteClause]) throws -> Int {
let fetchRequest = CoreStoreFetchRequest() let fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self) try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0 fetchRequest.fetchLimit = 0
fetchRequest.resultType = .managedObjectResultType fetchRequest.resultType = .managedObjectResultType
@@ -107,46 +107,34 @@ internal extension NSManagedObjectContext {
fetchRequest.includesPropertyValues = false fetchRequest.includesPropertyValues = false
deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) } deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else { return try self.deleteAll(fetchRequest.dynamicCast())
return nil
}
return self.deleteAll(fetchRequest.dynamicCast())
} }
@nonobjc @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 fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self) try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0 fetchRequest.fetchLimit = 0
selectClause.applyToFetchRequest(fetchRequest) selectClause.applyToFetchRequest(fetchRequest)
queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) } queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else { return try self.queryValue(selectClause.selectTerms, fetchRequest: fetchRequest.dynamicCast())
return nil
}
return self.queryValue(selectClause.selectTerms, fetchRequest: fetchRequest.dynamicCast())
} }
@nonobjc @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 fetchRequest = CoreStoreFetchRequest()
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self) try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0 fetchRequest.fetchLimit = 0
selectClause.applyToFetchRequest(fetchRequest) selectClause.applyToFetchRequest(fetchRequest)
queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) } queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else { return try self.queryAttributes(fetchRequest.dynamicCast())
return nil
}
return self.queryAttributes(fetchRequest.dynamicCast())
} }
} }

View File

@@ -142,11 +142,11 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) } fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
let entityClass = from.entityClass let entityClass = from.entityClass
return try self.fetchAll(fetchRequest.dynamicCast())?.map(entityClass.cs_fromRaw) return try self.fetchAll(fetchRequest.dynamicCast()).map(entityClass.cs_fromRaw)
} }
@nonobjc @nonobjc
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throw -> [B.ObjectType] { public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
return try self.fetchAll(clauseChain.from, clauseChain.fetchClauses) return try self.fetchAll(clauseChain.from, clauseChain.fetchClauses)
} }
@@ -174,42 +174,38 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
} }
@nonobjc @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 @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 fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self) try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 1 fetchRequest.fetchLimit = 1
fetchRequest.resultType = .managedObjectIDResultType fetchRequest.resultType = .managedObjectIDResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) } fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else { return try self.fetchObjectID(fetchRequest.dynamicCast())
return nil
}
return self.fetchObjectID(fetchRequest.dynamicCast())
} }
@nonobjc @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 @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 @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 fetchRequest = CoreStoreFetchRequest()
try from.applyToFetchRequest(fetchRequest, context: self) try from.applyToFetchRequest(fetchRequest, context: self)
@@ -218,21 +214,17 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
fetchRequest.resultType = .managedObjectIDResultType fetchRequest.resultType = .managedObjectIDResultType
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) } fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else { return try self.fetchObjectIDs(fetchRequest.dynamicCast())
return nil
}
return self.fetchObjectIDs(fetchRequest.dynamicCast())
} }
@nonobjc @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 @nonobjc
internal func fetchObjectIDs(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) -> [NSManagedObjectID]? { internal func fetchObjectIDs(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) throws -> [NSManagedObjectID] {
var fetchResults: [NSManagedObjectID]? var fetchResults: [NSManagedObjectID]?
var fetchError: Error? var fetchError: Error?
@@ -247,77 +239,70 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
fetchError = error fetchError = error
} }
} }
if fetchResults == nil { if let fetchResults = fetchResults {
CoreStore.log( return fetchResults
CoreStoreError(fetchError),
"Failed executing fetch request."
)
return nil
} }
return fetchResults let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
} }
// MARK: QueryableSource // MARK: QueryableSource
@nonobjc @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 @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 fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self) try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0 fetchRequest.fetchLimit = 0
selectClause.applyToFetchRequest(fetchRequest) selectClause.applyToFetchRequest(fetchRequest)
queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) } queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else { return try self.queryValue(selectClause.selectTerms, fetchRequest: fetchRequest)
return nil
}
return self.queryValue(selectClause.selectTerms, fetchRequest: fetchRequest)
} }
@nonobjc @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 @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 @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 fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self) try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0 fetchRequest.fetchLimit = 0
selectClause.applyToFetchRequest(fetchRequest) selectClause.applyToFetchRequest(fetchRequest)
queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) } queryClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else { return try self.queryAttributes(fetchRequest)
return nil
}
return 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)
} }
@@ -333,10 +318,10 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
// MARK: Deleting // MARK: Deleting
@nonobjc @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 fetchRequest = CoreStoreFetchRequest()
let storeFound = from.applyToFetchRequest(fetchRequest, context: self) try from.applyToFetchRequest(fetchRequest, context: self)
fetchRequest.fetchLimit = 0 fetchRequest.fetchLimit = 0
fetchRequest.resultType = .managedObjectResultType fetchRequest.resultType = .managedObjectResultType
@@ -344,11 +329,7 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
fetchRequest.includesPropertyValues = false fetchRequest.includesPropertyValues = false
deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) } deleteClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
guard storeFound else { return try self.deleteAll(fetchRequest.dynamicCast())
return nil
}
return self.deleteAll(fetchRequest.dynamicCast())
} }
@@ -384,16 +365,16 @@ internal extension NSManagedObjectContext {
fetchError = error fetchError = error
} }
} }
if fetchResults == nil { if let fetchResults = fetchResults {
let coreStoreError = CoreStoreError(fetchError) return fetchResults.first
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
} }
return fetchResults?.first let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
} }
@nonobjc @nonobjc
@@ -412,16 +393,16 @@ internal extension NSManagedObjectContext {
fetchError = error fetchError = error
} }
} }
if fetchResults == nil { if let fetchResults = fetchResults {
let coreStoreError = CoreStoreError(fetchError) return fetchResults
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
} }
return fetchResults let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
} }
@nonobjc @nonobjc
@@ -442,7 +423,7 @@ internal extension NSManagedObjectContext {
} }
if count == NSNotFound { if count == NSNotFound {
let coreStoreError = CoreStoreError(fetchError) let coreStoreError = CoreStoreError(countError)
CoreStore.log( CoreStore.log(
coreStoreError, coreStoreError,
"Failed executing count request." "Failed executing count request."
@@ -453,7 +434,7 @@ internal extension NSManagedObjectContext {
} }
@nonobjc @nonobjc
internal func fetchObjectID(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) -> NSManagedObjectID? { internal func fetchObjectID(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) throws -> NSManagedObjectID? {
var fetchResults: [NSManagedObjectID]? var fetchResults: [NSManagedObjectID]?
var fetchError: Error? var fetchError: Error?
@@ -468,22 +449,23 @@ internal extension NSManagedObjectContext {
fetchError = error fetchError = error
} }
} }
if fetchResults == nil { if let fetchResults = fetchResults {
CoreStore.log( return fetchResults.first
CoreStoreError(fetchError),
"Failed executing fetch request."
)
return nil
} }
return fetchResults?.first let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing fetch request."
)
throw coreStoreError
} }
// MARK: Querying // MARK: Querying
@nonobjc @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 fetchResults: [Any]?
var fetchError: Error? var fetchError: Error?
@@ -507,16 +489,16 @@ internal extension NSManagedObjectContext {
} }
return nil return nil
} }
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log( CoreStore.log(
CoreStoreError(fetchError), coreStoreError,
"Failed executing fetch request." "Failed executing fetch request."
) )
return nil throw coreStoreError
} }
@nonobjc @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 fetchResults: [Any]?
var fetchError: Error? var fetchError: Error?
@@ -540,16 +522,16 @@ internal extension NSManagedObjectContext {
} }
return nil return nil
} }
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log( CoreStore.log(
CoreStoreError(fetchError), coreStoreError,
"Failed executing fetch request." "Failed executing fetch request."
) )
return nil throw coreStoreError
} }
@nonobjc @nonobjc
internal func queryAttributes(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> [[String: Any]]? { internal func queryAttributes(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) throws -> [[String: Any]] {
var fetchResults: [Any]? var fetchResults: [Any]?
var fetchError: Error? var fetchError: Error?
@@ -568,19 +550,19 @@ internal extension NSManagedObjectContext {
return NSDictionary.cs_fromQueryResultsNativeType(fetchResults) return NSDictionary.cs_fromQueryResultsNativeType(fetchResults)
} }
let coreStoreError = CoreStoreError(fetchError)
CoreStore.log( CoreStore.log(
CoreStoreError(fetchError), coreStoreError,
"Failed executing fetch request." "Failed executing fetch request."
) )
return nil throw coreStoreError
} }
// MARK: Deleting // MARK: Deleting
@nonobjc @nonobjc
internal func deleteAll<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) -> Int? { internal func deleteAll<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) throws -> Int {
var numberOfDeletedObjects: Int? var numberOfDeletedObjects: Int?
var fetchError: Error? var fetchError: Error?
@@ -603,14 +585,15 @@ internal extension NSManagedObjectContext {
} }
} }
} }
if numberOfDeletedObjects == nil { if let numberOfDeletedObjects = numberOfDeletedObjects {
CoreStore.log( return numberOfDeletedObjects
CoreStoreError(fetchError),
"Failed executing fetch request."
)
return nil
} }
return numberOfDeletedObjects let coreStoreError = CoreStoreError(fetchError)
CoreStore.log(
coreStoreError,
"Failed executing delete request."
)
throw coreStoreError
} }
} }

View File

@@ -44,7 +44,7 @@ public protocol QueryableSource: class {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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. Queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
@@ -56,7 +56,7 @@ public protocol QueryableSource: class {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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. Queries a property value or aggregate as specified by the `QueryChainableBuilderType` built from a chain of clauses.
@@ -72,7 +72,7 @@ public protocol QueryableSource: class {
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request. - 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`
*/ */
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. 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.
@@ -84,7 +84,7 @@ public protocol QueryableSource: class {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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. 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.
@@ -96,7 +96,7 @@ public protocol QueryableSource: class {
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - 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. The type of the return value is specified by the generic type of the `Select<U>` parameter.
*/ */
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. Queries a dictionary of attribute values or as specified by the `QueryChainableBuilderType` built from a chain of clauses.
@@ -121,7 +121,7 @@ public protocol QueryableSource: class {
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request. - 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` - returns: the result of the the query as specified by the `QueryChainableBuilderType`
*/ */
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. 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.