mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Replace JoinQuery initializer with QueryInterfaceRequest.asJoinQuery()
This commit is contained in:
1 parent
9d391badc0
commit
5f037c7e4e
5 files changed
+29
-19
No files matched your search
@@ -226,6 +226,32 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
|
||||
}
|
||||
}
|
||||
|
||||
extension QueryInterfaceRequest {
|
||||
/// Turns a request into a JoinQuery.
|
||||
///
|
||||
/// This method helps initializing associations:
|
||||
///
|
||||
/// struct Book: TableRecord {
|
||||
/// // invokes Author.all().asJoinQuery()
|
||||
/// static let author = belongsTo(Author.self)
|
||||
/// }
|
||||
func asJoinQuery() -> JoinQuery {
|
||||
let query = self.query
|
||||
|
||||
GRDBPrecondition(!query.isDistinct, "Not implemented: join distinct queries")
|
||||
GRDBPrecondition(query.groupPromise == nil, "Can't join aggregated queries")
|
||||
GRDBPrecondition(query.havingExpression == nil, "Can't join aggregated queries")
|
||||
GRDBPrecondition(query.limit == nil, "Can't join limited queries")
|
||||
|
||||
return JoinQuery(
|
||||
source: query.source,
|
||||
selection: query.selection,
|
||||
filterPromise: query.filterPromise,
|
||||
ordering: query.ordering,
|
||||
joins: query.joins)
|
||||
}
|
||||
}
|
||||
|
||||
/// Conditional conformance to TableRequest when RowDecoder conforms
|
||||
/// to TableRecord:
|
||||
///
|
||||
|
||||
Reference in new issue
Block a user