Protocol
SQLRow
Represents a single row in a result set returned from an executed SQL query.
protocol SQLRow : Sendable
Mentioned in
Overview
Each of the protocol’s requirements corresponds closely to a similarly-named requirement of Swift’s KeyedDecodingContainerProtocol, in order to provide a Codable-like interface for generic row access. The additional logic which covers the gap between Decodable types and SQLRows is provided by SQLRowDecoder; see that type for additional discussion and further detail.
Topics
Instance Properties
var allColumns: [String]The list of all column names available in the row, in no particular order.
Instance Methods
func contains(column: String) -> BoolReturnstrueif the given column name is available in the row,falseotherwise.func decode<D>(column: String, as: D.Type) throws -> DIf the given column name exists in the row, attempt to decode it as the given type and return the result if successful.func decode<D>(column: String, inferringAs: D.Type) throws -> DThis method exists to enable the compiler to perform type inference on the generic parameterDofdecode(column:as:). Protocols can not provide default arguments to methods, which is required for inference to work with generic type parameters. It is not expected that user code will invoke this method directly; rather it will be selected by the compiler automatically, as in this example:func decode<D>(model: D.Type, prefix: String?, keyDecodingStrategy: SQLRowDecoder.KeyDecodingStrategy, userInfo: [CodingUserInfoKey : any Sendable]) throws -> DDecode an entireDecodable“model” type at once, optionally applying a prefix and/orSQLRowDecoder.KeyDecodingStrategyto the type’s coding keys.func decode<D>(model: D.Type, with: SQLRowDecoder) throws -> DDecode an entireDecodable“model” type at once using an explicitSQLRowDecoder.func decodeNil(column: String) throws -> BoolMust returntrueif the given column name is missing from the row or if it exists but has a value equivalent to an SQLNULL, orfalseif the column name exists with a non-NULLvalue.
Relationships
Inherits From
Swift.SendableSwift.SendableMetatype
See Also
Data Access
protocol SQLDatabaseThe common interface to SQLKit for both drivers and client code.struct SQLRowDecoderAn implementation ofDecoderdesigned to decode “models” (or, in general, aggregateDecodabletypes) fromSQLRows returned from a database query.struct SQLQueryEncoderAn implementation ofEncoderdesigned to encode “models” (or, in general, aggregateEncodabletypes) into a form which can be used as input to a database query.