Documentation

This commit is contained in:
Gwendal Roué committed 2020-12-23 10:08:30 +01:00
1 parent b485d4d3dc
commit dc16fae72e
2 files changed
+25

No files matched your search

+14
View File
@@ -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
}
@@ -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 }