mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Extract SQLAssociationCondition.using
This commit is contained in:
1 parent
06000abbfd
commit
a70b42cbf5
7 files changed
+67
-29
No files matched your search
@@ -149,6 +149,10 @@ private func prefetch(_ db: Database, associations: [_SQLAssociation], in rows:
|
||||
// are not prefetched.
|
||||
fatalError("Not implemented: prefetch association without any foreign key")
|
||||
|
||||
case .using:
|
||||
#warning("TODD: prefetch on USING clause")
|
||||
fatalError("Not implemented")
|
||||
|
||||
case let .foreignKey(request: foreignKeyRequest, originIsLeft: originIsLeft):
|
||||
// Annotate prefetched rows with pivot columns, so that we can
|
||||
// group them.
|
||||
@@ -214,6 +218,10 @@ func prefetchedRegion(_ db: Database, associations: [_SQLAssociation]) throws ->
|
||||
// are not prefetched.
|
||||
fatalError("Not implemented: prefetch association without any foreign key")
|
||||
|
||||
case .using:
|
||||
#warning("TODD: prefetch region on USING clause")
|
||||
fatalError("Not implemented")
|
||||
|
||||
case let .foreignKey(request: foreignKeyRequest, originIsLeft: originIsLeft):
|
||||
// Filter the pivot on a `NullRow` in order to make sure all join
|
||||
// condition columns are made visible to SQLite, and present in the
|
||||
|
||||
@@ -821,22 +821,10 @@ private struct SQLQualifiedJoin: Refinable {
|
||||
var joinExpressions: [SQLExpression]
|
||||
switch condition {
|
||||
case let .expression(condition):
|
||||
let conditionExpression = condition(leftAlias, rightAlias).sqlExpression
|
||||
#warning("TODO: we need a expression.isTrue() method")
|
||||
if let dbValue = conditionExpression as? DatabaseValue,
|
||||
dbValue == true.databaseValue
|
||||
{
|
||||
// ON 1 <=> no ON clause
|
||||
joinExpressions = []
|
||||
} else if let expr = conditionExpression as? _SQLExpressionAssociativeBinary,
|
||||
expr.op == .and,
|
||||
expr.expressions.isEmpty
|
||||
{
|
||||
// ON (nothing) <=> no ON clause
|
||||
joinExpressions = []
|
||||
} else {
|
||||
joinExpressions = [conditionExpression]
|
||||
}
|
||||
joinExpressions = [condition(leftAlias, rightAlias).sqlExpression]
|
||||
|
||||
case let .using(columns):
|
||||
joinExpressions = columns.map { leftAlias[$0] == rightAlias[$0] }
|
||||
|
||||
case let .foreignKey(request: foreignKeyRequest, originIsLeft: originIsLeft):
|
||||
joinExpressions = try foreignKeyRequest
|
||||
|
||||
Reference in new issue
Block a user