From f799d5f30c335774aa87a2eedadaef5115079aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 9 May 2020 20:45:37 +0200 Subject: [PATCH] Documentation --- GRDB/Core/FetchRequest.swift | 10 ++++++++-- GRDB/Core/SQLRequestProtocol.swift | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/GRDB/Core/FetchRequest.swift b/GRDB/Core/FetchRequest.swift index 20dd8585d..db259452e 100644 --- a/GRDB/Core/FetchRequest.swift +++ b/GRDB/Core/FetchRequest.swift @@ -87,8 +87,14 @@ public protocol FetchRequest: SQLRequestProtocol, DatabaseRegionConvertible { /// /// - parameter db: A database connection. /// - parameter singleResult: A hint that a single result row will be - /// consumed. Implementations can optionally use this to optimize the - /// prepared statement. + /// consumed. Implementations can optionally use it to optimize the + /// prepared statement, for example by adding a `LIMIT 1` SQL clause. + /// + /// // Calls makePreparedRequest(db, forSingleResult: true) + /// try request.fetchOne(db) + /// + /// // Calls makePreparedRequest(db, forSingleResult: false) + /// try request.fetchAll(db) /// - returns: A prepared request. func makePreparedRequest(_ db: Database, forSingleResult singleResult: Bool) throws -> PreparedRequest diff --git a/GRDB/Core/SQLRequestProtocol.swift b/GRDB/Core/SQLRequestProtocol.swift index fe406f56a..edaa9d290 100644 --- a/GRDB/Core/SQLRequestProtocol.swift +++ b/GRDB/Core/SQLRequestProtocol.swift @@ -1,13 +1,13 @@ /// The protocol that can generate SQL requests and subqueries. public protocol SQLRequestProtocol: SQLExpression, SQLCollection { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) - /// + /// /// Returns the request SQL. /// /// - parameter context: An SQL generation context. /// - parameter singleResult: A hint that a single result row will be - /// consumed. Implementations can optionally use this to optimize the - /// returned SQL. + /// consumed. Implementations can optionally use it to optimize the + /// generated SQL, for example by adding a `LIMIT 1` SQL clause. /// - returns: An SQL string. func requestSQL(_ context: SQLGenerationContext, forSingleResult singleResult: Bool) throws -> String }