mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-19 07:27:02 +01:00
Merge branch 'prototype/queryBuilders' of github.com:JohnEstropia/CoreStore into prototype/queryBuilders
This commit is contained in:
@@ -2627,6 +2627,7 @@
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
@@ -2680,6 +2681,7 @@
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
@@ -2955,7 +2957,7 @@
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -2979,7 +2981,7 @@
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = 4;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
@@ -408,6 +408,7 @@
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -447,6 +448,7 @@
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
SWIFT_VERSION = 4.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
@@ -230,15 +230,15 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
|
||||
)
|
||||
]
|
||||
|
||||
private let queryingItems = [
|
||||
private let queryingItems: [(title: String, query: () -> Any)] = [
|
||||
(
|
||||
title: "Number of Time Zones",
|
||||
query: { () -> Any in
|
||||
|
||||
return Static.timeZonesStack.queryValue(
|
||||
From<TimeZone>(),
|
||||
Select<NSNumber>(.count(#keyPath(TimeZone.name)))
|
||||
)!
|
||||
From<TimeZone>()
|
||||
.select(NSNumber.self, .count(#keyPath(TimeZone.name)))
|
||||
)! as Any
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -246,10 +246,10 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
|
||||
query: { () -> Any in
|
||||
|
||||
return Static.timeZonesStack.queryValue(
|
||||
From<TimeZone>(),
|
||||
Select<String>(#keyPath(TimeZone.abbreviation)),
|
||||
Where("%K ENDSWITH[c] %@", #keyPath(TimeZone.name), "Tokyo")
|
||||
)!
|
||||
From<TimeZone>()
|
||||
.select(String.self, .attribute(#keyPath(TimeZone.abbreviation)))
|
||||
.where(format: "%K ENDSWITH[c] %@", #keyPath(TimeZone.name), "Tokyo")
|
||||
)! as Any
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -257,9 +257,13 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
|
||||
query: { () -> Any in
|
||||
|
||||
return Static.timeZonesStack.queryAttributes(
|
||||
From<TimeZone>(),
|
||||
Select<NSDictionary>(#keyPath(TimeZone.name), #keyPath(TimeZone.abbreviation)),
|
||||
OrderBy(.ascending(#keyPath(TimeZone.name)))
|
||||
From<TimeZone>()
|
||||
.select(
|
||||
NSDictionary.self,
|
||||
.attribute(#keyPath(TimeZone.name)),
|
||||
.attribute(#keyPath(TimeZone.abbreviation))
|
||||
)
|
||||
.orderBy(.ascending(#keyPath(TimeZone.name)))
|
||||
)!
|
||||
}
|
||||
),
|
||||
@@ -268,10 +272,17 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
|
||||
query: { () -> Any in
|
||||
|
||||
return Static.timeZonesStack.queryAttributes(
|
||||
From<TimeZone>(),
|
||||
Select<NSDictionary>(.count(#keyPath(TimeZone.abbreviation)), #keyPath(TimeZone.abbreviation)),
|
||||
GroupBy(#keyPath(TimeZone.abbreviation)),
|
||||
OrderBy(.ascending(#keyPath(TimeZone.secondsFromGMT)), .ascending(#keyPath(TimeZone.name)))
|
||||
From<TimeZone>()
|
||||
.select(
|
||||
NSDictionary.self,
|
||||
.count(#keyPath(TimeZone.abbreviation)),
|
||||
.attribute(#keyPath(TimeZone.abbreviation))
|
||||
)
|
||||
.groupBy(#keyPath(TimeZone.abbreviation))
|
||||
.orderBy(
|
||||
.ascending(#keyPath(TimeZone.secondsFromGMT)),
|
||||
.ascending(#keyPath(TimeZone.name))
|
||||
)
|
||||
)!
|
||||
}
|
||||
),
|
||||
@@ -285,8 +296,8 @@ class FetchingAndQueryingDemoViewController: UIViewController, UITableViewDataSo
|
||||
.count(#keyPath(TimeZone.hasDaylightSavingTime), as: "numberOfCountries"),
|
||||
#keyPath(TimeZone.hasDaylightSavingTime)
|
||||
),
|
||||
GroupBy(#keyPath(TimeZone.hasDaylightSavingTime)),
|
||||
OrderBy(.descending(#keyPath(TimeZone.hasDaylightSavingTime)))
|
||||
GroupBy<TimeZone>(#keyPath(TimeZone.hasDaylightSavingTime)),
|
||||
OrderBy<TimeZone>(.descending(#keyPath(TimeZone.hasDaylightSavingTime)))
|
||||
)!
|
||||
}
|
||||
)
|
||||
|
||||
@@ -370,8 +370,8 @@ class MigrationsDemoViewController: UIViewController, ListObserver, UITableViewD
|
||||
|
||||
self._dataStack = dataStack
|
||||
let listMonitor = dataStack.monitorList(
|
||||
From(model.entityType)
|
||||
.orderBy(.descending(#keyPath(OrganismV1.dna)))
|
||||
From(model.entityType),
|
||||
OrderBy<NSManagedObject>(.descending(#keyPath(OrganismV1.dna)))
|
||||
)
|
||||
listMonitor.addObserver(self)
|
||||
self._listMonitor = listMonitor
|
||||
|
||||
@@ -45,6 +45,7 @@ public protocol QueryChainableBuilderType {
|
||||
var queryClauses: [QueryClause] { get set }
|
||||
}
|
||||
|
||||
@available(OSX 10.12, *)
|
||||
public protocol SectionMonitorBuilderType {
|
||||
|
||||
associatedtype ObjectType: DynamicObject
|
||||
@@ -85,6 +86,7 @@ public struct QueryChainBuilder<D: DynamicObject, R: SelectResultType>: QueryCha
|
||||
|
||||
// MARK: - SectionMonitorChainBuilder
|
||||
|
||||
@available(OSX 10.12, *)
|
||||
public struct SectionMonitorChainBuilder<D: DynamicObject>: SectionMonitorBuilderType {
|
||||
|
||||
// MARK: SectionMonitorBuilderType
|
||||
@@ -113,11 +115,13 @@ public extension From {
|
||||
)
|
||||
}
|
||||
|
||||
@available(OSX 10.12, *)
|
||||
public func sectionBy(_ sectionKeyPath: KeyPathString) -> SectionMonitorChainBuilder<D> {
|
||||
|
||||
return self.sectionBy(sectionKeyPath, { $0 })
|
||||
}
|
||||
|
||||
@available(OSX 10.12, *)
|
||||
public func sectionBy(_ sectionKeyPath: KeyPathString, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<D> {
|
||||
|
||||
return .init(
|
||||
@@ -270,6 +274,7 @@ public extension QueryChainBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
@available(OSX 10.12, *)
|
||||
public extension SectionMonitorChainBuilder {
|
||||
|
||||
public func `where`(_ clause: Where<D>) -> SectionMonitorChainBuilder<D> {
|
||||
|
||||
Reference in New Issue
Block a user