diff --git a/GRDB/Core/FetchRequest.swift b/GRDB/Core/FetchRequest.swift index 536ede493..f3d561860 100644 --- a/GRDB/Core/FetchRequest.swift +++ b/GRDB/Core/FetchRequest.swift @@ -22,15 +22,29 @@ public protocol _FetchRequest { /// // We know that "SELECT 1 AS a, 2 AS b" selects two columns, /// // so we can find cte columns in the row: /// row.scopes["cte"] // [a:1, b:2] + /// + /// :nodoc: func _selectedColumnCount(_ db: Database) throws -> Int /// Returns the request SQL. /// + /// This method makes it possible to embed a request as a subquery: + /// + /// // SELECT * + /// // FROM "player" + /// // WHERE "score" = (SELECT MAX("score") FROM "player") + /// let maxScore = Player.select(max(Column("score"))) + /// let players = try Player + /// .filter(Column("score") == maxScore) + /// .fetchAll(db) + /// /// - parameter context: An SQL generation context. /// - parameter singleResult: A hint that a single result row will be /// consumed. Implementations can optionally use it to optimize the /// generated SQL, for example by adding a `LIMIT 1` SQL clause. /// - returns: An SQL string. + /// + /// :nodoc: func _requestSQL(_ context: SQLGenerationContext, forSingleResult singleResult: Bool) throws -> String } diff --git a/GRDB/QueryInterface/SQL/SQLCollection.swift b/GRDB/QueryInterface/SQL/SQLCollection.swift index 8f3712dc6..198a8a457 100644 --- a/GRDB/QueryInterface/SQL/SQLCollection.swift +++ b/GRDB/QueryInterface/SQL/SQLCollection.swift @@ -1,5 +1,8 @@ // MARK: - SQLCollection +/// Implementation details of `SQLCollection`. +/// +/// :nodoc: public protocol _SQLCollection { /// Returns a qualified collection. /// @@ -8,6 +11,14 @@ public protocol _SQLCollection { /// The expressions in the collection, if known. /// + /// This property makes it possible to track individual rows identified by + /// their row ids, and ignore modifications to other rows: + /// + /// // Track rows 1, 2, 3 only + /// let request = Player.filter(keys: [1, 2, 3]) + /// let regionObservation = DatabaseRegionObservation(tracking: request) + /// let valueObservation = ValueObservation.tracking(request.fetchAll) + /// /// :nodoc: var _collectionExpressions: [SQLExpression]? { get }