Skip to content

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

  • allColumns
    The list of all column names available in the row, in no particular order.

Instance Methods

  • contains(column:)
    Returns true if the given column name is available in the row, false otherwise.
  • 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 parameter D of decode(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 entire Decodable “model” type at once, optionally applying a prefix and/or SQLRowDecoder.KeyDecodingStrategy to the type’s coding keys.
  • decode(model:with:)
    Decode an entire Decodable “model” type at once using an explicit SQLRowDecoder.
  • decodeNil(column:)
    Must return true if the given column name is missing from the row or if it exists but has a value equivalent to an SQL NULL, or false if the column name exists with a non-NULL value.

Relationships

Inherits From

  • Swift.Sendable
  • Swift.SendableMetatype

See Also

Data Access

  • SQLDatabase
    The common interface to SQLKit for both drivers and client code.
  • SQLRowDecoder
    An implementation of Decoder designed to decode “models” (or, in general, aggregate Decodable types) from SQLRows returned from a database query.
  • SQLQueryEncoder
    An implementation of Encoder designed to encode “models” (or, in general, aggregate Encodable types) into a form which can be used as input to a database query.