Skip to content

Commit def4fe8

Browse files
authored
Add hasColumn to PostgresRandomAccessRow (#270)
1 parent e9e431c commit def4fe8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Sources/PostgresNIO/Data/PostgresRow.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ extension PostgresRandomAccessRow: RandomAccessCollection {
178178
}
179179
return self[index]
180180
}
181+
182+
/// Checks if the row contains a cell for the given column name.
183+
/// - Parameter column: The column name to check against
184+
/// - Returns: `true` if the row contains this column, `false` if it does not.
185+
public func contains(_ column: String) -> Bool {
186+
self.lookupTable[column] != nil
187+
}
181188
}
182189

183190
extension PostgresRandomAccessRow {
@@ -286,8 +293,8 @@ extension PostgresRow {
286293

287294
@available(*, deprecated, message: """
288295
This call is O(n) where n is the number of cells in the row. For random access to cells
289-
in a row create a PostgresRandomAccessCollection from the row first and use its subscript
290-
methods.
296+
in a row create a PostgresRandomAccessRow from the row first and use its subscript
297+
methods. (see `makeRandomAccess()`)
291298
""")
292299
public func column(_ column: String) -> PostgresData? {
293300
guard let index = self.lookupTable[column] else {

0 commit comments

Comments
 (0)