diff --git a/Docs/API/Enums/PostgresError.html b/Docs/API/Enums/PostgresError.html index 2b61035..3736296 100644 --- a/Docs/API/Enums/PostgresError.html +++ b/Docs/API/Enums/PostgresError.html @@ -85,6 +85,33 @@
+
+
+ columnMetadataNotAvailable
+
+ Cursor.columns is nil, indicating column metadata is not available.
Swift
+case columnMetadataNotAvailable
+
+
diff --git a/Docs/API/Structs.html b/Docs/API/Structs.html
index 75a40f7..a07a9c0 100644
--- a/Docs/API/Structs.html
+++ b/Docs/API/Structs.html
@@ -274,7 +274,8 @@ Declaration
Declaration
Swift
- public struct PostgresByteA : PostgresValueConvertible, Equatable, CustomStringConvertible
+ public struct PostgresByteA:
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
Swift
-public struct PostgresDate : PostgresValueConvertible, Equatable, CustomStringConvertible
+ public struct PostgresDate:
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
Swift
-public struct PostgresTime : PostgresValueConvertible, Equatable, CustomStringConvertible
+ public struct PostgresTime:
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
Swift
public struct PostgresTimeWithTimeZone:
- PostgresValueConvertible, Equatable, CustomStringConvertible
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
Swift
-public struct PostgresTimestamp : PostgresValueConvertible, Equatable, CustomStringConvertible
+ public struct PostgresTimestamp:
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
Swift
public struct PostgresTimestampWithTimeZone:
- PostgresValueConvertible, Equatable, CustomStringConvertible
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
public struct PostgresByteA : PostgresValueConvertible, Equatable, CustomStringConvertible
+ public struct PostgresByteA:
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
+
+
+ init(from:)
+
+ Swift
+public init(from decoder: Decoder) throws
+
+ public struct PostgresDate : PostgresValueConvertible, Equatable, CustomStringConvertible
+ public struct PostgresDate:
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
+
+
+ init(from:)
+
+ Swift
+public init(from decoder: Decoder) throws
+
+ public struct PostgresTime : PostgresValueConvertible, Equatable, CustomStringConvertible
+ public struct PostgresTime:
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
+
+
+ init(from:)
+
+ Swift
+public init(from decoder: Decoder) throws
+
+ public struct PostgresTimeWithTimeZone:
- PostgresValueConvertible, Equatable, CustomStringConvertible
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
+
+
+ init(from:)
+
+ Swift
+public init(from decoder: Decoder) throws
+
+ public struct PostgresTimestamp : PostgresValueConvertible, Equatable, CustomStringConvertible
+ public struct PostgresTimestamp:
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
+
+
+ init(from:)
+
+ Swift
+public init(from decoder: Decoder) throws
+
+ public struct PostgresTimestampWithTimeZone:
- PostgresValueConvertible, Equatable, CustomStringConvertible
+ PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
+
+
+ init(from:)
+
+ Swift
+public init(from decoder: Decoder) throws
+
+
+
+
+ decodeByColumnName(_:defaultTimeZone:)
+
+ Decodes this Row to create an instance of the specified type.
The type specified must conform to the Decodable protocol. This method uses the column
+metadata provided by Cursor.columns to create a new instance of that type whose stored
+properties are set to the values of like-named columns. (To make this column metadata
+available, set retrieveColumnMetadata to true in calling
+Statement.execute(parameterValues:retrieveColumnMetadata:).)
The supported property types are a superset of the types supported by PostgresValue:
| Type of stored property | +Conversion performed | +
|---|---|
Bool |
+postgresValue.bool() |
+
String |
+postgresValue.string() |
+
Double |
+postgresValue.double() |
+
Float |
+Float(postgresValue.double()) |
+
Int |
+postgresValue.int() |
+
Int8 |
+Int8(postgresValue.string()) |
+
Int16 |
+Int16(postgresValue.string()) |
+
Int32 |
+Int32(postgresValue.string()) |
+
Int64 |
+Int64(postgresValue.string()) |
+
UInt |
+UInt(postgresValue.string()) |
+
UInt8 |
+UInt8(postgresValue.string()) |
+
UInt16 |
+UInt16(postgresValue.string()) |
+
UInt32 |
+UInt32(postgresValue.string()) |
+
UInt64 |
+UInt64(postgresValue.string()) |
+
PostgresByteA |
+postgresValue.byteA() |
+
PostgresTimestampWithTimeZone |
+postgresValue.timestampWithTimeZone() |
+
PostgresTimestamp |
+postgresValue.timestamp() |
+
PostgresDate |
+postgresValue.date() |
+
PostgresTime |
+postgresValue.time() |
+
PostgresTimeWithTimeZone |
+postgresValue.timeWithTimeZone() |
+
Date |
+see below | +
Foundation Date stored properties are decoded as follows:
postgresValue.timestampWithTimeZone().date, if successful;postgresValue.timestamp().date(in: defaultTimeZone), if successful;postgresValue.date().date(in: defaultTimeZone), if successful;postgresValue.time().date(in: defaultTimeZone), if successful;postgresValue.timeWithTimeZone().date, if successful(Instead of Date, consider using PostgresTimestampWithTimeZone, PostgresTimestamp,
+PostgresDate, PostgresTime, and PostgresTimeWithTimeZone whenever possible.)
Example:
+struct Weather: Decodable {
+ let date: PostgresDate
+ let city: String
+ let temp_lo: Int
+ let temp_hi: Int
+ let prcp: Double?
+}
+
+let connection: Connection = ...
+
+// Note that the columns must have the same names as the Weather
+// properties, but may be in a different order.
+let text = "SELECT city, temp_lo, temp_hi, prcp, date FROM weather;"
+let statement = try connection.prepareStatement(text: text)
+let cursor = try statement.execute(retrieveColumnMetadata: true)
+
+for row in cursor {
+ let weather = try row.get().decodeByColumnName(Weather.self)
+ ...
+}
+
+Throws
+PostgresError.columnMetadataNotAvailable if column metadata is not available;
+ DecodingError if the operation otherwise fails
+
+Swift
+public func decodeByColumnName<T: Decodable>(_ type: T.Type,
+ defaultTimeZone: TimeZone? = nil) throws -> T
+
+
+
+ type
+
+ |
+
+
+
+ the type of instance to create + |
+
+
+ defaultTimeZone
+
+ |
+
+
+
+ the default time zone for certain conversions to Foundation |
+
an instance of the specified type
+
+
+
+ decodeByColumnIndex(_:defaultTimeZone:)
+
+ Decodes this Row to create an instance of the specified type.
The type specified must conform to the Decodable protocol. This method matches columns
+to stored properties based on decoding order: the first property decoded is assigned the
+value of columns[0], the second property is assigned the value of columns[1], and so
+on. By default, a Decodable type decodes its properties in declaration order. This
+default behavior can be overridden by providing implementations of the CodingKeys enum
+and the init(from:) initializer. Refer to Apple’s developer documentation
+for further information.
The supported property types are a superset of the types supported by PostgresValue:
| Type of stored property | +Conversion performed | +
|---|---|
Bool |
+postgresValue.bool() |
+
String |
+postgresValue.string() |
+
Double |
+postgresValue.double() |
+
Float |
+Float(postgresValue.double()) |
+
Int |
+postgresValue.int() |
+
Int8 |
+Int8(postgresValue.string()) |
+
Int16 |
+Int16(postgresValue.string()) |
+
Int32 |
+Int32(postgresValue.string()) |
+
Int64 |
+Int64(postgresValue.string()) |
+
UInt |
+UInt(postgresValue.string()) |
+
UInt8 |
+UInt8(postgresValue.string()) |
+
UInt16 |
+UInt16(postgresValue.string()) |
+
UInt32 |
+UInt32(postgresValue.string()) |
+
UInt64 |
+UInt64(postgresValue.string()) |
+
PostgresByteA |
+postgresValue.byteA() |
+
PostgresTimestampWithTimeZone |
+postgresValue.timestampWithTimeZone() |
+
PostgresTimestamp |
+postgresValue.timestamp() |
+
PostgresDate |
+postgresValue.date() |
+
PostgresTime |
+postgresValue.time() |
+
PostgresTimeWithTimeZone |
+postgresValue.timeWithTimeZone() |
+
Date |
+see below | +
Foundation Date stored properties are decoded as follows:
postgresValue.timestampWithTimeZone().date, if successful;postgresValue.timestamp().date(in: defaultTimeZone), if successful;postgresValue.date().date(in: defaultTimeZone), if successful;postgresValue.time().date(in: defaultTimeZone), if successful;postgresValue.timeWithTimeZone().date, if successful(Instead of Date, consider using PostgresTimestampWithTimeZone, PostgresTimestamp,
+PostgresDate, PostgresTime, and PostgresTimeWithTimeZone whenever possible.)
Example:
+struct Weather: Decodable {
+ let city: String
+ let lowestTemperature: Int
+ let highestTemperature: Int
+ let precipitation: Double?
+ let date: PostgresDate
+}
+
+let connection: Connection = ...
+
+// Notice that the columns must be in the same order as the Weather
+// properties, but may have different names.
+let text = "SELECT city, temp_lo, temp_hi, prcp, date FROM weather;"
+let statement = try connection.prepareStatement(text: text)
+let cursor = try statement.execute()
+
+for row in cursor {
+ let weather = try row.get().decodeByColumnIndex(Weather.self)
+ ...
+}
+
+Throws
+DecodingError if the operation fails
+
+Swift
+public func decodeByColumnIndex<T: Decodable>(_ type: T.Type,
+ defaultTimeZone: TimeZone? = nil) throws -> T
+
+
+
+ type
+
+ |
+
+
+
+ the type of instance to create + |
+
+
+ defaultTimeZone
+
+ |
+
+
+
+ the default time zone for certain conversions to Foundation |
+
an instance of the specified type
+