From 5464d6418078fbda230602625aaed4ac9ee832b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 5 Dec 2020 12:24:05 +0100 Subject: [PATCH] Prevent an infinite loop of self-proxying TableAlias I saw once --- .../SQLGeneration/SQLGenerationContext.swift | 8 ++++++++ 1 file changed, 8 insertions(+) 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) {