mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-05-27 09:59:22 +02:00
Merge branch 'throwables' into develop
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-21
@@ -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)
|
||||||
)
|
)
|
||||||
)!
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|||||||
+4
-4
@@ -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
|
||||||
|
|||||||
+2
-2
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>())
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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!)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -248,51 +248,54 @@ 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(
|
let totalAge = try transaction.queryValue(From<Dog>().select(Int.self, .sum(\Dog.age)))
|
||||||
|
XCTAssertEqual(totalAge, 1)
|
||||||
|
|
||||||
|
_ = 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)
|
||||||
)
|
)
|
||||||
|
|||||||
+534
-672
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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])
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|
||||||
|
|||||||
+122
-122
@@ -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"),
|
||||||
|
|||||||
@@ -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,20 @@ 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()
|
let configCount = try stack.fetchCount(From<TestEntity1>("Config1"))
|
||||||
|
XCTAssertEqual(configCount, 0)
|
||||||
|
|
||||||
|
let defaultCount = try stack.fetchCount(From<TestEntity1>(nil))
|
||||||
|
XCTAssertEqual(defaultCount, 0)
|
||||||
|
|
||||||
|
deleteExpectation.fulfill()
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
|
||||||
|
XCTFail()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
failure: { _ in
|
failure: { _ in
|
||||||
|
|
||||||
@@ -754,8 +799,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 +827,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 +856,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 +880,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 +930,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 +949,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 +963,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 +979,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 +987,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 +1019,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 +1036,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 +1050,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 +1067,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 +1075,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 +1102,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 +1131,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 +1142,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 +1155,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 +1171,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 +1180,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 +1193,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")
|
||||||
|
|||||||
@@ -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>()
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,15 +136,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D? {
|
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchOne(from, fetchClauses)
|
return try self.context.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,15 +153,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D? {
|
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchOne(from, fetchClauses)
|
return try self.context.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,15 +175,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
|
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchOne(clauseChain)
|
return try self.context.fetchOne(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,15 +192,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]? {
|
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchAll(from, fetchClauses)
|
return try self.context.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,15 +209,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]? {
|
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchAll(from, fetchClauses)
|
return try self.context.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,15 +231,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]? {
|
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchAll(clauseChain)
|
return try self.context.fetchAll(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,15 +248,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int? {
|
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchCount(from, fetchClauses)
|
return try self.context.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,15 +265,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int? {
|
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchCount(from, fetchClauses)
|
return try self.context.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,15 +287,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
|
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchCount(clauseChain)
|
return try self.context.fetchCount(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -295,15 +304,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -311,15 +321,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -332,15 +343,16 @@ 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`, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
|
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -348,15 +360,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -364,15 +377,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -385,15 +399,16 @@ 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`, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -407,15 +422,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U? {
|
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -426,15 +442,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U? {
|
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -449,15 +466,16 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
|
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
|
||||||
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
|
- returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType {
|
public func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -469,14 +487,15 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -488,14 +507,15 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -520,14 +540,15 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
|
|||||||
```
|
```
|
||||||
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request.
|
- 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`
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary {
|
public func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,6 +247,14 @@ extension CoreStoreError: CoreStoreSwiftType, _ObjectiveCBridgeableError {
|
|||||||
|
|
||||||
case .userCancelled:
|
case .userCancelled:
|
||||||
self = .userCancelled
|
self = .userCancelled
|
||||||
|
|
||||||
|
case .persistentStoreNotFound:
|
||||||
|
guard let entity = info["entity"] as? DynamicObject.Type else {
|
||||||
|
|
||||||
|
self = .unknown
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self = .persistentStoreNotFound(entity: entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -132,7 +132,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
@objc
|
@objc
|
||||||
public func hasObjectsInSection(_ section: Int) -> Bool {
|
public func hasObjectsInSection(_ section: Int) -> Bool {
|
||||||
|
|
||||||
return self.bridgeToSwift.hasObjectsInSection(section)
|
return self.bridgeToSwift.hasObjects(in: section)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,7 +155,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
@objc
|
@objc
|
||||||
public func objectsInSection(_ section: Int) -> [NSManagedObject] {
|
public func objectsInSection(_ section: Int) -> [NSManagedObject] {
|
||||||
|
|
||||||
return self.bridgeToSwift.objectsInSection(section)
|
return self.bridgeToSwift.objects(in: section)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,7 +167,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
@objc
|
@objc
|
||||||
public func objectsInSafeSection(safeSectionIndex section: Int) -> [NSManagedObject]? {
|
public func objectsInSafeSection(safeSectionIndex section: Int) -> [NSManagedObject]? {
|
||||||
|
|
||||||
return self.bridgeToSwift.objectsInSection(safeSectionIndex: section)
|
return self.bridgeToSwift.objects(safelyIn: section)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,7 +201,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
@objc
|
@objc
|
||||||
public func numberOfObjectsInSection(_ section: Int) -> Int {
|
public func numberOfObjectsInSection(_ section: Int) -> Int {
|
||||||
|
|
||||||
return self.bridgeToSwift.numberOfObjectsInSection(section)
|
return self.bridgeToSwift.numberOfObjects(in: section)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +214,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
public func numberOfObjectsInSafeSection(safeSectionIndex section: Int) -> NSNumber? {
|
public func numberOfObjectsInSafeSection(safeSectionIndex section: Int) -> NSNumber? {
|
||||||
|
|
||||||
return self.bridgeToSwift
|
return self.bridgeToSwift
|
||||||
.numberOfObjectsInSection(safeSectionIndex: section)
|
.numberOfObjects(safelyIn: section)
|
||||||
.flatMap { NSNumber(value: $0) }
|
.flatMap { NSNumber(value: $0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
@objc
|
@objc
|
||||||
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
|
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
|
||||||
|
|
||||||
return self.bridgeToSwift.sectionInfoAtIndex(section)
|
return self.bridgeToSwift.sectionInfo(at: section)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,7 +239,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
@objc
|
@objc
|
||||||
public func sectionInfoAtSafeSectionIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? {
|
public func sectionInfoAtSafeSectionIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? {
|
||||||
|
|
||||||
return self.bridgeToSwift.sectionInfoAtIndex(safeSectionIndex: section)
|
return self.bridgeToSwift.sectionInfo(safelyAt: section)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,7 +263,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
@objc
|
@objc
|
||||||
public func targetSectionForSectionIndexTitle(title: String, index: Int) -> Int {
|
public func targetSectionForSectionIndexTitle(title: String, index: Int) -> Int {
|
||||||
|
|
||||||
return self.bridgeToSwift.targetSectionForSectionIndex(title: title, index: index)
|
return self.bridgeToSwift.targetSection(forSectionIndexTitle: title, at: index)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -287,7 +287,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
public func indexOf(_ object: NSManagedObject) -> NSNumber? {
|
public func indexOf(_ object: NSManagedObject) -> NSNumber? {
|
||||||
|
|
||||||
return self.bridgeToSwift
|
return self.bridgeToSwift
|
||||||
.indexOf(object)
|
.index(of: object)
|
||||||
.flatMap { NSNumber(value: $0) }
|
.flatMap { NSNumber(value: $0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ public final class CSListMonitor: NSObject {
|
|||||||
@objc
|
@objc
|
||||||
public func indexPathOf(_ object: NSManagedObject) -> IndexPath? {
|
public func indexPathOf(_ object: NSManagedObject) -> IndexPath? {
|
||||||
|
|
||||||
return self.bridgeToSwift.indexPathOf(object)
|
return self.bridgeToSwift.indexPath(of: object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public extension CoreStore {
|
|||||||
|
|
||||||
```
|
```
|
||||||
CoreStore.monitorList(
|
CoreStore.monitorList(
|
||||||
{ (monitor) in
|
createAsynchronously: { (monitor) in
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
},
|
},
|
||||||
From<MyPersonEntity>()
|
From<MyPersonEntity>()
|
||||||
@@ -123,7 +123,6 @@ public extension CoreStore {
|
|||||||
```
|
```
|
||||||
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
|
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
|
||||||
*/
|
*/
|
||||||
public static func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
public static func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
||||||
|
|
||||||
@@ -212,7 +211,7 @@ public extension CoreStore {
|
|||||||
Asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType` built from a chain of clauses.
|
Asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType` built from a chain of clauses.
|
||||||
```
|
```
|
||||||
CoreStore.monitorSectionedList(
|
CoreStore.monitorSectionedList(
|
||||||
{ (monitor) in
|
createAsynchronously: { (monitor) in
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
},
|
},
|
||||||
From<MyPersonEntity>()
|
From<MyPersonEntity>()
|
||||||
@@ -221,8 +220,8 @@ public extension CoreStore {
|
|||||||
.orderBy(.ascending(\.age))
|
.orderBy(.ascending(\.age))
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
|
||||||
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
|
||||||
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType`
|
|
||||||
*/
|
*/
|
||||||
public static func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
public static func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
||||||
|
|
||||||
|
|||||||
@@ -80,11 +80,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D? {
|
public static func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
|
||||||
|
|
||||||
return self.defaultStack.fetchOne(from, fetchClauses)
|
return try self.defaultStack.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,11 +93,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D? {
|
public static func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
|
||||||
|
|
||||||
return self.defaultStack.fetchOne(from, fetchClauses)
|
return try self.defaultStack.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,11 +111,12 @@ public extension CoreStore {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
|
public static func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? {
|
||||||
|
|
||||||
return self.defaultStack.fetchOne(clauseChain)
|
return try self.defaultStack.fetchOne(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,11 +124,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]? {
|
public static func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
|
||||||
|
|
||||||
return self.defaultStack.fetchAll(from, fetchClauses)
|
return try self.defaultStack.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,11 +137,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]? {
|
public static func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
|
||||||
|
|
||||||
return self.defaultStack.fetchAll(from, fetchClauses)
|
return try self.defaultStack.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,11 +155,12 @@ public extension CoreStore {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]? {
|
public static func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
|
||||||
|
|
||||||
return self.defaultStack.fetchAll(clauseChain)
|
return try self.defaultStack.fetchAll(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,11 +168,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int? {
|
public static func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
|
||||||
|
|
||||||
return self.defaultStack.fetchCount(from, fetchClauses)
|
return try self.defaultStack.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,11 +181,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int? {
|
public static func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
|
||||||
|
|
||||||
return self.defaultStack.fetchCount(from, fetchClauses)
|
return try self.defaultStack.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,11 +199,12 @@ public extension CoreStore {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
|
public static func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
|
||||||
|
|
||||||
return self.defaultStack.fetchCount(clauseChain)
|
return try self.defaultStack.fetchCount(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,11 +212,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
public static func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectID(from, fetchClauses)
|
return try self.defaultStack.fetchObjectID(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,11 +225,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
public static func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectID(from, fetchClauses)
|
return try self.defaultStack.fetchObjectID(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -232,11 +243,12 @@ public extension CoreStore {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
|
public static func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectID(clauseChain)
|
return try self.defaultStack.fetchObjectID(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,11 +256,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
public static func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
|
return try self.defaultStack.fetchObjectIDs(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,11 +269,12 @@ public extension CoreStore {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
public static func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectIDs(from, fetchClauses)
|
return try self.defaultStack.fetchObjectIDs(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,11 +287,12 @@ public extension CoreStore {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
|
public static func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
return self.defaultStack.fetchObjectIDs(clauseChain)
|
return try self.defaultStack.fetchObjectIDs(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -288,11 +303,12 @@ public extension CoreStore {
|
|||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U? {
|
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
|
||||||
|
|
||||||
return self.defaultStack.queryValue(from, selectClause, queryClauses)
|
return try self.defaultStack.queryValue(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -303,11 +319,12 @@ public extension CoreStore {
|
|||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U? {
|
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
|
||||||
|
|
||||||
return self.defaultStack.queryValue(from, selectClause, queryClauses)
|
return try self.defaultStack.queryValue(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -322,11 +339,12 @@ public extension CoreStore {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
|
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
|
||||||
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
|
- returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType {
|
public static func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType {
|
||||||
|
|
||||||
return self.defaultStack.queryValue(clauseChain)
|
return try self.defaultStack.queryValue(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -338,10 +356,11 @@ public extension CoreStore {
|
|||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
|
||||||
|
|
||||||
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
return try self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -353,10 +372,11 @@ public extension CoreStore {
|
|||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
|
||||||
|
|
||||||
return self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
return try self.defaultStack.queryAttributes(from, selectClause, queryClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -381,9 +401,10 @@ public extension CoreStore {
|
|||||||
```
|
```
|
||||||
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request.
|
- 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`
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public static func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary {
|
public static func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary {
|
||||||
|
|
||||||
return self.defaultStack.queryAttributes(clauseChain)
|
return try self.defaultStack.queryAttributes(clauseChain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,11 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
|
|||||||
*/
|
*/
|
||||||
case userCancelled
|
case userCancelled
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempted to perform a fetch but could not find any related persistent store.
|
||||||
|
*/
|
||||||
|
case persistentStoreNotFound(entity: DynamicObject.Type)
|
||||||
|
|
||||||
|
|
||||||
// MARK: CustomNSError
|
// MARK: CustomNSError
|
||||||
|
|
||||||
@@ -109,6 +114,9 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
|
|||||||
|
|
||||||
case .userCancelled:
|
case .userCancelled:
|
||||||
return CoreStoreErrorCode.userCancelled.rawValue
|
return CoreStoreErrorCode.userCancelled.rawValue
|
||||||
|
|
||||||
|
case .persistentStoreNotFound:
|
||||||
|
return CoreStoreErrorCode.persistentStoreNotFound.rawValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +162,11 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
|
|||||||
|
|
||||||
case .userCancelled:
|
case .userCancelled:
|
||||||
return [:]
|
return [:]
|
||||||
|
|
||||||
|
case .persistentStoreNotFound(let entity):
|
||||||
|
return [
|
||||||
|
"entity": entity
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +209,9 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
|
|||||||
case (.userCancelled, .userCancelled):
|
case (.userCancelled, .userCancelled):
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
case (.persistentStoreNotFound(let entity1), .persistentStoreNotFound(let entity2)):
|
||||||
|
return entity1 == entity2
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -233,6 +249,9 @@ public enum CoreStoreError: Error, CustomNSError, Hashable {
|
|||||||
case .userError(let error):
|
case .userError(let error):
|
||||||
hasher.combine(error as NSError)
|
hasher.combine(error as NSError)
|
||||||
|
|
||||||
|
case .persistentStoreNotFound(let entity):
|
||||||
|
hasher.combine(ObjectIdentifier(entity))
|
||||||
|
|
||||||
case .userCancelled:
|
case .userCancelled:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -303,6 +322,11 @@ public enum CoreStoreErrorCode: Int {
|
|||||||
The transaction was cancelled by the user.
|
The transaction was cancelled by the user.
|
||||||
*/
|
*/
|
||||||
case userCancelled
|
case userCancelled
|
||||||
|
|
||||||
|
/**
|
||||||
|
Attempted to perform a fetch but could not find any related persistent store.
|
||||||
|
*/
|
||||||
|
case persistentStoreNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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 from.applyAffectedStoresForFetchedRequest(fetchRequest, context: context)
|
try from.applyAffectedStoresForFetchedRequest(fetchRequest, context: context)
|
||||||
}
|
}
|
||||||
|
|
||||||
super.init(
|
super.init(
|
||||||
@@ -72,13 +72,7 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
|||||||
@nonobjc
|
@nonobjc
|
||||||
internal func performFetchFromSpecifiedStores() throws {
|
internal func performFetchFromSpecifiedStores() throws {
|
||||||
|
|
||||||
if !self.reapplyAffectedStores(self.fetchRequest, self.managedObjectContext) {
|
try self.reapplyAffectedStores(self.fetchRequest, self.managedObjectContext)
|
||||||
|
|
||||||
CoreStore.log(
|
|
||||||
.warning,
|
|
||||||
message: "Attempted to perform a fetch on an \(cs_typeName(self)) but could not find any persistent store for the entity \(cs_typeName(self.fetchRequest.entityName))"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
try self.performFetch()
|
try self.performFetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,5 +91,5 @@ internal final class CoreStoreFetchedResultsController: NSFetchedResultsControll
|
|||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
private let reapplyAffectedStores: (_ fetchRequest: NSFetchRequest<NSManagedObject>, _ context: NSManagedObjectContext) -> Bool
|
private let reapplyAffectedStores: (_ fetchRequest: NSFetchRequest<NSManagedObject>, _ context: NSManagedObjectContext) throws -> Void
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public extension DataStack {
|
|||||||
|
|
||||||
```
|
```
|
||||||
dataStack.monitorList(
|
dataStack.monitorList(
|
||||||
{ (monitor) in
|
createAsynchronously: { (monitor) in
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
},
|
},
|
||||||
From<MyPersonEntity>()
|
From<MyPersonEntity>()
|
||||||
@@ -162,7 +162,6 @@ public extension DataStack {
|
|||||||
```
|
```
|
||||||
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
|
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
|
||||||
*/
|
*/
|
||||||
public func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
public func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
||||||
|
|
||||||
@@ -288,7 +287,7 @@ public extension DataStack {
|
|||||||
Asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType` built from a chain of clauses.
|
Asynchronously creates a `ListMonitor` for a sectioned list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType` built from a chain of clauses.
|
||||||
```
|
```
|
||||||
dataStack.monitorSectionedList(
|
dataStack.monitorSectionedList(
|
||||||
{ (monitor) in
|
createAsynchronously: { (monitor) in
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
},
|
},
|
||||||
From<MyPersonEntity>()
|
From<MyPersonEntity>()
|
||||||
@@ -297,8 +296,8 @@ public extension DataStack {
|
|||||||
.orderBy(.ascending(\.age))
|
.orderBy(.ascending(\.age))
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
|
||||||
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
|
||||||
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType`
|
|
||||||
*/
|
*/
|
||||||
public func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
public func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
||||||
|
|
||||||
|
|||||||
@@ -82,15 +82,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D? {
|
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchOne(from, fetchClauses)
|
return try self.mainContext.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,15 +99,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D? {
|
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchOne(from, fetchClauses)
|
return try self.mainContext.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,15 +121,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
|
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchOne(clauseChain)
|
return try self.mainContext.fetchOne(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,15 +138,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]? {
|
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchAll(from, fetchClauses)
|
return try self.mainContext.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,15 +155,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]? {
|
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchAll(from, fetchClauses)
|
return try self.mainContext.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,15 +177,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]? {
|
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchAll(clauseChain)
|
return try self.mainContext.fetchAll(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,15 +194,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int? {
|
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchCount(from, fetchClauses)
|
return try self.mainContext.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,15 +211,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int? {
|
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchCount(from, fetchClauses)
|
return try self.mainContext.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,15 +233,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
|
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
|
||||||
|
|
||||||
CoreStore.assert(
|
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.fetchCount(clauseChain)
|
return try self.mainContext.fetchCount(clauseChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -241,15 +250,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID? {
|
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,15 +267,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID? {
|
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,15 +289,16 @@ 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`, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
|
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -294,15 +306,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -310,15 +323,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -331,15 +345,16 @@ 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`, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -353,15 +368,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U? {
|
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -372,15 +388,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U? {
|
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,15 +412,16 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
|
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
|
||||||
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
|
- returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType {
|
public func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -415,14 +433,15 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]? {
|
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -434,14 +453,15 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]? {
|
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -466,14 +486,15 @@ extension DataStack: FetchableSource, QueryableSource {
|
|||||||
```
|
```
|
||||||
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request.
|
- 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`
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
public func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary {
|
public func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary {
|
||||||
|
|
||||||
CoreStore.assert(
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,18 +71,20 @@ public protocol FetchableSource: class {
|
|||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D?
|
func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D?
|
func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
|
Fetches the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
|
||||||
@@ -94,27 +96,30 @@ public protocol FetchableSource: class {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`
|
- returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType?
|
func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]?
|
func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]?
|
func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
|
Fetches all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
|
||||||
@@ -126,27 +131,30 @@ public protocol FetchableSource: class {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`
|
- returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) -> [B.ObjectType]?
|
func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int?
|
func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int?
|
func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
|
Fetches the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
|
||||||
@@ -158,27 +166,30 @@ public protocol FetchableSource: class {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
- returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int?
|
func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSManagedObjectID?
|
func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSManagedObjectID?
|
func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
|
Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses.
|
||||||
@@ -190,27 +201,30 @@ public protocol FetchableSource: class {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`
|
- returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID?
|
func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]?
|
func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
|
|
||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
- parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses.
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [NSManagedObjectID]?
|
func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
|
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.
|
||||||
@@ -222,9 +236,10 @@ public protocol FetchableSource: class {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`
|
- returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]?
|
func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The internal `NSManagedObjectContext` managed by this `FetchableSource`. Using this context directly should typically be avoided, and is provided by CoreStore only for extremely specialized cases.
|
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.
|
||||||
|
|||||||
+22
-11
@@ -139,29 +139,40 @@ public struct From<D: DynamicObject> {
|
|||||||
self.findPersistentStores = findPersistentStores
|
self.findPersistentStores = findPersistentStores
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func applyToFetchRequest<ResultType>(_ fetchRequest: NSFetchRequest<ResultType>, context: NSManagedObjectContext, applyAffectedStores: Bool = true) -> Bool {
|
internal func applyToFetchRequest<U>(_ fetchRequest: NSFetchRequest<U>, context: NSManagedObjectContext, applyAffectedStores: Bool = true) throws {
|
||||||
|
|
||||||
fetchRequest.entity = context.parentStack!.entityDescription(for: EntityIdentifier(self.entityClass))!
|
fetchRequest.entity = context.parentStack!.entityDescription(for: EntityIdentifier(self.entityClass))!
|
||||||
guard applyAffectedStores else {
|
guard applyAffectedStores else {
|
||||||
|
|
||||||
return true
|
return
|
||||||
}
|
}
|
||||||
if self.applyAffectedStoresForFetchedRequest(fetchRequest, context: context) {
|
do {
|
||||||
|
|
||||||
return true
|
try self.applyAffectedStoresForFetchedRequest(fetchRequest, context: context)
|
||||||
|
}
|
||||||
|
catch let error as CoreStoreError {
|
||||||
|
|
||||||
|
CoreStore.log(
|
||||||
|
error,
|
||||||
|
"Attempted to perform a fetch but could not find any persistent store for the entity \(cs_typeName(fetchRequest.entityName))"
|
||||||
|
)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
CoreStore.log(
|
|
||||||
.warning,
|
|
||||||
message: "Attempted to perform a fetch but could not find any persistent store for the entity \(cs_typeName(fetchRequest.entityName))"
|
|
||||||
)
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func applyAffectedStoresForFetchedRequest<U>(_ fetchRequest: NSFetchRequest<U>, context: NSManagedObjectContext) -> Bool {
|
internal func applyAffectedStoresForFetchedRequest<U>(_ fetchRequest: NSFetchRequest<U>, context: NSManagedObjectContext) throws {
|
||||||
|
|
||||||
let stores = self.findPersistentStores(context)
|
let stores = self.findPersistentStores(context)
|
||||||
fetchRequest.affectedStores = stores
|
fetchRequest.affectedStores = stores
|
||||||
return stores?.isEmpty == false
|
if stores?.isEmpty == false {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
throw CoreStoreError.persistentStoreNotFound(entity: self.entityClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+103
-22
@@ -136,7 +136,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
*/
|
*/
|
||||||
public subscript(safeSectionIndex sectionIndex: Int, safeItemIndex itemIndex: Int) -> ObjectType? {
|
public subscript(safeSectionIndex sectionIndex: Int, safeItemIndex itemIndex: Int) -> ObjectType? {
|
||||||
|
|
||||||
guard let section = self.sectionInfoAtIndex(safeSectionIndex: sectionIndex) else {
|
guard let section = self.sectionInfo(safelyAt: sectionIndex) else {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -202,9 +202,9 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will return `false`.
|
- parameter section: the section index. Using an index outside the valid range will return `false`.
|
||||||
- returns: `true` if at least one object in the specified section exists, `false` otherwise
|
- returns: `true` if at least one object in the specified section exists, `false` otherwise
|
||||||
*/
|
*/
|
||||||
public func hasObjectsInSection(_ section: Int) -> Bool {
|
public func hasObjects(in section: Int) -> Bool {
|
||||||
|
|
||||||
return self.numberOfObjectsInSection(safeSectionIndex: section)! > 0
|
return self.numberOfObjects(safelyIn: section)! > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -241,9 +241,9 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
||||||
- returns: the number of objects in the specified section
|
- returns: the number of objects in the specified section
|
||||||
*/
|
*/
|
||||||
public func numberOfObjectsInSection(_ section: Int) -> Int {
|
public func numberOfObjects(in section: Int) -> Int {
|
||||||
|
|
||||||
return self.sectionInfoAtIndex(section).numberOfObjects
|
return self.sectionInfo(at: section).numberOfObjects
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,9 +252,9 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
||||||
- returns: the number of objects in the specified section
|
- returns: the number of objects in the specified section
|
||||||
*/
|
*/
|
||||||
public func numberOfObjectsInSection(safeSectionIndex section: Int) -> Int? {
|
public func numberOfObjects(safelyIn section: Int) -> Int? {
|
||||||
|
|
||||||
return self.sectionInfoAtIndex(safeSectionIndex: section)?.numberOfObjects
|
return self.sectionInfo(safelyAt: section)?.numberOfObjects
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,7 +263,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
||||||
- returns: the `NSFetchedResultsSectionInfo` for the specified section
|
- returns: the `NSFetchedResultsSectionInfo` for the specified section
|
||||||
*/
|
*/
|
||||||
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
|
public func sectionInfo(at section: Int) -> NSFetchedResultsSectionInfo {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isPendingRefetch || Thread.isMainThread,
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
@@ -278,7 +278,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
||||||
- returns: the `NSFetchedResultsSectionInfo` for the specified section, or `nil` if the section index is out of bounds.
|
- returns: the `NSFetchedResultsSectionInfo` for the specified section, or `nil` if the section index is out of bounds.
|
||||||
*/
|
*/
|
||||||
public func sectionInfoAtIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? {
|
public func sectionInfo(safelyAt section: Int) -> NSFetchedResultsSectionInfo? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isPendingRefetch || Thread.isMainThread,
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
@@ -312,17 +312,17 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
/**
|
/**
|
||||||
Returns the target section for a specified "Section Index" title and index.
|
Returns the target section for a specified "Section Index" title and index.
|
||||||
|
|
||||||
- parameter title: the title of the Section Index
|
- parameter sectionIndexTitle: the title of the Section Index
|
||||||
- parameter index: the index of the Section Index
|
- parameter sectionIndex: the index of the Section Index
|
||||||
- returns: the target section for the specified "Section Index" title and index.
|
- returns: the target section for the specified "Section Index" title and index.
|
||||||
*/
|
*/
|
||||||
public func targetSectionForSectionIndex(title: String, index: Int) -> Int {
|
public func targetSection(forSectionIndexTitle sectionIndexTitle: String, at sectionIndex: Int) -> Int {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isPendingRefetch || Thread.isMainThread,
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
)
|
)
|
||||||
return self.fetchedResultsController.section(forSectionIndexTitle: title, at: index)
|
return self.fetchedResultsController.section(forSectionIndexTitle: sectionIndexTitle, at: sectionIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -345,7 +345,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
- parameter object: the `DynamicObject` to search the index of
|
- parameter object: the `DynamicObject` to search the index of
|
||||||
- returns: the index of the `DynamicObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
- returns: the index of the `DynamicObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
public func indexOf(_ object: ObjectType) -> Int? {
|
public func index(of object: ObjectType) -> Int? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isPendingRefetch || Thread.isMainThread,
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
@@ -364,7 +364,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
- parameter object: the `DynamicObject` to search the index of
|
- parameter object: the `DynamicObject` to search the index of
|
||||||
- returns: the `IndexPath` of the `DynamicObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
- returns: the `IndexPath` of the `DynamicObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
||||||
*/
|
*/
|
||||||
public func indexPathOf(_ object: ObjectType) -> IndexPath? {
|
public func indexPath(of object: ObjectType) -> IndexPath? {
|
||||||
|
|
||||||
CoreStore.assert(
|
CoreStore.assert(
|
||||||
!self.isPendingRefetch || Thread.isMainThread,
|
!self.isPendingRefetch || Thread.isMainThread,
|
||||||
@@ -1164,6 +1164,57 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
try! self.fetchedResultsController.performFetchFromSpecifiedStores()
|
try! self.fetchedResultsController.performFetchFromSpecifiedStores()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Deprecated
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "hasObjects(in:)")
|
||||||
|
public func hasObjectsInSection(_ section: Int) -> Bool {
|
||||||
|
|
||||||
|
return self.hasObjects(in: section)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "numberOfObjects(in:)")
|
||||||
|
public func numberOfObjectsInSection(_ section: Int) -> Int {
|
||||||
|
|
||||||
|
return self.numberOfObjects(in: section)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "numberOfObjects(safelyIn:)")
|
||||||
|
public func numberOfObjectsInSection(safeSectionIndex section: Int) -> Int? {
|
||||||
|
|
||||||
|
return self.numberOfObjects(safelyIn: section)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "sectionInfo(at:)")
|
||||||
|
public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo {
|
||||||
|
|
||||||
|
return self.sectionInfo(at: section)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "sectionInfo(safelyAt:)")
|
||||||
|
public func sectionInfoAtIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo? {
|
||||||
|
|
||||||
|
return self.sectionInfo(safelyAt: section)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "targetSection(forSectionIndexTitle:at:)")
|
||||||
|
public func targetSectionForSectionIndex(title: String, index: Int) -> Int {
|
||||||
|
|
||||||
|
return self.targetSection(forSectionIndexTitle: title, at: index)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "index(of:)")
|
||||||
|
public func indexOf(_ object: ObjectType) -> Int? {
|
||||||
|
|
||||||
|
return self.index(of: object)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "indexPath(of:)")
|
||||||
|
public func indexPathOf(_ object: ObjectType) -> IndexPath? {
|
||||||
|
|
||||||
|
return self.indexPath(of: object)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1192,9 +1243,9 @@ extension ListMonitor where ListMonitor.ObjectType: NSManagedObject {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
||||||
- returns: all objects in the specified section
|
- returns: all objects in the specified section
|
||||||
*/
|
*/
|
||||||
public func objectsInSection(_ section: Int) -> [ObjectType] {
|
public func objects(in section: Int) -> [ObjectType] {
|
||||||
|
|
||||||
return (self.sectionInfoAtIndex(section).objects as! [ObjectType]?) ?? []
|
return (self.sectionInfo(at: section).objects as! [ObjectType]?) ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1203,9 +1254,24 @@ extension ListMonitor where ListMonitor.ObjectType: NSManagedObject {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
||||||
- returns: all objects in the specified section
|
- returns: all objects in the specified section
|
||||||
*/
|
*/
|
||||||
|
public func objects(safelyIn section: Int) -> [ObjectType]? {
|
||||||
|
|
||||||
|
return self.sectionInfo(safelyAt: section)?.objects as! [ObjectType]?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Deprecated
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "objects(in:)")
|
||||||
|
public func objectsInSection(_ section: Int) -> [ObjectType] {
|
||||||
|
|
||||||
|
return self.objects(in: section)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "objects(safelyIn:)")
|
||||||
public func objectsInSection(safeSectionIndex section: Int) -> [ObjectType]? {
|
public func objectsInSection(safeSectionIndex section: Int) -> [ObjectType]? {
|
||||||
|
|
||||||
return self.sectionInfoAtIndex(safeSectionIndex: section)?.objects as! [ObjectType]?
|
return self.objects(safelyIn: section)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1236,9 +1302,9 @@ extension ListMonitor where ListMonitor.ObjectType: CoreStoreObject {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
- parameter section: the section index. Using an index outside the valid range will raise an exception.
|
||||||
- returns: all objects in the specified section
|
- returns: all objects in the specified section
|
||||||
*/
|
*/
|
||||||
public func objectsInSection(_ section: Int) -> [ObjectType] {
|
public func objects(in section: Int) -> [ObjectType] {
|
||||||
|
|
||||||
return (self.sectionInfoAtIndex(section).objects ?? [])
|
return (self.sectionInfo(at: section).objects ?? [])
|
||||||
.map({ ObjectType.cs_fromRaw(object: $0 as! NSManagedObject) })
|
.map({ ObjectType.cs_fromRaw(object: $0 as! NSManagedObject) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1248,10 +1314,25 @@ extension ListMonitor where ListMonitor.ObjectType: CoreStoreObject {
|
|||||||
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
- parameter section: the section index. Using an index outside the valid range will return `nil`.
|
||||||
- returns: all objects in the specified section
|
- returns: all objects in the specified section
|
||||||
*/
|
*/
|
||||||
|
public func objects(safelyIn section: Int) -> [ObjectType]? {
|
||||||
|
|
||||||
|
return (self.sectionInfo(safelyAt: section)?.objects)?
|
||||||
|
.map({ ObjectType.cs_fromRaw(object: $0 as! NSManagedObject) })
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Deprecated
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "objects(in:)")
|
||||||
|
public func objectsInSection(_ section: Int) -> [ObjectType] {
|
||||||
|
|
||||||
|
return self.objects(in: section)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "objects(safelyIn:)")
|
||||||
public func objectsInSection(safeSectionIndex section: Int) -> [ObjectType]? {
|
public func objectsInSection(safeSectionIndex section: Int) -> [ObjectType]? {
|
||||||
|
|
||||||
return (self.sectionInfoAtIndex(safeSectionIndex: section)?.objects)?
|
return self.objects(safelyIn: section)
|
||||||
.map({ ObjectType.cs_fromRaw(object: $0 as! NSManagedObject) })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,92 +34,72 @@ internal extension NSManagedObjectContext {
|
|||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func fetchOne(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> NSManagedObject? {
|
internal func fetchOne(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> NSManagedObject? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 1
|
fetchRequest.fetchLimit = 1
|
||||||
fetchRequest.resultType = .managedObjectResultType
|
fetchRequest.resultType = .managedObjectResultType
|
||||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||||
|
|
||||||
guard storeFound else {
|
return try self.fetchOne(fetchRequest.dynamicCast())
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return self.fetchOne(fetchRequest.dynamicCast())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func fetchAll<T: NSManagedObject>(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> [T]? {
|
internal func fetchAll<T: NSManagedObject>(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> [T] {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let 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
|
||||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||||
|
|
||||||
guard storeFound else {
|
return try self.fetchAll(fetchRequest.dynamicCast())
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return self.fetchAll(fetchRequest.dynamicCast())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func fetchCount(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> Int? {
|
internal func fetchCount(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> Int {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
try from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
||||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||||
|
|
||||||
guard storeFound else {
|
return try self.fetchCount(fetchRequest.dynamicCast())
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return self.fetchCount(fetchRequest.dynamicCast())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func fetchObjectID(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> NSManagedObjectID? {
|
internal func fetchObjectID(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.bridgeToSwift.applyToFetchRequest(fetchRequest, context: self)
|
try from.bridgeToSwift.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
|
||||||
internal func fetchObjectIDs(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) -> [NSManagedObjectID]? {
|
internal func fetchObjectIDs(_ from: CSFrom, _ fetchClauses: [CSFetchClause]) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
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 = .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
|
||||||
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
|
||||||
@@ -127,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())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,152 +101,130 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> D? {
|
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
|
||||||
|
|
||||||
return self.fetchOne(from, fetchClauses)
|
return try self.fetchOne(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> D? {
|
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
try from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
|
|
||||||
fetchRequest.fetchLimit = 1
|
fetchRequest.fetchLimit = 1
|
||||||
fetchRequest.resultType = .managedObjectResultType
|
fetchRequest.resultType = .managedObjectResultType
|
||||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||||
|
|
||||||
guard storeFound else {
|
return try self.fetchOne(fetchRequest.dynamicCast()).flatMap(from.entityClass.cs_fromRaw)
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return self.fetchOne(fetchRequest.dynamicCast()).flatMap(from.entityClass.cs_fromRaw)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) -> B.ObjectType? {
|
public func fetchOne<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> B.ObjectType? {
|
||||||
|
|
||||||
return self.fetchOne(clauseChain.from, clauseChain.fetchClauses)
|
return try self.fetchOne(clauseChain.from, clauseChain.fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [D]? {
|
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
|
||||||
|
|
||||||
return self.fetchAll(from, fetchClauses)
|
return try self.fetchAll(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> [D]? {
|
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let 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
|
||||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||||
|
|
||||||
guard storeFound else {
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
let entityClass = from.entityClass
|
let entityClass = from.entityClass
|
||||||
return 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) -> [B.ObjectType]? {
|
public func fetchAll<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [B.ObjectType] {
|
||||||
|
|
||||||
return self.fetchAll(clauseChain.from, clauseChain.fetchClauses)
|
return try self.fetchAll(clauseChain.from, clauseChain.fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> Int? {
|
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
|
||||||
|
|
||||||
return self.fetchCount(from, fetchClauses)
|
return try self.fetchCount(from, fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> Int? {
|
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
|
||||||
|
|
||||||
let fetchRequest = CoreStoreFetchRequest()
|
let fetchRequest = CoreStoreFetchRequest()
|
||||||
let storeFound = from.applyToFetchRequest(fetchRequest, context: self)
|
try from.applyToFetchRequest(fetchRequest, context: self)
|
||||||
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
|
||||||
|
|
||||||
guard storeFound else {
|
return try self.fetchCount(fetchRequest.dynamicCast())
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return self.fetchCount(fetchRequest.dynamicCast())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) -> Int? {
|
public func fetchCount<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> Int {
|
||||||
|
|
||||||
return self.fetchCount(clauseChain.from, clauseChain.fetchClauses)
|
return try self.fetchCount(clauseChain.from, clauseChain.fetchClauses)
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@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())
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: docs
|
|
||||||
@nonobjc
|
|
||||||
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) -> NSManagedObjectID? {
|
|
||||||
|
|
||||||
return self.fetchObjectID(clauseChain.from, clauseChain.fetchClauses)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> [NSManagedObjectID]? {
|
public func fetchObjectID<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> NSManagedObjectID? {
|
||||||
|
|
||||||
return self.fetchObjectIDs(from, 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 try self.fetchObjectIDs(from, fetchClauses)
|
||||||
|
}
|
||||||
|
|
||||||
|
@nonobjc
|
||||||
|
public func fetchObjectIDs<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 = 0
|
fetchRequest.fetchLimit = 0
|
||||||
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())
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: docs
|
|
||||||
@nonobjc
|
|
||||||
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) -> [NSManagedObjectID]? {
|
|
||||||
|
|
||||||
return self.fetchObjectIDs(clauseChain.from, clauseChain.fetchClauses)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func fetchObjectIDs(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) -> [NSManagedObjectID]? {
|
public func fetchObjectIDs<B: FetchChainableBuilderType>(_ clauseChain: B) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
|
return try self.fetchObjectIDs(clauseChain.from, clauseChain.fetchClauses)
|
||||||
|
}
|
||||||
|
|
||||||
|
@nonobjc
|
||||||
|
internal func fetchObjectIDs(_ fetchRequest: NSFetchRequest<NSManagedObjectID>) throws -> [NSManagedObjectID] {
|
||||||
|
|
||||||
var fetchResults: [NSManagedObjectID]?
|
var fetchResults: [NSManagedObjectID]?
|
||||||
var fetchError: Error?
|
var fetchError: Error?
|
||||||
@@ -261,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -347,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
|
||||||
@@ -358,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())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -383,7 +350,7 @@ internal extension NSManagedObjectContext {
|
|||||||
// MARK: Fetching
|
// MARK: Fetching
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func fetchOne<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) -> D? {
|
internal func fetchOne<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) throws -> D? {
|
||||||
|
|
||||||
var fetchResults: [D]?
|
var fetchResults: [D]?
|
||||||
var fetchError: Error?
|
var fetchError: Error?
|
||||||
@@ -398,19 +365,20 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func fetchAll<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) -> [D]? {
|
internal func fetchAll<D: NSManagedObject>(_ fetchRequest: NSFetchRequest<D>) throws -> [D] {
|
||||||
|
|
||||||
var fetchResults: [D]?
|
var fetchResults: [D]?
|
||||||
var fetchError: Error?
|
var fetchError: Error?
|
||||||
@@ -425,19 +393,20 @@ internal extension NSManagedObjectContext {
|
|||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal func fetchCount(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> Int? {
|
internal func fetchCount(_ fetchRequest: NSFetchRequest<NSFetchRequestResult>) throws -> Int {
|
||||||
|
|
||||||
var count = 0
|
var count = 0
|
||||||
var countError: Error?
|
var countError: Error?
|
||||||
@@ -454,17 +423,18 @@ internal extension NSManagedObjectContext {
|
|||||||
}
|
}
|
||||||
if count == NSNotFound {
|
if count == NSNotFound {
|
||||||
|
|
||||||
|
let coreStoreError = CoreStoreError(countError)
|
||||||
CoreStore.log(
|
CoreStore.log(
|
||||||
CoreStoreError(countError),
|
coreStoreError,
|
||||||
"Failed executing count request."
|
"Failed executing count request."
|
||||||
)
|
)
|
||||||
return nil
|
throw coreStoreError
|
||||||
}
|
}
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
@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?
|
||||||
@@ -479,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?
|
||||||
@@ -518,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?
|
||||||
@@ -551,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?
|
||||||
@@ -579,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?
|
||||||
@@ -614,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,10 @@ public protocol QueryableSource: class {
|
|||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) -> U?
|
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
Queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
@@ -54,9 +55,10 @@ public protocol QueryableSource: class {
|
|||||||
- parameter from: a `From` clause indicating the entity type
|
- parameter from: a `From` clause indicating the entity type
|
||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
- returns: the result of the the query. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
- returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select<U>` parameter.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) -> U?
|
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries a property value or aggregate as specified by the `QueryChainableBuilderType` built from a chain of clauses.
|
Queries a property value or aggregate as specified by the `QueryChainableBuilderType` built from a chain of clauses.
|
||||||
@@ -70,9 +72,10 @@ public protocol QueryableSource: class {
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
|
- parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request.
|
||||||
- returns: the result of the the query as specified by the `QueryChainableBuilderType`
|
- returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) -> B.ResultType? where B.ResultType: QueryableAttributeType
|
func queryValue<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
@@ -83,8 +86,9 @@ public protocol QueryableSource: class {
|
|||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) -> [[String: Any]]?
|
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
||||||
@@ -95,8 +99,9 @@ public protocol QueryableSource: class {
|
|||||||
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
- parameter selectClause: a `Select<U>` clause indicating the properties to fetch, and with the generic type indicating the return type.
|
||||||
- parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses.
|
- 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.
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) -> [[String: Any]]?
|
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Queries a dictionary of attribute values or as specified by the `QueryChainableBuilderType` built from a chain of clauses.
|
Queries a dictionary of attribute values or as specified by the `QueryChainableBuilderType` built from a chain of clauses.
|
||||||
@@ -120,8 +125,9 @@ public protocol QueryableSource: class {
|
|||||||
```
|
```
|
||||||
- parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request.
|
- 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`
|
||||||
|
- throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema.
|
||||||
*/
|
*/
|
||||||
func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) -> [[String: Any]]? where B.ResultType == NSDictionary
|
func queryAttributes<B: QueryChainableBuilderType>(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The internal `NSManagedObjectContext` managed by this `QueryableSource`. Using this context directly should typically be avoided, and is provided by CoreStore only for extremely specialized cases.
|
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.
|
||||||
|
|||||||
@@ -298,6 +298,9 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - SelectTerm where D: NSManagedObject
|
||||||
|
|
||||||
extension SelectTerm where D: NSManagedObject {
|
extension SelectTerm where D: NSManagedObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -366,6 +369,9 @@ extension SelectTerm where D: NSManagedObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: - SelectTerm where D: CoreStoreObject
|
||||||
|
|
||||||
extension SelectTerm where D: CoreStoreObject {
|
extension SelectTerm where D: CoreStoreObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -143,7 +143,22 @@ public extension UnsafeDataTransaction {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: docs
|
/**
|
||||||
|
Asynchronously creates a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses. Since `NSFetchedResultsController` greedily locks the persistent store on initial fetch, you may prefer this method instead of the synchronous counterpart to avoid deadlocks while background updates/saves are being executed.
|
||||||
|
|
||||||
|
```
|
||||||
|
dataStack.monitorList(
|
||||||
|
createAsynchronously: { (monitor) in
|
||||||
|
self.monitor = monitor
|
||||||
|
},
|
||||||
|
From<MyPersonEntity>()
|
||||||
|
.where(\.age > 18)
|
||||||
|
.orderBy(.ascending(\.age))
|
||||||
|
)
|
||||||
|
```
|
||||||
|
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
|
||||||
|
- parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses
|
||||||
|
*/
|
||||||
public func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
public func monitorList<B: FetchChainableBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
||||||
|
|
||||||
self.monitorList(
|
self.monitorList(
|
||||||
@@ -267,8 +282,8 @@ public extension UnsafeDataTransaction {
|
|||||||
.orderBy(.ascending(\.age))
|
.orderBy(.ascending(\.age))
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
- parameter createAsynchronously: the closure that receives the created `ListMonitor` instance
|
||||||
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
|
- parameter clauseChain: a `SectionMonitorBuilderType` built from a chain of clauses
|
||||||
- returns: a `ListMonitor` for a list of `DynamicObject`s that satisfy the specified `SectionMonitorBuilderType`
|
|
||||||
*/
|
*/
|
||||||
public func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
public func monitorSectionedList<B: SectionMonitorBuilderType>(createAsynchronously: @escaping (ListMonitor<B.ObjectType>) -> Void, _ clauseChain: B) {
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -541,7 +541,7 @@ public extension Sequence where Iterator.Element: WhereClauseType {
|
|||||||
|
|
||||||
public extension Where {
|
public extension Where {
|
||||||
|
|
||||||
@available(*, deprecated: 4.0, renamed: "&&?")
|
@available(*, deprecated, renamed: "&&?")
|
||||||
public static func && (left: Where<D>, right: Where<D>?) -> Where<D> {
|
public static func && (left: Where<D>, right: Where<D>?) -> Where<D> {
|
||||||
|
|
||||||
if let right = right {
|
if let right = right {
|
||||||
@@ -551,7 +551,7 @@ public extension Where {
|
|||||||
return left
|
return left
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, deprecated: 4.0, renamed: "&&?")
|
@available(*, deprecated, renamed: "&&?")
|
||||||
public static func && (left: Where<D>?, right: Where<D>) -> Where<D> {
|
public static func && (left: Where<D>?, right: Where<D>) -> Where<D> {
|
||||||
|
|
||||||
if let left = left {
|
if let left = left {
|
||||||
@@ -561,7 +561,7 @@ public extension Where {
|
|||||||
return right
|
return right
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, deprecated: 4.0, renamed: "||?")
|
@available(*, deprecated, renamed: "||?")
|
||||||
public static func || (left: Where<D>, right: Where<D>?) -> Where<D> {
|
public static func || (left: Where<D>, right: Where<D>?) -> Where<D> {
|
||||||
|
|
||||||
if let right = right {
|
if let right = right {
|
||||||
@@ -571,7 +571,7 @@ public extension Where {
|
|||||||
return left
|
return left
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, deprecated: 4.0, renamed: "||?")
|
@available(*, deprecated, renamed: "||?")
|
||||||
public static func || (left: Where<D>?, right: Where<D>) -> Where<D> {
|
public static func || (left: Where<D>?, right: Where<D>) -> Where<D> {
|
||||||
|
|
||||||
if let left = left {
|
if let left = left {
|
||||||
|
|||||||
Reference in New Issue
Block a user