mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 10:21:17 +01:00
Unify generic labeling
This commit is contained in:
@@ -52,7 +52,7 @@ public protocol SelectAttributesResultType: SelectResultType {
|
||||
/**
|
||||
The `SelectTerm` is passed to the `Select` clause to indicate the attributes/aggregate keys to be queried.
|
||||
*/
|
||||
public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
public enum SelectTerm<O: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
|
||||
/**
|
||||
Provides a `SelectTerm` to a `Select` clause for querying an entity attribute. A shorter way to do the same is to assign from the string keypath directly:
|
||||
@@ -74,7 +74,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter keyPath: the attribute name
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying an entity attribute
|
||||
*/
|
||||
public static func attribute(_ keyPath: KeyPathString) -> SelectTerm<D> {
|
||||
public static func attribute(_ keyPath: KeyPathString) -> SelectTerm<O> {
|
||||
|
||||
return ._attribute(keyPath)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
|
||||
*/
|
||||
public static func average(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func average(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return ._aggregate(
|
||||
function: "average:",
|
||||
@@ -113,7 +113,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
*/
|
||||
public static func count(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func count(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return ._aggregate(
|
||||
function: "count:",
|
||||
@@ -135,7 +135,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
|
||||
*/
|
||||
public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return ._aggregate(
|
||||
function: "max:",
|
||||
@@ -157,7 +157,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
|
||||
*/
|
||||
public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return ._aggregate(
|
||||
function: "min:",
|
||||
@@ -179,7 +179,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return ._aggregate(
|
||||
function: "sum:",
|
||||
@@ -202,7 +202,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "objecID" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func objectID(as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func objectID(as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return ._identity(
|
||||
alias: alias ?? "objectID",
|
||||
@@ -231,7 +231,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
|
||||
// MARK: Equatable
|
||||
|
||||
public static func == (lhs: SelectTerm<D>, rhs: SelectTerm<D>) -> Bool {
|
||||
public static func == (lhs: SelectTerm<O>, rhs: SelectTerm<O>) -> Bool {
|
||||
|
||||
switch (lhs, rhs) {
|
||||
|
||||
@@ -296,19 +296,25 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
|
||||
case ._identity(let alias, _): return alias
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Deprecated
|
||||
|
||||
@available(*, deprecated, renamed: "O")
|
||||
public typealias D = O
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SelectTerm where D: NSManagedObject
|
||||
// MARK: - SelectTerm where O: NSManagedObject
|
||||
|
||||
extension SelectTerm where D: NSManagedObject {
|
||||
extension SelectTerm where O: NSManagedObject {
|
||||
|
||||
/**
|
||||
Provides a `SelectTerm` to a `Select` clause for querying an entity attribute.
|
||||
- parameter keyPath: the attribute name
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying an entity attribute
|
||||
*/
|
||||
public static func attribute<V>(_ keyPath: KeyPath<D, V>) -> SelectTerm<D> {
|
||||
public static func attribute<V>(_ keyPath: KeyPath<O, V>) -> SelectTerm<O> {
|
||||
|
||||
return self.attribute(keyPath._kvcKeyPathString!)
|
||||
}
|
||||
@@ -319,7 +325,7 @@ extension SelectTerm where D: NSManagedObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
|
||||
*/
|
||||
public static func average<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func average<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.average(keyPath._kvcKeyPathString!, as: alias)
|
||||
}
|
||||
@@ -330,7 +336,7 @@ extension SelectTerm where D: NSManagedObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
*/
|
||||
public static func count<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func count<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.count(keyPath._kvcKeyPathString!, as: alias)
|
||||
}
|
||||
@@ -341,7 +347,7 @@ extension SelectTerm where D: NSManagedObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
|
||||
*/
|
||||
public static func maximum<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func maximum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.maximum(keyPath._kvcKeyPathString!, as: alias)
|
||||
}
|
||||
@@ -352,7 +358,7 @@ extension SelectTerm where D: NSManagedObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
|
||||
*/
|
||||
public static func minimum<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func minimum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.minimum(keyPath._kvcKeyPathString!, as: alias)
|
||||
}
|
||||
@@ -363,25 +369,25 @@ extension SelectTerm where D: NSManagedObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func sum<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func sum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.sum(keyPath._kvcKeyPathString!, as: alias)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SelectTerm where D: CoreStoreObject
|
||||
// MARK: - SelectTerm where O: CoreStoreObject
|
||||
|
||||
extension SelectTerm where D: CoreStoreObject {
|
||||
extension SelectTerm where O: CoreStoreObject {
|
||||
|
||||
/**
|
||||
Provides a `SelectTerm` to a `Select` clause for querying an entity attribute.
|
||||
- parameter keyPath: the attribute name
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying an entity attribute
|
||||
*/
|
||||
public static func attribute<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>) -> SelectTerm<D> {
|
||||
public static func attribute<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>) -> SelectTerm<O> {
|
||||
|
||||
return self.attribute(D.meta[keyPath: keyPath].keyPath)
|
||||
return self.attribute(O.meta[keyPath: keyPath].keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,9 +395,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter keyPath: the attribute name
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying an entity attribute
|
||||
*/
|
||||
public static func attribute<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>) -> SelectTerm<D> {
|
||||
public static func attribute<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>) -> SelectTerm<O> {
|
||||
|
||||
return self.attribute(D.meta[keyPath: keyPath].keyPath)
|
||||
return self.attribute(O.meta[keyPath: keyPath].keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,9 +405,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter keyPath: the attribute name
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying an entity attribute
|
||||
*/
|
||||
public static func attribute<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<V>>) -> SelectTerm<D> {
|
||||
public static func attribute<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<V>>) -> SelectTerm<O> {
|
||||
|
||||
return self.attribute(D.meta[keyPath: keyPath].keyPath)
|
||||
return self.attribute(O.meta[keyPath: keyPath].keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,9 +415,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter keyPath: the attribute name
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying an entity attribute
|
||||
*/
|
||||
public static func attribute<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<V>>) -> SelectTerm<D> {
|
||||
public static func attribute<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<V>>) -> SelectTerm<O> {
|
||||
|
||||
return self.attribute(D.meta[keyPath: keyPath].keyPath)
|
||||
return self.attribute(O.meta[keyPath: keyPath].keyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,9 +426,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
|
||||
*/
|
||||
public static func average<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func average<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.average(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.average(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,9 +437,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
|
||||
*/
|
||||
public static func average<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func average<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.average(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.average(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,9 +448,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
|
||||
*/
|
||||
public static func average<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func average<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.average(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.average(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,9 +459,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
|
||||
*/
|
||||
public static func average<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func average<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.average(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.average(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,10 +470,10 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
*/
|
||||
public static func count<V>(_ keyPath: KeyPath<D,
|
||||
ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func count<V>(_ keyPath: KeyPath<O,
|
||||
ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.count(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.count(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,10 +482,10 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
*/
|
||||
public static func count<V>(_ keyPath: KeyPath<D,
|
||||
ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func count<V>(_ keyPath: KeyPath<O,
|
||||
ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.count(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.count(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,10 +494,10 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
*/
|
||||
public static func count<V>(_ keyPath: KeyPath<D,
|
||||
TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func count<V>(_ keyPath: KeyPath<O,
|
||||
TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.count(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.count(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -500,10 +506,10 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||
*/
|
||||
public static func count<V>(_ keyPath: KeyPath<D,
|
||||
TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func count<V>(_ keyPath: KeyPath<O,
|
||||
TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.count(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.count(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -512,10 +518,10 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
|
||||
*/
|
||||
public static func maximum<V>(_ keyPath: KeyPath<D,
|
||||
ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func maximum<V>(_ keyPath: KeyPath<O,
|
||||
ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.maximum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.maximum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -524,10 +530,10 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
|
||||
*/
|
||||
public static func maximum<V>(_ keyPath: KeyPath<D,
|
||||
ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func maximum<V>(_ keyPath: KeyPath<O,
|
||||
ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.maximum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.maximum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,10 +542,10 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
|
||||
*/
|
||||
public static func maximum<V>(_ keyPath: KeyPath<D,
|
||||
TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func maximum<V>(_ keyPath: KeyPath<O,
|
||||
TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.maximum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.maximum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -548,10 +554,10 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
|
||||
*/
|
||||
public static func maximum<V>(_ keyPath: KeyPath<D,
|
||||
TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func maximum<V>(_ keyPath: KeyPath<O,
|
||||
TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.maximum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.maximum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -560,9 +566,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
|
||||
*/
|
||||
public static func minimum<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func minimum<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.minimum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.minimum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -571,9 +577,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
|
||||
*/
|
||||
public static func minimum<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func minimum<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.minimum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.minimum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -582,9 +588,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
|
||||
*/
|
||||
public static func minimum<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func minimum<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.minimum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.minimum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -593,9 +599,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
|
||||
*/
|
||||
public static func minimum<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func minimum<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.minimum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.minimum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -604,9 +610,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func sum<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func sum<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.sum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.sum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -615,9 +621,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func sum<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func sum<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.sum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.sum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -626,9 +632,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func sum<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func sum<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.sum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.sum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -637,9 +643,9 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||
*/
|
||||
public static func sum<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
|
||||
public static func sum<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
|
||||
|
||||
return self.sum(D.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
return self.sum(O.meta[keyPath: keyPath].keyPath, as: alias)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,7 +678,7 @@ extension SelectTerm where D: CoreStoreObject {
|
||||
|
||||
- parameter sortDescriptors: a series of `NSSortDescriptor`s
|
||||
*/
|
||||
public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hashable {
|
||||
public struct Select<O: DynamicObject, T: SelectResultType>: SelectClause, Hashable {
|
||||
|
||||
/**
|
||||
Initializes a `Select` clause with a list of `SelectTerm`s
|
||||
@@ -680,7 +686,7 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
|
||||
- parameter selectTerm: a `SelectTerm`
|
||||
- parameter selectTerms: a series of `SelectTerm`s
|
||||
*/
|
||||
public init(_ selectTerm: SelectTerm<D>, _ selectTerms: SelectTerm<D>...) {
|
||||
public init(_ selectTerm: SelectTerm<O>, _ selectTerms: SelectTerm<O>...) {
|
||||
|
||||
self.selectTerms = [selectTerm] + selectTerms
|
||||
}
|
||||
@@ -690,7 +696,7 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
|
||||
|
||||
- parameter selectTerms: a series of `SelectTerm`s
|
||||
*/
|
||||
public init(_ selectTerms: [SelectTerm<D>]) {
|
||||
public init(_ selectTerms: [SelectTerm<O>]) {
|
||||
|
||||
self.selectTerms = selectTerms
|
||||
}
|
||||
@@ -698,7 +704,7 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
|
||||
|
||||
// MARK: Equatable
|
||||
|
||||
public static func == <T, U>(lhs: Select<D, T>, rhs: Select<D, U>) -> Bool {
|
||||
public static func == <T, U>(lhs: Select<O, T>, rhs: Select<O, U>) -> Bool {
|
||||
|
||||
return lhs.selectTerms == rhs.selectTerms
|
||||
}
|
||||
@@ -706,10 +712,10 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
|
||||
|
||||
// MARK: SelectClause
|
||||
|
||||
public typealias ObjectType = D
|
||||
public typealias ObjectType = O
|
||||
public typealias ReturnType = T
|
||||
|
||||
public let selectTerms: [SelectTerm<D>]
|
||||
public let selectTerms: [SelectTerm<O>]
|
||||
|
||||
|
||||
// MARK: Hashable
|
||||
@@ -806,6 +812,12 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
|
||||
|
||||
fetchRequest.propertiesToFetch = propertiesToFetch
|
||||
}
|
||||
|
||||
|
||||
// MARK: Deprecated
|
||||
|
||||
@available(*, deprecated, renamed: "O")
|
||||
public typealias D = O
|
||||
}
|
||||
|
||||
extension Select where T: NSManagedObjectID {
|
||||
@@ -819,25 +831,25 @@ extension Select where T: NSManagedObjectID {
|
||||
}
|
||||
}
|
||||
|
||||
extension Select where D: NSManagedObject {
|
||||
extension Select where O: NSManagedObject {
|
||||
|
||||
/**
|
||||
Initializes a `Select` that queries the value of an attribute pertained by a keyPath
|
||||
- parameter keyPath: the keyPath for the attribute
|
||||
*/
|
||||
public init(_ keyPath: KeyPath<D, T>) {
|
||||
public init(_ keyPath: KeyPath<O, T>) {
|
||||
|
||||
self.init(.attribute(keyPath))
|
||||
}
|
||||
}
|
||||
|
||||
extension Select where D: CoreStoreObject, T: ImportableAttributeType {
|
||||
extension Select where O: CoreStoreObject, T: ImportableAttributeType {
|
||||
|
||||
/**
|
||||
Initializes a `Select` that queries the value of an attribute pertained by a keyPath
|
||||
- parameter keyPath: the keyPath for the attribute
|
||||
*/
|
||||
public init(_ keyPath: KeyPath<D, ValueContainer<D>.Required<T>>) {
|
||||
public init(_ keyPath: KeyPath<O, ValueContainer<O>.Required<T>>) {
|
||||
|
||||
self.init(.attribute(keyPath))
|
||||
}
|
||||
@@ -846,19 +858,19 @@ extension Select where D: CoreStoreObject, T: ImportableAttributeType {
|
||||
Initializes a `Select` that queries the value of an attribute pertained by a keyPath
|
||||
- parameter keyPath: the keyPath for the attribute
|
||||
*/
|
||||
public init(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<T>>) {
|
||||
public init(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<T>>) {
|
||||
|
||||
self.init(.attribute(keyPath))
|
||||
}
|
||||
}
|
||||
|
||||
extension Select where D: CoreStoreObject, T: ImportableAttributeType & NSCoding & NSCopying {
|
||||
extension Select where O: CoreStoreObject, T: ImportableAttributeType & NSCoding & NSCopying {
|
||||
|
||||
/**
|
||||
Initializes a `Select` that queries the value of an attribute pertained by a keyPath
|
||||
- parameter keyPath: the keyPath for the attribute
|
||||
*/
|
||||
public init(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<T>>) {
|
||||
public init(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<T>>) {
|
||||
|
||||
self.init(.attribute(keyPath))
|
||||
}
|
||||
@@ -867,7 +879,7 @@ extension Select where D: CoreStoreObject, T: ImportableAttributeType & NSCoding
|
||||
Initializes a `Select` that queries the value of an attribute pertained by a keyPath
|
||||
- parameter keyPath: the keyPath for the attribute
|
||||
*/
|
||||
public init(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>) {
|
||||
public init(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>) {
|
||||
|
||||
self.init(.attribute(keyPath))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user