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
allColumnsThe list of all column names available in the row, in no particular order.
Instance Methods
contains(column:)Returnstrueif the given column name is available in the row,falseotherwise.decode(column:as:)If the given column name exists in the row, attempt to decode it as the given type and return the result if successful.decode(column:inferringAs:)This 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:decode(model:prefix:keyDecodingStrategy:userInfo:)Decode an entireDecodable“model” type at once, optionally applying a prefix and/orSQLRowDecoder.KeyDecodingStrategyto the type’s coding keys.decode(model:with:)Decode an entireDecodable“model” type at once using an explicitSQLRowDecoder.decodeNil(column:)Must 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
SQLDatabaseThe common interface to SQLKit for both drivers and client code.SQLRowDecoderAn implementation ofDecoderdesigned to decode “models” (or, in general, aggregateDecodabletypes) fromSQLRows returned from a database query.SQLQueryEncoderAn implementation ofEncoderdesigned to encode “models” (or, in general, aggregateEncodabletypes) into a form which can be used as input to a database query.