From 2f2dc86c9d0810df657e544893b40fc04d643ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 8 Dec 2016 17:20:32 +0100 Subject: [PATCH] Documentation --- GRDB/Core/Request.swift | 2 +- README.md | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/GRDB/Core/Request.swift b/GRDB/Core/Request.swift index 32a77894b..fffff563d 100644 --- a/GRDB/Core/Request.swift +++ b/GRDB/Core/Request.swift @@ -44,7 +44,7 @@ public struct AnyRequest : Request { private let _prepare: (Database) throws -> (SelectStatement, RowAdapter?) } -/// TODO +/// A Request built from raw SQL. public struct SQLRequest : Request { /// Creates a fetch request from an SQL string, optional arguments, and /// optional row adapter. diff --git a/README.md b/README.md index a76cf11b0..47358f6b6 100644 --- a/README.md +++ b/README.md @@ -3232,7 +3232,7 @@ try request.fetchCount() // Int try request.deleteAll() ``` -**Whenever the query interface can not generate the SQL you need**, you can still build requests on top of the `Request` and `TypedRequest` protocols. Those protocols can't count or delete, but they can fetch: +**When the query interface can not generate the SQL you need**, you can still build requests on top of the `Request` and `TypedRequest` protocols. Unlike QueryInterfaceRequest, these protocols can't count or delete. But they can fetch: ```swift /// The protocol for all types that define a way to fetch values from @@ -3250,6 +3250,8 @@ protocol TypedRequest : Request { } ``` +The `prepare(_:)` function returns a tuple made of a [prepared statement](#prepared-statements) and an optional [row adapter](#row-adapters). + A Request doesn't know what to fetch, but it can be used by any fetchable type ([row](#fetching-rows), [value](#values), or [record](#records)): ```swift @@ -3276,12 +3278,14 @@ extension Request { func bound(to type: T.Type) -> AnyTypedRequest } +/// A Request built from raw SQL. struct SQLRequest : Request { /// Creates a fetch request from an SQL string, optional arguments, and /// optional row adapter. init(sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) } +/// A type-erased Request. struct AnyRequest : Request { /// Creates a new fetch request that wraps and forwards operations /// to `request`. @@ -3292,6 +3296,7 @@ struct AnyRequest : Request { init(_ prepare: @escaping (Database) throws -> (SelectStatement, RowAdapter?)) } +/// A type-erased TypedRequest. struct AnyTypedRequest : TypedRequest { /// The fetched type typealias Fetched = T