mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Cleanup
This commit is contained in:
1 parent
5747d1cff0
commit
5e7235307a
4 files changed
+24
-34
No files matched your search
@@ -56,10 +56,6 @@ public protocol Association: SelectionRequest, FilteredRequest, OrderedRequest {
|
||||
func mapRequest(_ transform: (AssociationRequest<RightAssociated>) -> AssociationRequest<RightAssociated>) -> Self
|
||||
}
|
||||
|
||||
func defaultAssociationKey<T: TableRecord>(for type: T.Type) -> String {
|
||||
return T.databaseTableName
|
||||
}
|
||||
|
||||
extension Association {
|
||||
/// Creates an association with a new net of selected columns.
|
||||
///
|
||||
|
||||
@@ -11,15 +11,14 @@ public struct BelongsToAssociation<Left, Right> : Association, TableRequest wher
|
||||
public var databaseTableName: String { return RightAssociated.databaseTableName }
|
||||
|
||||
/// :nodoc:
|
||||
public let request: AssociationRequest<Right>
|
||||
public var request: AssociationRequest<Right>
|
||||
|
||||
let foreignKeyRequest: ForeignKeyRequest
|
||||
|
||||
public func forKey(_ key: String) -> BelongsToAssociation<Left, Right> {
|
||||
return BelongsToAssociation(
|
||||
key: key,
|
||||
request: request,
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
var association = self
|
||||
association.key = key
|
||||
return association
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
@@ -31,10 +30,9 @@ public struct BelongsToAssociation<Left, Right> : Association, TableRequest wher
|
||||
|
||||
/// :nodoc:
|
||||
public func mapRequest(_ transform: (AssociationRequest<Right>) -> AssociationRequest<Right>) -> BelongsToAssociation<Left, Right> {
|
||||
return BelongsToAssociation(
|
||||
key: key,
|
||||
request: transform(request),
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
var association = self
|
||||
association.request = transform(request)
|
||||
return association
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +51,7 @@ extension TableRecord {
|
||||
foreignKey: foreignKey)
|
||||
|
||||
return BelongsToAssociation(
|
||||
key: key ?? defaultAssociationKey(for: Right.self),
|
||||
key: key ?? Right.databaseTableName,
|
||||
request: AssociationRequest(rightRequest),
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
}
|
||||
|
||||
@@ -11,15 +11,14 @@ public struct HasManyAssociation<Left, Right> : Association, TableRequest where
|
||||
public var databaseTableName: String { return RightAssociated.databaseTableName }
|
||||
|
||||
/// :nodoc:
|
||||
public let request: AssociationRequest<Right>
|
||||
public var request: AssociationRequest<Right>
|
||||
|
||||
let foreignKeyRequest: ForeignKeyRequest
|
||||
|
||||
public func forKey(_ key: String) -> HasManyAssociation<Left, Right> {
|
||||
return HasManyAssociation(
|
||||
key: key,
|
||||
request: request,
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
var association = self
|
||||
association.key = key
|
||||
return association
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
@@ -31,10 +30,9 @@ public struct HasManyAssociation<Left, Right> : Association, TableRequest where
|
||||
|
||||
/// :nodoc:
|
||||
public func mapRequest(_ transform: (AssociationRequest<Right>) -> AssociationRequest<Right>) -> HasManyAssociation<Left, Right> {
|
||||
return HasManyAssociation(
|
||||
key: key,
|
||||
request: transform(request),
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
var association = self
|
||||
association.request = transform(request)
|
||||
return association
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +51,7 @@ extension TableRecord {
|
||||
foreignKey: foreignKey)
|
||||
|
||||
return HasManyAssociation(
|
||||
key: key ?? defaultAssociationKey(for: Right.self),
|
||||
key: key ?? Right.databaseTableName,
|
||||
request: AssociationRequest(rightRequest),
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
}
|
||||
|
||||
@@ -11,15 +11,14 @@ public struct HasOneAssociation<Left, Right> : Association, TableRequest where
|
||||
public var databaseTableName: String { return RightAssociated.databaseTableName }
|
||||
|
||||
/// :nodoc:
|
||||
public let request: AssociationRequest<Right>
|
||||
public var request: AssociationRequest<Right>
|
||||
|
||||
let foreignKeyRequest: ForeignKeyRequest
|
||||
|
||||
public func forKey(_ key: String) -> HasOneAssociation<Left, Right> {
|
||||
return HasOneAssociation(
|
||||
key: key,
|
||||
request: request,
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
var association = self
|
||||
association.key = key
|
||||
return association
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
@@ -31,10 +30,9 @@ public struct HasOneAssociation<Left, Right> : Association, TableRequest where
|
||||
|
||||
/// :nodoc:
|
||||
public func mapRequest(_ transform: (AssociationRequest<Right>) -> AssociationRequest<Right>) -> HasOneAssociation<Left, Right> {
|
||||
return HasOneAssociation(
|
||||
key: key,
|
||||
request: transform(request),
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
var association = self
|
||||
association.request = transform(request)
|
||||
return association
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +51,7 @@ extension TableRecord {
|
||||
foreignKey: foreignKey)
|
||||
|
||||
return HasOneAssociation(
|
||||
key: key ?? defaultAssociationKey(for: Right.self),
|
||||
key: key ?? Right.databaseTableName,
|
||||
request: AssociationRequest(rightRequest),
|
||||
foreignKeyRequest: foreignKeyRequest)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user