YAGNI: JoinCondition.sqlExpression is not optional

This commit is contained in:
Gwendal Roué committed 2019-02-03 08:42:37 +01:00
1 parent 950fa607a1
commit 5ea914ce0a
2 files changed
+3 -5

No files matched your search

@@ -360,9 +360,7 @@ extension Association where OriginRowDecoder: MutablePersistableRecord {
.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._impl.joinCondition.sqlExpression(db, leftAlias: recordAlias, rightAlias: associationAlias) else {
fatalError("Can't request from record without join condition")
}
let joinExpression = try self._impl.joinCondition.sqlExpression(db, leftAlias: recordAlias, rightAlias: associationAlias)
// Serialize record: ["id": 123, ...]
// We do it as late as possible, when request is about to be
+2 -2
View File
@@ -1,4 +1,4 @@
/// The SQLSelectQuery generates SQL for query interface requests.
/// SQLSelectQuery generates SQL for query interface requests.
struct SQLSelectQuery {
var relation: SQLRelation
var isDistinct: Bool
@@ -424,7 +424,7 @@ public /* TODO: internal */ struct JoinCondition: Equatable {
/// - parameter rightAlias: A TableAlias for the table on the right of the
/// JOIN operator.
/// - Returns: An SQL expression.
func sqlExpression(_ db: Database, leftAlias: TableAlias, rightAlias: TableAlias) throws -> SQLExpression? {
func sqlExpression(_ db: Database, leftAlias: TableAlias, rightAlias: TableAlias) throws -> SQLExpression {
let foreignKeyMapping = try foreignKeyRequest.fetch(db).mapping
let columnMapping: [(left: Column, right: Column)]
if originIsLeft {