Class
SQLReturningResultBuilder
A builder returned from the methods of
SQLReturningBuilder; this builder wraps the original builder with one which provides SQLQueryFetcher conformance. As such, the returning(_:) methods must always be the last ones in any call chain.final class SQLReturningResultBuilder<QueryBuilder> where QueryBuilder : SQLReturningBuilder
Overview
Example:
// Correct:
db.insert(into: "foo").model(foo).returning("id").first() // Returns a row containing an "id" column
// Incorrect:
db.insert(into: "foo").returning("id").model(foo).first() // Syntax error
Note
The only reason we can’t make SQLReturningResultBuilder conditionally conform to the other builder protocols and thus remove the “last-in-chain” restriction is that it has historically exposed its query and database properties as both mutable and public, whereas they are get-only in the SQLQueryBuilder protocol - a classic example of Hyrum’s Law and its consequences. Conforming SQLReturningBuilder directly to SQLQueryFetcher would have been a simpler approach, but then the availability of the fetching methods would not have been contingent upon the presence of a returning clause.
Topics
Instance Properties
Relationships
Conforms To
See Also
Query Builders
SQLAlterEnumBuilderBuildsSQLAlterEnumqueries.SQLAlterTableBuilderBuildsSQLAlterTablequeries.SQLConflictUpdateBuilderA builder for specifying column updates and an optional predicate to be applied to rows that caused unique key conflicts during anINSERT.SQLCreateEnumBuilderBuildsSQLCreateEnumqueries.SQLCreateIndexBuilderBuildsSQLCreateIndexqueries.SQLCreateTableBuilderBuildsSQLCreateTablequeries.SQLCreateTriggerBuilderBuildsSQLCreateTriggerqueries.SQLDeleteBuilderBuildsSQLDeletequeries.SQLDropEnumBuilderBuildsSQLDropEnumqueries.SQLDropIndexBuilderBuildsSQLDropIndexqueries.SQLDropTableBuilderBuildsSQLDropTablequeries.SQLDropTriggerBuilderBuildsSQLDropTriggerqueries.SQLInsertBuilderBuildsSQLInsertqueries.SQLPredicateGroupBuilderNestedSQLPredicateBuilderfor building expression groups.SQLRawBuilderBuilds raw SQL queries.