added .where(combinedByAnd:) and .where(combinedByOr:) to help compiler with long && and || chains

This commit is contained in:
John Estropia
2021-01-02 10:00:23 +09:00
parent 2cd8101987
commit c6be892cb0

View File

@@ -42,6 +42,28 @@ extension From {
return self.fetchChain(appending: clause)
}
/**
Creates a `FetchChainBuilder` that `AND`s the specified `Where` clauses. Use this overload if the compiler cannot infer the types when chaining multiple `&&` operators.
- parameter clauses: the `Where` clauses to create a `FetchChainBuilder` with
- returns: a `FetchChainBuilder` that `AND`s the specified `Where` clauses
*/
public func `where`(combineByAnd clauses: Where<O>...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: clauses.combinedByAnd())
}
/**
Creates a `FetchChainBuilder` that `OR`s the specified `Where` clauses. Use this overload if the compiler cannot infer the types when chaining multiple `||` operators.
- parameter clauses: the `Where` clauses to create a `FetchChainBuilder` with
- returns: a `FetchChainBuilder` that `OR`s the specified `Where` clauses
*/
public func `where`(combineByOr clauses: Where<O>...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: clauses.combinedByOr())
}
/**
Creates a `FetchChainBuilder` with a predicate using the specified string format and arguments
@@ -295,11 +317,6 @@ extension From where O: CoreStoreObject {
return self.fetchChain(appending: clause(O.meta))
}
public func `where`(combinedByAnd clause: Where<O>, _ others: Where<O>...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: ([clause] + others).combinedByAnd())
}
/**
Creates a `QueryChainBuilder` that starts with a `Select` clause created from the specified key path
@@ -544,6 +561,28 @@ extension FetchChainBuilder {
return self.fetchChain(appending: clause)
}
/**
Creates a `FetchChainBuilder` that `AND`s the specified `Where` clauses. Use this overload if the compiler cannot infer the types when chaining multiple `&&` operators.
- parameter clauses: the `Where` clauses to create a `FetchChainBuilder` with
- returns: a `FetchChainBuilder` that `AND`s the specified `Where` clauses
*/
public func `where`(combineByAnd clauses: Where<O>...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: clauses.combinedByAnd())
}
/**
Creates a `FetchChainBuilder` that `OR`s the specified `Where` clauses. Use this overload if the compiler cannot infer the types when chaining multiple `||` operators.
- parameter clauses: the `Where` clauses to create a `FetchChainBuilder` with
- returns: a `FetchChainBuilder` that `OR`s the specified `Where` clauses
*/
public func `where`(combineByOr clauses: Where<O>...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: clauses.combinedByOr())
}
/**
Adds a `Where` clause to the `FetchChainBuilder`
@@ -682,6 +721,28 @@ extension QueryChainBuilder {
return self.queryChain(appending: clause)
}
/**
Creates a `FetchChainBuilder` that `AND`s the specified `Where` clauses. Use this overload if the compiler cannot infer the types when chaining multiple `&&` operators.
- parameter clauses: the `Where` clauses to create a `FetchChainBuilder` with
- returns: a `FetchChainBuilder` that `AND`s the specified `Where` clauses
*/
public func `where`(combineByAnd clauses: Where<O>...) -> QueryChainBuilder<O> {
return self.queryChain(appending: clauses.combinedByAnd())
}
/**
Creates a `FetchChainBuilder` that `OR`s the specified `Where` clauses. Use this overload if the compiler cannot infer the types when chaining multiple `||` operators.
- parameter clauses: the `Where` clauses to create a `FetchChainBuilder` with
- returns: a `FetchChainBuilder` that `OR`s the specified `Where` clauses
*/
public func `where`(combineByOr clauses: Where<O>...) -> QueryChainBuilder<O> {
return self.queryChain(appending: clauses.combinedByOr())
}
/**
Adds a `Where` clause to the `QueryChainBuilder`
@@ -957,6 +1018,28 @@ extension SectionMonitorChainBuilder {
return self.sectionMonitorChain(appending: clause)
}
/**
Creates a `FetchChainBuilder` that `AND`s the specified `Where` clauses. Use this overload if the compiler cannot infer the types when chaining multiple `&&` operators.
- parameter clauses: the `Where` clauses to create a `FetchChainBuilder` with
- returns: a `FetchChainBuilder` that `AND`s the specified `Where` clauses
*/
public func `where`(combineByAnd clauses: Where<O>...) -> SectionMonitorChainBuilder<O> {
return self.sectionMonitorChain(appending: clauses.combinedByAnd())
}
/**
Creates a `FetchChainBuilder` that `OR`s the specified `Where` clauses. Use this overload if the compiler cannot infer the types when chaining multiple `||` operators.
- parameter clauses: the `Where` clauses to create a `FetchChainBuilder` with
- returns: a `FetchChainBuilder` that `OR`s the specified `Where` clauses
*/
public func `where`(combineByOr clauses: Where<O>...) -> SectionMonitorChainBuilder<O> {
return self.sectionMonitorChain(appending: clauses.combinedByOr())
}
/**
Adds a `Where` clause to the `SectionMonitorChainBuilder`