mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Trim associations
This commit is contained in:
1 parent
4e4d591109
commit
b180fc37bb
13 files changed
+231
-246
No files matched your search
@@ -271,12 +271,9 @@
|
||||
5653EB0C20944C7C00F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */; };
|
||||
5653EB0D20944C7C00F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */; };
|
||||
5653EB0E20944C7C00F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */; };
|
||||
5653EB0F20944C7C00F46237 /* AssociationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFC20944C7B00F46237 /* AssociationRequest.swift */; };
|
||||
5653EB1020944C7C00F46237 /* AssociationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFC20944C7B00F46237 /* AssociationRequest.swift */; };
|
||||
5653EB1120944C7C00F46237 /* AssociationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFC20944C7B00F46237 /* AssociationRequest.swift */; };
|
||||
5653EB1520944C7C00F46237 /* AssociationQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFE20944C7C00F46237 /* AssociationQuery.swift */; };
|
||||
5653EB1620944C7C00F46237 /* AssociationQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFE20944C7C00F46237 /* AssociationQuery.swift */; };
|
||||
5653EB1720944C7C00F46237 /* AssociationQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFE20944C7C00F46237 /* AssociationQuery.swift */; };
|
||||
5653EB1520944C7C00F46237 /* JoinQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFE20944C7C00F46237 /* JoinQuery.swift */; };
|
||||
5653EB1620944C7C00F46237 /* JoinQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFE20944C7C00F46237 /* JoinQuery.swift */; };
|
||||
5653EB1720944C7C00F46237 /* JoinQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFE20944C7C00F46237 /* JoinQuery.swift */; };
|
||||
5653EB1820944C7C00F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFF20944C7C00F46237 /* ForeignKey.swift */; };
|
||||
5653EB1920944C7C00F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFF20944C7C00F46237 /* ForeignKey.swift */; };
|
||||
5653EB1A20944C7C00F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFF20944C7C00F46237 /* ForeignKey.swift */; };
|
||||
@@ -1011,8 +1008,7 @@
|
||||
5653EAF920944C7B00F46237 /* ForeignKeyRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKeyRequest.swift; sourceTree = "<group>"; };
|
||||
5653EAFA20944C7B00F46237 /* Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Association.swift; sourceTree = "<group>"; };
|
||||
5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasManyAssociation.swift; sourceTree = "<group>"; };
|
||||
5653EAFC20944C7B00F46237 /* AssociationRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationRequest.swift; sourceTree = "<group>"; };
|
||||
5653EAFE20944C7C00F46237 /* AssociationQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationQuery.swift; sourceTree = "<group>"; };
|
||||
5653EAFE20944C7C00F46237 /* JoinQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinQuery.swift; sourceTree = "<group>"; };
|
||||
5653EAFF20944C7C00F46237 /* ForeignKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKey.swift; sourceTree = "<group>"; };
|
||||
5653EB0220944C7C00F46237 /* HasOneAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasOneAssociation.swift; sourceTree = "<group>"; };
|
||||
5653EB242094A14400F46237 /* QueryInterfaceRequest+Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "QueryInterfaceRequest+Association.swift"; sourceTree = "<group>"; };
|
||||
@@ -1607,13 +1603,12 @@
|
||||
children = (
|
||||
5653EAFA20944C7B00F46237 /* Association.swift */,
|
||||
563EF42C2161180D007DAACD /* AssociationAggregate.swift */,
|
||||
5653EAFE20944C7C00F46237 /* AssociationQuery.swift */,
|
||||
5653EAFC20944C7B00F46237 /* AssociationRequest.swift */,
|
||||
5653EAF820944C7B00F46237 /* BelongsToAssociation.swift */,
|
||||
5653EAFF20944C7C00F46237 /* ForeignKey.swift */,
|
||||
5653EAF920944C7B00F46237 /* ForeignKeyRequest.swift */,
|
||||
5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */,
|
||||
5653EB0220944C7C00F46237 /* HasOneAssociation.swift */,
|
||||
5653EAFE20944C7C00F46237 /* JoinQuery.swift */,
|
||||
);
|
||||
path = Association;
|
||||
sourceTree = "<group>";
|
||||
@@ -2521,7 +2516,6 @@
|
||||
56CEB5001EAA2F4D00BFAF62 /* FTS3.swift in Sources */,
|
||||
5698AD271DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */,
|
||||
5613ED4121A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */,
|
||||
5653EB1120944C7C00F46237 /* AssociationRequest.swift in Sources */,
|
||||
C96C0F2D2084A45A006B2981 /* SQLiteDateParser.swift in Sources */,
|
||||
566A841C2041146100E50BFD /* DatabaseSnapshot.swift in Sources */,
|
||||
5613ED4A21A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */,
|
||||
@@ -2592,7 +2586,7 @@
|
||||
565490CB1D5AE252005622CB /* (null) in Sources */,
|
||||
563EF417215F87EB007DAACD /* OrderedDictionary.swift in Sources */,
|
||||
565490D61D5AE252005622CB /* StandardLibrary.swift in Sources */,
|
||||
5653EB1720944C7C00F46237 /* AssociationQuery.swift in Sources */,
|
||||
5653EB1720944C7C00F46237 /* JoinQuery.swift in Sources */,
|
||||
565490B81D5AE236005622CB /* DatabaseError.swift in Sources */,
|
||||
564CE4D821B2DEB600652B19 /* ValueObservation+CompactMap.swift in Sources */,
|
||||
56BF6D3C1DEF47DA006039A3 /* Fixits-0-90-1.swift in Sources */,
|
||||
@@ -2673,12 +2667,11 @@
|
||||
56A8C2331D1914540096E9D4 /* UUID.swift in Sources */,
|
||||
56BF6D321DEF47DA006039A3 /* Fixits-0-84-0.swift in Sources */,
|
||||
560D92411C672C3E00F4F92B /* DatabaseValueConvertible.swift in Sources */,
|
||||
5653EB1020944C7C00F46237 /* AssociationRequest.swift in Sources */,
|
||||
566475BD1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */,
|
||||
56A238A51B9C753B0082EB20 /* Record.swift in Sources */,
|
||||
5671FC231DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */,
|
||||
56D51D031EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */,
|
||||
5653EB1620944C7C00F46237 /* AssociationQuery.swift in Sources */,
|
||||
5653EB1620944C7C00F46237 /* JoinQuery.swift in Sources */,
|
||||
560D924C1C672C4B00F4F92B /* TableRecord.swift in Sources */,
|
||||
564CE52121B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */,
|
||||
5653EC132098738B00F46237 /* SQLGenerationContext.swift in Sources */,
|
||||
@@ -3204,10 +3197,9 @@
|
||||
5695311F1C907A8C00CF1A2B /* DatabaseSchemaCache.swift in Sources */,
|
||||
5605F15D1C672E4000235C62 /* DatabaseDateComponents.swift in Sources */,
|
||||
56BF6D361DEF47DA006039A3 /* Fixits-0-90-1.swift in Sources */,
|
||||
5653EB0F20944C7C00F46237 /* AssociationRequest.swift in Sources */,
|
||||
56193E8E1CD8A3E200F95862 /* FetchedRecordsController.swift in Sources */,
|
||||
56B964B91DA51D0A0002DA19 /* FTS5Pattern.swift in Sources */,
|
||||
5653EB1520944C7C00F46237 /* AssociationQuery.swift in Sources */,
|
||||
5653EB1520944C7C00F46237 /* JoinQuery.swift in Sources */,
|
||||
563363C01C942C04000BE133 /* DatabaseReader.swift in Sources */,
|
||||
564CE43121AA901800652B19 /* ValueObserver.swift in Sources */,
|
||||
5605F1651C672E4000235C62 /* NSNull.swift in Sources */,
|
||||
|
||||
@@ -5,7 +5,20 @@
|
||||
public protocol Association: DerivableRequest {
|
||||
associatedtype OriginRowDecoder
|
||||
associatedtype RowDecoder
|
||||
|
||||
associatedtype _Impl: _AssociationImpl
|
||||
var _impl: _Impl { get set }
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
/// :nodoc:
|
||||
public protocol _AssociationImpl {
|
||||
var key: String { get set }
|
||||
func mapQuery(_ transform: (JoinQuery) -> JoinQuery) -> Self
|
||||
func joinedRequest<T>(_ request: QueryInterfaceRequest<T>, joinOperator: JoinOperator) -> QueryInterfaceRequest<T>
|
||||
func joinedQuery(_ query: JoinQuery, joinOperator: JoinOperator) -> JoinQuery
|
||||
}
|
||||
|
||||
extension Association {
|
||||
/// The association key defines how rows fetched from this association
|
||||
/// should be consumed.
|
||||
///
|
||||
@@ -30,7 +43,9 @@ public protocol Association: DerivableRequest {
|
||||
/// for row in Row.fetchAll(db, request) {
|
||||
/// let team: Team = row["custom"]
|
||||
/// }
|
||||
var key: String { get }
|
||||
public var key: String {
|
||||
return _impl.key
|
||||
}
|
||||
|
||||
/// Creates an association with the given key.
|
||||
///
|
||||
@@ -46,19 +61,18 @@ public protocol Association: DerivableRequest {
|
||||
/// for row in Row.fetchAll(db, request) {
|
||||
/// let team: Team = row["custom"]
|
||||
/// }
|
||||
func forKey(_ key: String) -> Self
|
||||
public func forKey(_ key: String) -> Self {
|
||||
var association = self
|
||||
association._impl.key = key
|
||||
return association
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
var request: AssociationRequest<RowDecoder> { get }
|
||||
private func mapQuery(_ transform: (JoinQuery) -> JoinQuery) -> Self {
|
||||
var association = self
|
||||
association._impl = _impl.mapQuery(transform)
|
||||
return association
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
var joinCondition: JoinCondition { get }
|
||||
|
||||
/// :nodoc:
|
||||
func mapRequest(_ transform: (AssociationRequest<RowDecoder>) -> AssociationRequest<RowDecoder>) -> Self
|
||||
}
|
||||
|
||||
extension Association {
|
||||
/// Creates an association which selects *selection*.
|
||||
///
|
||||
/// struct Player: TableRecord {
|
||||
@@ -81,7 +95,7 @@ extension Association {
|
||||
/// .select([Column("color")])
|
||||
/// var request = Player.including(required: association)
|
||||
public func select(_ selection: [SQLSelectable]) -> Self {
|
||||
return mapRequest { $0.select(selection) }
|
||||
return mapQuery { $0.select(selection) }
|
||||
}
|
||||
|
||||
/// Creates an association with the provided *predicate promise* added to
|
||||
@@ -97,7 +111,7 @@ extension Association {
|
||||
/// let association = Player.team.filter { db in true }
|
||||
/// var request = Player.including(required: association)
|
||||
public func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> Self {
|
||||
return mapRequest { $0.filter(predicate) }
|
||||
return mapQuery { $0.filter(predicate) }
|
||||
}
|
||||
|
||||
/// Creates an association with the provided *orderings promise*.
|
||||
@@ -125,7 +139,7 @@ extension Association {
|
||||
/// .order{ _ in [Column("name")] }
|
||||
/// var request = Player.including(required: association)
|
||||
public func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> Self {
|
||||
return mapRequest { $0.order(orderings) }
|
||||
return mapQuery { $0.order(orderings) }
|
||||
}
|
||||
|
||||
/// Creates an association that reverses applied orderings.
|
||||
@@ -149,7 +163,7 @@ extension Association {
|
||||
/// let association = Player.team.reversed()
|
||||
/// var request = Player.including(required: association)
|
||||
public func reversed() -> Self {
|
||||
return mapRequest { $0.reversed() }
|
||||
return mapQuery { $0.reversed() }
|
||||
}
|
||||
|
||||
/// Creates an association with the given key.
|
||||
@@ -207,7 +221,7 @@ extension Association {
|
||||
/// .including(required: Player.team.aliased(teamAlias))
|
||||
/// .filter(sql: "custom.color = ?", arguments: ["red"])
|
||||
public func aliased(_ alias: TableAlias) -> Self {
|
||||
return mapRequest { $0.aliased(alias) }
|
||||
return mapQuery { $0.qualified(with: alias) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +244,8 @@ extension Association {
|
||||
/// let request = Book
|
||||
/// .include(required: Book.author)
|
||||
/// .include(required: Book.author)
|
||||
/// TODO: Hide if possible
|
||||
/// :nodoc:
|
||||
public struct JoinCondition: Equatable {
|
||||
var foreignKeyRequest: ForeignKeyRequest
|
||||
var originIsLeft: Bool
|
||||
@@ -254,28 +270,28 @@ extension Association {
|
||||
/// associated record are selected. The returned association does not
|
||||
/// require that the associated database table contains a matching row.
|
||||
public func including<A: Association>(optional association: A) -> Self where A.OriginRowDecoder == RowDecoder {
|
||||
return mapRequest { $0.joining(.optional, association) }
|
||||
return mapQuery { association._impl.joinedQuery($0, joinOperator: .optional) }
|
||||
}
|
||||
|
||||
/// Creates an association that includes another one. The columns of the
|
||||
/// associated record are selected. The returned association requires
|
||||
/// that the associated database table contains a matching row.
|
||||
public func including<A: Association>(required association: A) -> Self where A.OriginRowDecoder == RowDecoder {
|
||||
return mapRequest { $0.joining(.required, association) }
|
||||
return mapQuery { association._impl.joinedQuery($0, joinOperator: .required) }
|
||||
}
|
||||
|
||||
/// Creates an association that joins another one. The columns of the
|
||||
/// associated record are not selected. The returned association does not
|
||||
/// require that the associated database table contains a matching row.
|
||||
public func joining<A: Association>(optional association: A) -> Self where A.OriginRowDecoder == RowDecoder {
|
||||
return mapRequest { $0.joining(.optional, association.select([])) }
|
||||
return mapQuery { association.select([])._impl.joinedQuery($0, joinOperator: .optional) }
|
||||
}
|
||||
|
||||
/// Creates an association that joins another one. The columns of the
|
||||
/// associated record are not selected. The returned association requires
|
||||
/// that the associated database table contains a matching row.
|
||||
public func joining<A: Association>(required association: A) -> Self where A.OriginRowDecoder == RowDecoder {
|
||||
return mapRequest { $0.joining(.required, association.select([])) }
|
||||
return mapQuery { association.select([])._impl.joinedQuery($0, joinOperator: .required) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,38 +310,43 @@ extension Association where OriginRowDecoder: MutablePersistableRecord {
|
||||
/// let team: Team = ...
|
||||
/// let players = try team.players.fetchAll(db) // [Player]
|
||||
func request(from record: OriginRowDecoder) -> QueryInterfaceRequest<RowDecoder> {
|
||||
// Goal: turn `JOIN association ON association.recordId = record.id`
|
||||
// into a regular request `SELECT * FROM association WHERE association.recordId = 123`
|
||||
|
||||
// We need table aliases to build the joining condition
|
||||
let associationAlias = TableAlias()
|
||||
let recordAlias = TableAlias()
|
||||
|
||||
// Turn the association request into a query interface request:
|
||||
// JOIN association -> SELECT FROM association
|
||||
return QueryInterfaceRequest(request)
|
||||
|
||||
// Turn the JOIN condition into a regular WHERE condition
|
||||
.filter { db in
|
||||
// Build a join condition: `association.recordId = record.id`
|
||||
// We still need to replace `record.id` with the actual record id.
|
||||
guard let joinExpression = try self.joinCondition.sqlExpression(db, leftAlias: recordAlias, rightAlias: associationAlias) else {
|
||||
fatalError("Can't request from record without join condition")
|
||||
}
|
||||
|
||||
// Serialize record: ["id": 123, ...]
|
||||
// We do it as late as possible, when request is about to be
|
||||
// executed, in order to support long-lived reference types.
|
||||
let container = PersistenceContainer(record)
|
||||
|
||||
// Replace `record.id` with 123
|
||||
return joinExpression.resolvedExpression(inContext: [recordAlias: container])
|
||||
}
|
||||
|
||||
// We just added a condition qualified with associationAlias. Don't
|
||||
// risk introducing conflicting aliases that would prevent the user
|
||||
// from setting a custom alias name: force the same alias for the
|
||||
// whole request.
|
||||
.aliased(associationAlias)
|
||||
let query = QueryInterfaceQuery(
|
||||
source: .table(tableName: "TODO", alias: nil),
|
||||
selection: [AllColumns()])
|
||||
return QueryInterfaceRequest(query: query)
|
||||
// fatalError("not implemented")
|
||||
// // Goal: turn `JOIN association ON association.recordId = record.id`
|
||||
// // into a regular request `SELECT * FROM association WHERE association.recordId = 123`
|
||||
//
|
||||
// // We need table aliases to build the joining condition
|
||||
// let associationAlias = TableAlias()
|
||||
// let recordAlias = TableAlias()
|
||||
//
|
||||
// // Turn the association query into a query interface request:
|
||||
// // JOIN association -> SELECT FROM association
|
||||
// return QueryInterfaceRequest(query: query)
|
||||
//
|
||||
// // Turn the JOIN condition into a regular WHERE condition
|
||||
// .filter { db in
|
||||
// // Build a join condition: `association.recordId = record.id`
|
||||
// // We still need to replace `record.id` with the actual record id.
|
||||
// guard let joinExpression = try self.joinCondition.sqlExpression(db, leftAlias: recordAlias, rightAlias: associationAlias) else {
|
||||
// fatalError("Can't request from record without join condition")
|
||||
// }
|
||||
//
|
||||
// // Serialize record: ["id": 123, ...]
|
||||
// // We do it as late as possible, when request is about to be
|
||||
// // executed, in order to support long-lived reference types.
|
||||
// let container = PersistenceContainer(record)
|
||||
//
|
||||
// // Replace `record.id` with 123
|
||||
// return joinExpression.resolvedExpression(inContext: [recordAlias: container])
|
||||
// }
|
||||
//
|
||||
// // We just added a condition qualified with associationAlias. Don't
|
||||
// // risk introducing conflicting aliases that would prevent the user
|
||||
// // from setting a custom alias name: force the same alias for the
|
||||
// // whole request.
|
||||
// .aliased(associationAlias)
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// In `SELECT a.*, b.* FROM a JOIN b ON b.aid = a.id AND b.name = 'foo'`,
|
||||
/// the AssociationRequest is (`b.*` + `b.name = 'foo'`).
|
||||
/// :nodoc:
|
||||
public struct AssociationRequest<T> {
|
||||
let query: AssociationQuery
|
||||
|
||||
init(query: AssociationQuery) {
|
||||
self.query = query
|
||||
}
|
||||
|
||||
init(_ request: QueryInterfaceRequest<T>) {
|
||||
self.init(query: AssociationQuery(request.query))
|
||||
}
|
||||
}
|
||||
|
||||
extension AssociationRequest {
|
||||
func select(_ selection: [SQLSelectable]) -> AssociationRequest {
|
||||
return AssociationRequest(query: query.select(selection))
|
||||
}
|
||||
|
||||
func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> AssociationRequest {
|
||||
return AssociationRequest(query: query.filter(predicate))
|
||||
}
|
||||
|
||||
func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> AssociationRequest {
|
||||
return AssociationRequest(query: query.order(orderings))
|
||||
}
|
||||
|
||||
func reversed() -> AssociationRequest {
|
||||
return AssociationRequest(query: query.reversed())
|
||||
}
|
||||
|
||||
func aliased(_ alias: TableAlias) -> AssociationRequest {
|
||||
return AssociationRequest(query: query.qualified(with: alias))
|
||||
}
|
||||
|
||||
func joining<A: Association>(_ joinOperator: AssociationJoinOperator, _ association: A)
|
||||
-> AssociationRequest
|
||||
where A.OriginRowDecoder == T
|
||||
{
|
||||
let join = AssociationJoin(
|
||||
joinOperator: joinOperator,
|
||||
joinCondition: association.joinCondition,
|
||||
query: association.request.query)
|
||||
return AssociationRequest(query: query.appendingJoin(join, forKey: association.key))
|
||||
}
|
||||
}
|
||||
@@ -65,25 +65,38 @@ public struct BelongsToAssociation<Origin, Destination>: Association {
|
||||
/// :nodoc:
|
||||
public typealias RowDecoder = Destination
|
||||
|
||||
public var key: String
|
||||
|
||||
/// :nodoc:
|
||||
public let joinCondition: JoinCondition
|
||||
|
||||
/// :nodoc:
|
||||
public var request: AssociationRequest<Destination>
|
||||
public var _impl: _BelongsToAssociationImpl
|
||||
}
|
||||
|
||||
public func forKey(_ key: String) -> BelongsToAssociation<Origin, Destination> {
|
||||
var association = self
|
||||
association.key = key
|
||||
return association
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// :nodoc:
|
||||
public struct _BelongsToAssociationImpl: _AssociationImpl {
|
||||
public var key: String
|
||||
let joinCondition: JoinCondition
|
||||
var query: JoinQuery
|
||||
|
||||
public func mapQuery(_ transform: (JoinQuery) -> JoinQuery) -> _BelongsToAssociationImpl {
|
||||
var impl = self
|
||||
impl.query = transform(query)
|
||||
return impl
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public func mapRequest(_ transform: (AssociationRequest<Destination>) -> AssociationRequest<Destination>) -> BelongsToAssociation<Origin, Destination> {
|
||||
var association = self
|
||||
association.request = transform(request)
|
||||
return association
|
||||
public func joinedRequest<T>(_ request: QueryInterfaceRequest<T>, joinOperator: JoinOperator) -> QueryInterfaceRequest<T> {
|
||||
let join = Join(
|
||||
joinOperator: joinOperator,
|
||||
joinCondition: joinCondition,
|
||||
query: query)
|
||||
return QueryInterfaceRequest(query: request.query.appendingJoin(join, forKey: key))
|
||||
}
|
||||
|
||||
public func joinedQuery(_ query: JoinQuery, joinOperator: JoinOperator) -> JoinQuery {
|
||||
let join = Join(
|
||||
joinOperator: joinOperator,
|
||||
joinCondition: joinCondition,
|
||||
query: self.query)
|
||||
return query.appendingJoin(join, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,10 +178,10 @@ extension TableRecord {
|
||||
let joinCondition = JoinCondition(
|
||||
foreignKeyRequest: foreignKeyRequest,
|
||||
originIsLeft: true)
|
||||
|
||||
return BelongsToAssociation(
|
||||
|
||||
return BelongsToAssociation(_impl: _BelongsToAssociationImpl(
|
||||
key: key ?? Destination.databaseTableName,
|
||||
joinCondition: joinCondition,
|
||||
request: AssociationRequest(Destination.all()))
|
||||
query: JoinQuery(Destination.all().query)))
|
||||
}
|
||||
}
|
||||
@@ -65,25 +65,38 @@ public struct HasManyAssociation<Origin, Destination>: Association {
|
||||
/// :nodoc:
|
||||
public typealias RowDecoder = Destination
|
||||
|
||||
/// :nodoc:
|
||||
public var _impl: _HasManyAssociationImpl
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// :nodoc:
|
||||
public struct _HasManyAssociationImpl: _AssociationImpl {
|
||||
public var key: String
|
||||
let joinCondition: JoinCondition
|
||||
var query: JoinQuery
|
||||
|
||||
/// :nodoc:
|
||||
public let joinCondition: JoinCondition
|
||||
|
||||
/// :nodoc:
|
||||
public var request: AssociationRequest<Destination>
|
||||
|
||||
public func forKey(_ key: String) -> HasManyAssociation<Origin, Destination> {
|
||||
var association = self
|
||||
association.key = key
|
||||
return association
|
||||
public func mapQuery(_ transform: (JoinQuery) -> JoinQuery) -> _HasManyAssociationImpl {
|
||||
var impl = self
|
||||
impl.query = transform(query)
|
||||
return impl
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public func mapRequest(_ transform: (AssociationRequest<Destination>) -> AssociationRequest<Destination>) -> HasManyAssociation<Origin, Destination> {
|
||||
var association = self
|
||||
association.request = transform(request)
|
||||
return association
|
||||
public func joinedRequest<T>(_ request: QueryInterfaceRequest<T>, joinOperator: JoinOperator) -> QueryInterfaceRequest<T> {
|
||||
let join = Join(
|
||||
joinOperator: joinOperator,
|
||||
joinCondition: joinCondition,
|
||||
query: query)
|
||||
return QueryInterfaceRequest(query: request.query.appendingJoin(join, forKey: key))
|
||||
}
|
||||
|
||||
public func joinedQuery(_ query: JoinQuery, joinOperator: JoinOperator) -> JoinQuery {
|
||||
let join = Join(
|
||||
joinOperator: joinOperator,
|
||||
joinCondition: joinCondition,
|
||||
query: self.query)
|
||||
return query.appendingJoin(join, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,9 +268,9 @@ extension TableRecord {
|
||||
foreignKeyRequest: foreignKeyRequest,
|
||||
originIsLeft: false)
|
||||
|
||||
return HasManyAssociation(
|
||||
return HasManyAssociation(_impl: _HasManyAssociationImpl(
|
||||
key: key ?? Destination.databaseTableName,
|
||||
joinCondition: joinCondition,
|
||||
request: AssociationRequest(Destination.all()))
|
||||
query: JoinQuery(Destination.all().query)))
|
||||
}
|
||||
}
|
||||
@@ -66,26 +66,39 @@ public struct HasOneAssociation<Origin, Destination> : Association {
|
||||
|
||||
/// :nodoc:
|
||||
public typealias RowDecoder = Destination
|
||||
|
||||
|
||||
/// :nodoc:
|
||||
public var _impl: _HasOneAssociationImpl
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// :nodoc:
|
||||
public struct _HasOneAssociationImpl: _AssociationImpl {
|
||||
public var key: String
|
||||
let joinCondition: JoinCondition
|
||||
var query: JoinQuery
|
||||
|
||||
/// :nodoc:
|
||||
public let joinCondition: JoinCondition
|
||||
|
||||
/// :nodoc:
|
||||
public var request: AssociationRequest<Destination>
|
||||
|
||||
public func forKey(_ key: String) -> HasOneAssociation<Origin, Destination> {
|
||||
var association = self
|
||||
association.key = key
|
||||
return association
|
||||
public func mapQuery(_ transform: (JoinQuery) -> JoinQuery) -> _HasOneAssociationImpl {
|
||||
var impl = self
|
||||
impl.query = transform(query)
|
||||
return impl
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public func mapRequest(_ transform: (AssociationRequest<Destination>) -> AssociationRequest<Destination>) -> HasOneAssociation<Origin, Destination> {
|
||||
var association = self
|
||||
association.request = transform(request)
|
||||
return association
|
||||
public func joinedRequest<T>(_ request: QueryInterfaceRequest<T>, joinOperator: JoinOperator) -> QueryInterfaceRequest<T> {
|
||||
let join = Join(
|
||||
joinOperator: joinOperator,
|
||||
joinCondition: joinCondition,
|
||||
query: query)
|
||||
return QueryInterfaceRequest(query: request.query.appendingJoin(join, forKey: key))
|
||||
}
|
||||
|
||||
public func joinedQuery(_ query: JoinQuery, joinOperator: JoinOperator) -> JoinQuery {
|
||||
let join = Join(
|
||||
joinOperator: joinOperator,
|
||||
joinCondition: joinCondition,
|
||||
query: self.query)
|
||||
return query.appendingJoin(join, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,9 +181,9 @@ extension TableRecord {
|
||||
foreignKeyRequest: foreignKeyRequest,
|
||||
originIsLeft: false)
|
||||
|
||||
return HasOneAssociation(
|
||||
return HasOneAssociation(_impl: _HasOneAssociationImpl(
|
||||
key: key ?? Destination.databaseTableName,
|
||||
joinCondition: joinCondition,
|
||||
request: AssociationRequest(Destination.all()))
|
||||
query: JoinQuery(Destination.all().query)))
|
||||
}
|
||||
}
|
||||
+20
-17
@@ -1,16 +1,19 @@
|
||||
struct AssociationQuery {
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
/// TODO: Hide if possible
|
||||
/// :nodoc:
|
||||
public struct JoinQuery {
|
||||
var source: SQLSource
|
||||
var selection: [SQLSelectable]
|
||||
var filterPromise: DatabasePromise<SQLExpression?>
|
||||
var ordering: QueryOrdering
|
||||
var joins: OrderedDictionary<String, AssociationJoin>
|
||||
var joins: OrderedDictionary<String, Join>
|
||||
|
||||
var alias: TableAlias? {
|
||||
return source.alias
|
||||
}
|
||||
}
|
||||
|
||||
extension AssociationQuery {
|
||||
extension JoinQuery {
|
||||
init(_ query: QueryInterfaceQuery) {
|
||||
GRDBPrecondition(!query.isDistinct, "Not implemented: join distinct queries")
|
||||
GRDBPrecondition(query.groupPromise == nil, "Can't join aggregated queries")
|
||||
@@ -26,14 +29,14 @@ extension AssociationQuery {
|
||||
}
|
||||
}
|
||||
|
||||
extension AssociationQuery {
|
||||
func select(_ selection: [SQLSelectable]) -> AssociationQuery {
|
||||
extension JoinQuery {
|
||||
func select(_ selection: [SQLSelectable]) -> JoinQuery {
|
||||
var query = self
|
||||
query.selection = selection
|
||||
return query
|
||||
}
|
||||
|
||||
func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> AssociationQuery {
|
||||
func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> JoinQuery {
|
||||
var query = self
|
||||
query.filterPromise = query.filterPromise.map { (db, filter) in
|
||||
if let filter = filter {
|
||||
@@ -45,21 +48,21 @@ extension AssociationQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> AssociationQuery {
|
||||
func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> JoinQuery {
|
||||
return order(QueryOrdering(orderings: orderings))
|
||||
}
|
||||
|
||||
func reversed() -> AssociationQuery {
|
||||
func reversed() -> JoinQuery {
|
||||
return order(ordering.reversed)
|
||||
}
|
||||
|
||||
private func order(_ ordering: QueryOrdering) -> AssociationQuery {
|
||||
private func order(_ ordering: QueryOrdering) -> JoinQuery {
|
||||
var query = self
|
||||
query.ordering = ordering
|
||||
return query
|
||||
}
|
||||
|
||||
func appendingJoin(_ join: AssociationJoin, forKey key: String) -> AssociationQuery {
|
||||
func appendingJoin(_ join: Join, forKey key: String) -> JoinQuery {
|
||||
var query = self
|
||||
if let existingJoin = query.joins.removeValue(forKey: key) {
|
||||
guard let mergedJoin = existingJoin.merged(with: join) else {
|
||||
@@ -73,16 +76,16 @@ extension AssociationQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
func qualified(with alias: TableAlias) -> AssociationQuery {
|
||||
func qualified(with alias: TableAlias) -> JoinQuery {
|
||||
var query = self
|
||||
query.source = source.qualified(with: alias)
|
||||
return query
|
||||
}
|
||||
}
|
||||
|
||||
extension AssociationQuery {
|
||||
extension JoinQuery {
|
||||
/// A finalized query is ready for SQL generation
|
||||
var finalizedQuery: AssociationQuery {
|
||||
var finalizedQuery: JoinQuery {
|
||||
var query = self
|
||||
|
||||
let alias = TableAlias()
|
||||
@@ -144,9 +147,9 @@ extension AssociationQuery {
|
||||
}
|
||||
}
|
||||
|
||||
extension AssociationQuery {
|
||||
extension JoinQuery {
|
||||
/// Returns nil if queries can't be merged (conflict in source, joins...)
|
||||
func merged(with other: AssociationQuery) -> AssociationQuery? {
|
||||
func merged(with other: JoinQuery) -> JoinQuery? {
|
||||
guard let mergedSource = source.merged(with: other.source) else {
|
||||
// can't merge
|
||||
return nil
|
||||
@@ -161,7 +164,7 @@ extension AssociationQuery {
|
||||
return expressions.joined(operator: .and)
|
||||
}
|
||||
|
||||
var mergedJoins: OrderedDictionary<String, AssociationJoin> = [:]
|
||||
var mergedJoins: OrderedDictionary<String, Join> = [:]
|
||||
for (key, join) in joins {
|
||||
if let otherJoin = other.joins[key] {
|
||||
guard let mergedJoin = join.merged(with: otherJoin) else {
|
||||
@@ -183,7 +186,7 @@ extension AssociationQuery {
|
||||
// replace ordering unless empty
|
||||
let mergedOrdering = other.ordering.isEmpty ? ordering : other.ordering
|
||||
|
||||
return AssociationQuery(
|
||||
return JoinQuery(
|
||||
source: mergedSource,
|
||||
selection: mergedSelection,
|
||||
filterPromise: mergedFilterPromise,
|
||||
@@ -25,7 +25,7 @@ struct QueryInterfaceQuery {
|
||||
var ordering: QueryOrdering
|
||||
var havingExpression: SQLExpression?
|
||||
var limit: SQLLimit?
|
||||
var joins: OrderedDictionary<String, AssociationJoin>
|
||||
var joins: OrderedDictionary<String, Join>
|
||||
|
||||
init(
|
||||
source: SQLSource,
|
||||
@@ -36,7 +36,7 @@ struct QueryInterfaceQuery {
|
||||
ordering: QueryOrdering = QueryOrdering(),
|
||||
havingExpression: SQLExpression? = nil,
|
||||
limit: SQLLimit? = nil,
|
||||
joins: OrderedDictionary<String, AssociationJoin> = [:])
|
||||
joins: OrderedDictionary<String, Join> = [:])
|
||||
{
|
||||
self.source = source
|
||||
self.selection = selection
|
||||
@@ -49,7 +49,7 @@ struct QueryInterfaceQuery {
|
||||
self.joins = joins
|
||||
}
|
||||
|
||||
init(_ query: AssociationQuery) {
|
||||
init(_ query: JoinQuery) {
|
||||
self.init(
|
||||
source: query.source,
|
||||
selection: query.selection,
|
||||
@@ -136,7 +136,7 @@ extension QueryInterfaceQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
func appendingJoin(_ join: AssociationJoin, forKey key: String) -> QueryInterfaceQuery {
|
||||
func appendingJoin(_ join: Join, forKey key: String) -> QueryInterfaceQuery {
|
||||
var query = self
|
||||
if let existingJoin = query.joins.removeValue(forKey: key) {
|
||||
guard let mergedJoin = existingJoin.merged(with: join) else {
|
||||
@@ -420,11 +420,11 @@ extension QueryInterfaceQuery {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - AssociationJoin
|
||||
// MARK: - Join
|
||||
|
||||
/// Not to be mismatched with SQL join operators (inner join, left join).
|
||||
///
|
||||
/// AssociationJoinOperator is designed to be hierarchically nested, unlike
|
||||
/// JoinOperator is designed to be hierarchically nested, unlike
|
||||
/// SQL join operators.
|
||||
///
|
||||
/// Consider the following request for (A, B, C) tuples:
|
||||
@@ -465,16 +465,18 @@ extension QueryInterfaceQuery {
|
||||
///
|
||||
/// // what is my meaning?
|
||||
/// A.including(optional: A.b.including(required: B.c))
|
||||
enum AssociationJoinOperator {
|
||||
/// TODO: Hide if possible
|
||||
/// :nodoc:
|
||||
public enum JoinOperator {
|
||||
case required, optional
|
||||
}
|
||||
|
||||
struct AssociationJoin {
|
||||
var joinOperator: AssociationJoinOperator
|
||||
struct Join {
|
||||
var joinOperator: JoinOperator
|
||||
var joinCondition: JoinCondition
|
||||
var query: AssociationQuery
|
||||
var query: JoinQuery
|
||||
|
||||
var finalizedJoin: AssociationJoin {
|
||||
var finalizedJoin: Join {
|
||||
var join = self
|
||||
join.query = query.finalizedQuery
|
||||
return join
|
||||
@@ -531,7 +533,7 @@ struct AssociationJoin {
|
||||
}
|
||||
|
||||
/// Returns nil if joins can't be merged (conflict in condition, query...)
|
||||
func merged(with other: AssociationJoin) -> AssociationJoin? {
|
||||
func merged(with other: Join) -> Join? {
|
||||
guard joinCondition == other.joinCondition else {
|
||||
// can't merge
|
||||
return nil
|
||||
@@ -542,7 +544,7 @@ struct AssociationJoin {
|
||||
return nil
|
||||
}
|
||||
|
||||
let mergedJoinOperator: AssociationJoinOperator
|
||||
let mergedJoinOperator: JoinOperator
|
||||
switch (joinOperator, other.joinOperator) {
|
||||
case (.required, _), (_, .required):
|
||||
mergedJoinOperator = .required
|
||||
@@ -550,7 +552,7 @@ struct AssociationJoin {
|
||||
mergedJoinOperator = .optional
|
||||
}
|
||||
|
||||
return AssociationJoin(
|
||||
return Join(
|
||||
joinOperator: mergedJoinOperator,
|
||||
joinCondition: joinCondition,
|
||||
query: mergedQuery)
|
||||
|
||||
@@ -1,43 +1,32 @@
|
||||
extension QueryInterfaceRequest where RowDecoder: TableRecord {
|
||||
func joining<A: Association>(_ joinOperator: AssociationJoinOperator, _ association: A)
|
||||
-> QueryInterfaceRequest<RowDecoder>
|
||||
where A.OriginRowDecoder == RowDecoder
|
||||
{
|
||||
let join = AssociationJoin(
|
||||
joinOperator: joinOperator,
|
||||
joinCondition: association.joinCondition,
|
||||
query: association.request.query)
|
||||
return QueryInterfaceRequest(query: query.appendingJoin(join, forKey: association.key))
|
||||
}
|
||||
|
||||
// MARK: - Associations
|
||||
|
||||
/// Creates a request that includes an association. The columns of the
|
||||
/// associated record are selected. The returned association does not
|
||||
/// require that the associated database table contains a matching row.
|
||||
public func including<A: Association>(optional association: A) -> QueryInterfaceRequest<RowDecoder> where A.OriginRowDecoder == RowDecoder {
|
||||
return joining(.optional, association)
|
||||
return association._impl.joinedRequest(self, joinOperator: .optional)
|
||||
}
|
||||
|
||||
/// Creates a request that includes an association. The columns of the
|
||||
/// associated record are selected. The returned association requires
|
||||
/// that the associated database table contains a matching row.
|
||||
public func including<A: Association>(required association: A) -> QueryInterfaceRequest<RowDecoder> where A.OriginRowDecoder == RowDecoder {
|
||||
return joining(.required, association)
|
||||
return association._impl.joinedRequest(self, joinOperator: .required)
|
||||
}
|
||||
|
||||
/// Creates a request that includes an association. The columns of the
|
||||
/// associated record are not selected. The returned association does not
|
||||
/// require that the associated database table contains a matching row.
|
||||
public func joining<A: Association>(optional association: A) -> QueryInterfaceRequest<RowDecoder> where A.OriginRowDecoder == RowDecoder {
|
||||
return joining(.optional, association.select([]))
|
||||
return association.select([])._impl.joinedRequest(self, joinOperator: .optional)
|
||||
}
|
||||
|
||||
/// Creates a request that includes an association. The columns of the
|
||||
/// associated record are not selected. The returned association requires
|
||||
/// that the associated database table contains a matching row.
|
||||
public func joining<A: Association>(required association: A) -> QueryInterfaceRequest<RowDecoder> where A.OriginRowDecoder == RowDecoder {
|
||||
return joining(.required, association.select([]))
|
||||
return association.select([])._impl.joinedRequest(self, joinOperator: .required)
|
||||
}
|
||||
|
||||
// MARK: - Association Aggregates
|
||||
|
||||
@@ -8,8 +8,8 @@ public struct QueryInterfaceRequest<T> {
|
||||
self.query = query
|
||||
}
|
||||
|
||||
init(_ request: AssociationRequest<T>) {
|
||||
self.query = QueryInterfaceQuery(request.query)
|
||||
init(query: JoinQuery) {
|
||||
self.query = QueryInterfaceQuery(query)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// QueryOrdering provides the order clause to QueryInterfaceQuery
|
||||
/// and AssociationQuery.
|
||||
/// and JoinQuery.
|
||||
struct QueryOrdering {
|
||||
private enum Element {
|
||||
case orderingTerms((Database) throws -> [SQLOrderingTerm])
|
||||
|
||||
@@ -296,16 +296,14 @@
|
||||
5653EB9020961FC000F46237 /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8520961FBF00F46237 /* BelongsToAssociation.swift */; };
|
||||
5653EB9120961FC000F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8620961FBF00F46237 /* HasOneAssociation.swift */; };
|
||||
5653EB9220961FC000F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8620961FBF00F46237 /* HasOneAssociation.swift */; };
|
||||
5653EB9320961FC000F46237 /* AssociationQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8720961FBF00F46237 /* AssociationQuery.swift */; };
|
||||
5653EB9420961FC000F46237 /* AssociationQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8720961FBF00F46237 /* AssociationQuery.swift */; };
|
||||
5653EB9320961FC000F46237 /* JoinQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8720961FBF00F46237 /* JoinQuery.swift */; };
|
||||
5653EB9420961FC000F46237 /* JoinQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8720961FBF00F46237 /* JoinQuery.swift */; };
|
||||
5653EB9520961FC000F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8820961FBF00F46237 /* HasManyAssociation.swift */; };
|
||||
5653EB9620961FC000F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8820961FBF00F46237 /* HasManyAssociation.swift */; };
|
||||
5653EB9720961FC000F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8920961FBF00F46237 /* ForeignKey.swift */; };
|
||||
5653EB9820961FC000F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8920961FBF00F46237 /* ForeignKey.swift */; };
|
||||
5653EB9920961FC000F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8A20961FBF00F46237 /* ForeignKeyRequest.swift */; };
|
||||
5653EB9A20961FC000F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8A20961FBF00F46237 /* ForeignKeyRequest.swift */; };
|
||||
5653EB9B20961FC000F46237 /* AssociationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8B20961FBF00F46237 /* AssociationRequest.swift */; };
|
||||
5653EB9C20961FC000F46237 /* AssociationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8B20961FBF00F46237 /* AssociationRequest.swift */; };
|
||||
5653EB9D20961FC000F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8C20961FBF00F46237 /* Association.swift */; };
|
||||
5653EB9E20961FC000F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB8C20961FBF00F46237 /* Association.swift */; };
|
||||
5653EBA220961FCA00F46237 /* QueryInterfaceRequest+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EBA120961FCA00F46237 /* QueryInterfaceRequest+Association.swift */; };
|
||||
@@ -1106,11 +1104,10 @@
|
||||
564F9C2C1F075DD200877A00 /* DatabaseFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseFunction.swift; sourceTree = "<group>"; };
|
||||
5653EB8520961FBF00F46237 /* BelongsToAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BelongsToAssociation.swift; sourceTree = "<group>"; };
|
||||
5653EB8620961FBF00F46237 /* HasOneAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasOneAssociation.swift; sourceTree = "<group>"; };
|
||||
5653EB8720961FBF00F46237 /* AssociationQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationQuery.swift; sourceTree = "<group>"; };
|
||||
5653EB8720961FBF00F46237 /* JoinQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinQuery.swift; sourceTree = "<group>"; };
|
||||
5653EB8820961FBF00F46237 /* HasManyAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasManyAssociation.swift; sourceTree = "<group>"; };
|
||||
5653EB8920961FBF00F46237 /* ForeignKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKey.swift; sourceTree = "<group>"; };
|
||||
5653EB8A20961FBF00F46237 /* ForeignKeyRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKeyRequest.swift; sourceTree = "<group>"; };
|
||||
5653EB8B20961FBF00F46237 /* AssociationRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationRequest.swift; sourceTree = "<group>"; };
|
||||
5653EB8C20961FBF00F46237 /* Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Association.swift; sourceTree = "<group>"; };
|
||||
5653EBA120961FCA00F46237 /* QueryInterfaceRequest+Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "QueryInterfaceRequest+Association.swift"; sourceTree = "<group>"; };
|
||||
5653EBA620961FE600F46237 /* AssociationParallelSQLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationParallelSQLTests.swift; sourceTree = "<group>"; };
|
||||
@@ -1667,13 +1664,12 @@
|
||||
children = (
|
||||
5653EB8C20961FBF00F46237 /* Association.swift */,
|
||||
563EF43A2161183E007DAACD /* AssociationAggregate.swift */,
|
||||
5653EB8720961FBF00F46237 /* AssociationQuery.swift */,
|
||||
5653EB8B20961FBF00F46237 /* AssociationRequest.swift */,
|
||||
5653EB8520961FBF00F46237 /* BelongsToAssociation.swift */,
|
||||
5653EB8920961FBF00F46237 /* ForeignKey.swift */,
|
||||
5653EB8A20961FBF00F46237 /* ForeignKeyRequest.swift */,
|
||||
5653EB8820961FBF00F46237 /* HasManyAssociation.swift */,
|
||||
5653EB8620961FBF00F46237 /* HasOneAssociation.swift */,
|
||||
5653EB8720961FBF00F46237 /* JoinQuery.swift */,
|
||||
);
|
||||
path = Association;
|
||||
sourceTree = "<group>";
|
||||
@@ -2328,7 +2324,6 @@
|
||||
563EF4502161F1A8007DAACD /* Inflections.swift in Sources */,
|
||||
566B910A1FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
|
||||
566B91241FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
|
||||
5653EB9B20961FC000F46237 /* AssociationRequest.swift in Sources */,
|
||||
56CEB5121EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */,
|
||||
5659F4911EA8D964004A4992 /* ReadWriteBox.swift in Sources */,
|
||||
566A842920413D6F00E50BFD /* DatabaseSnapshot.swift in Sources */,
|
||||
@@ -2400,7 +2395,7 @@
|
||||
560FC5341CB003810014AA8E /* QueryInterfaceQuery.swift in Sources */,
|
||||
566B912C1FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */,
|
||||
560FC5351CB003810014AA8E /* Statement.swift in Sources */,
|
||||
5653EB9320961FC000F46237 /* AssociationQuery.swift in Sources */,
|
||||
5653EB9320961FC000F46237 /* JoinQuery.swift in Sources */,
|
||||
5690C3411D23E82A00E59934 /* Data.swift in Sources */,
|
||||
5659F4891EA8D94E004A4992 /* Utils.swift in Sources */,
|
||||
560FC5361CB003810014AA8E /* DatabaseMigrator.swift in Sources */,
|
||||
@@ -2816,7 +2811,6 @@
|
||||
563EF4512161F1A8007DAACD /* Inflections.swift in Sources */,
|
||||
566B910D1FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
|
||||
566B91271FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
|
||||
5653EB9C20961FC000F46237 /* AssociationRequest.swift in Sources */,
|
||||
56CEB5151EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */,
|
||||
5659F4941EA8D964004A4992 /* ReadWriteBox.swift in Sources */,
|
||||
566A842A20413D8500E50BFD /* DatabaseSnapshot.swift in Sources */,
|
||||
@@ -2888,7 +2882,7 @@
|
||||
56AFCA091CB1A8BB00F48B96 /* QueryInterfaceQuery.swift in Sources */,
|
||||
566B912F1FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */,
|
||||
56AFCA0A1CB1A8BB00F48B96 /* Migration.swift in Sources */,
|
||||
5653EB9420961FC000F46237 /* AssociationQuery.swift in Sources */,
|
||||
5653EB9420961FC000F46237 /* JoinQuery.swift in Sources */,
|
||||
5690C3441D23E82A00E59934 /* Data.swift in Sources */,
|
||||
5659F48C1EA8D94E004A4992 /* Utils.swift in Sources */,
|
||||
56AFCA0B1CB1A8BB00F48B96 /* Row.swift in Sources */,
|
||||
|
||||
@@ -121,16 +121,14 @@
|
||||
5653EB4220961F6100F46237 /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3720961F6000F46237 /* BelongsToAssociation.swift */; };
|
||||
5653EB4320961F6100F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3820961F6000F46237 /* HasOneAssociation.swift */; };
|
||||
5653EB4420961F6100F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3820961F6000F46237 /* HasOneAssociation.swift */; };
|
||||
5653EB4520961F6100F46237 /* AssociationQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3920961F6000F46237 /* AssociationQuery.swift */; };
|
||||
5653EB4620961F6100F46237 /* AssociationQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3920961F6000F46237 /* AssociationQuery.swift */; };
|
||||
5653EB4520961F6100F46237 /* JoinQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3920961F6000F46237 /* JoinQuery.swift */; };
|
||||
5653EB4620961F6100F46237 /* JoinQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3920961F6000F46237 /* JoinQuery.swift */; };
|
||||
5653EB4720961F6100F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3A20961F6000F46237 /* HasManyAssociation.swift */; };
|
||||
5653EB4820961F6100F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3A20961F6000F46237 /* HasManyAssociation.swift */; };
|
||||
5653EB4920961F6100F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3B20961F6000F46237 /* ForeignKey.swift */; };
|
||||
5653EB4A20961F6100F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3B20961F6000F46237 /* ForeignKey.swift */; };
|
||||
5653EB4B20961F6100F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3C20961F6000F46237 /* ForeignKeyRequest.swift */; };
|
||||
5653EB4C20961F6100F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3C20961F6000F46237 /* ForeignKeyRequest.swift */; };
|
||||
5653EB4D20961F6100F46237 /* AssociationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3D20961F6100F46237 /* AssociationRequest.swift */; };
|
||||
5653EB4E20961F6100F46237 /* AssociationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3D20961F6100F46237 /* AssociationRequest.swift */; };
|
||||
5653EB4F20961F6100F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3E20961F6100F46237 /* Association.swift */; };
|
||||
5653EB5020961F6100F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3E20961F6100F46237 /* Association.swift */; };
|
||||
5653EB5420961F7D00F46237 /* QueryInterfaceRequest+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB5320961F7D00F46237 /* QueryInterfaceRequest+Association.swift */; };
|
||||
@@ -741,11 +739,10 @@
|
||||
564F9C2C1F075DD200877A00 /* DatabaseFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseFunction.swift; sourceTree = "<group>"; };
|
||||
5653EB3720961F6000F46237 /* BelongsToAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BelongsToAssociation.swift; sourceTree = "<group>"; };
|
||||
5653EB3820961F6000F46237 /* HasOneAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasOneAssociation.swift; sourceTree = "<group>"; };
|
||||
5653EB3920961F6000F46237 /* AssociationQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationQuery.swift; sourceTree = "<group>"; };
|
||||
5653EB3920961F6000F46237 /* JoinQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinQuery.swift; sourceTree = "<group>"; };
|
||||
5653EB3A20961F6000F46237 /* HasManyAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasManyAssociation.swift; sourceTree = "<group>"; };
|
||||
5653EB3B20961F6000F46237 /* ForeignKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKey.swift; sourceTree = "<group>"; };
|
||||
5653EB3C20961F6000F46237 /* ForeignKeyRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKeyRequest.swift; sourceTree = "<group>"; };
|
||||
5653EB3D20961F6100F46237 /* AssociationRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationRequest.swift; sourceTree = "<group>"; };
|
||||
5653EB3E20961F6100F46237 /* Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Association.swift; sourceTree = "<group>"; };
|
||||
5653EB5320961F7D00F46237 /* QueryInterfaceRequest+Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "QueryInterfaceRequest+Association.swift"; sourceTree = "<group>"; };
|
||||
5653EB5820961FB000F46237 /* AssociationParallelSQLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationParallelSQLTests.swift; sourceTree = "<group>"; };
|
||||
@@ -1275,13 +1272,12 @@
|
||||
children = (
|
||||
5653EB3E20961F6100F46237 /* Association.swift */,
|
||||
563EF4362161182C007DAACD /* AssociationAggregate.swift */,
|
||||
5653EB3920961F6000F46237 /* AssociationQuery.swift */,
|
||||
5653EB3D20961F6100F46237 /* AssociationRequest.swift */,
|
||||
5653EB3720961F6000F46237 /* BelongsToAssociation.swift */,
|
||||
5653EB3B20961F6000F46237 /* ForeignKey.swift */,
|
||||
5653EB3C20961F6000F46237 /* ForeignKeyRequest.swift */,
|
||||
5653EB3A20961F6000F46237 /* HasManyAssociation.swift */,
|
||||
5653EB3820961F6000F46237 /* HasOneAssociation.swift */,
|
||||
5653EB3920961F6000F46237 /* JoinQuery.swift */,
|
||||
);
|
||||
path = Association;
|
||||
sourceTree = "<group>";
|
||||
@@ -1965,7 +1961,6 @@
|
||||
563EF44E2161F196007DAACD /* Inflections.swift in Sources */,
|
||||
566B910E1FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
|
||||
566B91281FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
|
||||
5653EB4E20961F6100F46237 /* AssociationRequest.swift in Sources */,
|
||||
56CEB5161EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */,
|
||||
5659F4951EA8D964004A4992 /* ReadWriteBox.swift in Sources */,
|
||||
566A842E20413D9A00E50BFD /* DatabaseSnapshot.swift in Sources */,
|
||||
@@ -2036,7 +2031,7 @@
|
||||
F3BA800C1CFB286F003DC1BA /* DatabaseError.swift in Sources */,
|
||||
566B91301FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */,
|
||||
F3BA80221CFB288C003DC1BA /* NSNumber.swift in Sources */,
|
||||
5653EB4620961F6100F46237 /* AssociationQuery.swift in Sources */,
|
||||
5653EB4620961F6100F46237 /* JoinQuery.swift in Sources */,
|
||||
F3BA80321CFB28A4003DC1BA /* FetchedRecordsController.swift in Sources */,
|
||||
5659F48D1EA8D94E004A4992 /* Utils.swift in Sources */,
|
||||
F3BA80231CFB288C003DC1BA /* NSString.swift in Sources */,
|
||||
@@ -2273,7 +2268,6 @@
|
||||
563EF44D2161F196007DAACD /* Inflections.swift in Sources */,
|
||||
566B910B1FA4C3970012D5B0 /* Database+Statements.swift in Sources */,
|
||||
566B91251FA4CF810012D5B0 /* Database+Schema.swift in Sources */,
|
||||
5653EB4D20961F6100F46237 /* AssociationRequest.swift in Sources */,
|
||||
56CEB5131EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */,
|
||||
5659F4921EA8D964004A4992 /* ReadWriteBox.swift in Sources */,
|
||||
566A842D20413D9A00E50BFD /* DatabaseSnapshot.swift in Sources */,
|
||||
@@ -2344,7 +2338,7 @@
|
||||
F3BA80681CFB2E55003DC1BA /* DatabaseError.swift in Sources */,
|
||||
566B912D1FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */,
|
||||
F3BA807E1CFB2E61003DC1BA /* NSNumber.swift in Sources */,
|
||||
5653EB4520961F6100F46237 /* AssociationQuery.swift in Sources */,
|
||||
5653EB4520961F6100F46237 /* JoinQuery.swift in Sources */,
|
||||
F3BA808E1CFB2E7A003DC1BA /* FetchedRecordsController.swift in Sources */,
|
||||
5659F48A1EA8D94E004A4992 /* Utils.swift in Sources */,
|
||||
F3BA807F1CFB2E61003DC1BA /* NSString.swift in Sources */,
|
||||
|
||||
Reference in new issue
Block a user