         argumentsSink: StatementArgumentsSink = StatementArgumentsSink(),
         aliases: [TableAlias] = [])
     {
-        self.impl = .base(db: db, argumentsSink: argumentsSink)
+        self.parent = .none(db: db, argumentsSink: argumentsSink)
         self.resolvedNames = aliases.resolvedNames
         self.ownAliases = Set(aliases)
     }
     
     /// Creates a generation context.
     ///
-    /// - parameter db: A database connection.
-    /// - parameter argumentsSink: An arguments sink.
+    /// - parameter parent: A parent context.
     /// - parameter aliases: An array of table aliases to disambiguate.
     init(
         parent: SQLGenerationContext,
         aliases: [TableAlias] = [])
     {
-        self.impl = .parent(parent)
+        self.parent = .context(parent)
         self.resolvedNames = aliases.resolvedNames
         self.ownAliases = Set(aliases)
     }

        if let name = resolvedNames[alias] {
            return name
        }
        switch impl {
        case .base:
            return alias.identityName
        case let .parent(context):
            return context.resolvedName(for: alias)
        }
    }

///
/// :nodoc:
public final class SQLGenerationContext {
    private enum Parent {
        case none(db: Database, argumentsSink: StatementArgumentsSink)
        case context(SQLGenerationContext)
    }
    
    /// A database connection so that request elements can perform database
    /// introspection in order to build their SQL representation.
    var db: Database {
        switch parent {
        case let .none(db: db, argumentsSink: _): return db
        case let .context(context): return context.db
        }
    }
    
    /// All gathered arguments
    var arguments: StatementArguments { argumentsSink.arguments }
    
    /// Access to the database connection, the arguments sink, and resolved
    /// names of table aliases from outer contexts (useful in case of
    /// subquery generation).
    private let parent: Parent
    
    /// The arguments sink which prevents SQL injection.
    private var argumentsSink: StatementArgumentsSink {
        switch parent {
        case let .none(db: _, argumentsSink: argumentsSink): return argumentsSink
        case let .context(context): return context.argumentsSink
        }
    }
    
    private let resolvedNames: [TableAlias: String]
    private let ownAliases: Set<TableAlias>
    
    /// Creates a generation context.
    ///
