diff --git a/GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift b/GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift index 746df500e..2c2a0f754 100644 --- a/GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift +++ b/GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift @@ -289,6 +289,10 @@ public class TableAlias: Hashable { } func becomeProxy(of base: TableAlias) { + if self === base { + return + } + switch impl { case let .undefined(userName): if let userName = userName { @@ -312,6 +316,10 @@ public class TableAlias: Hashable { /// Returns nil if aliases can't be merged (conflict in tables, aliases...) func merged(with other: TableAlias) -> TableAlias? { + if self === other { + return self + } + let root = self.root let otherRoot = other.root switch (root.impl, otherRoot.impl) {