File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed
Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,26 @@ extension QueryInterfaceRequest: SelectionRequest {
290290 /// // SELECT id FROM player WHERE ...
291291 /// let request = try Player.filter(...).selectID()
292292 /// ```
293+ ///
294+ /// **Important**: if the record type has an `ID` type that is an
295+ /// optional, such as `Int64?`, it is recommended to prefer
296+ /// ``selectPrimaryKey(as:)`` instead:
297+ ///
298+ /// ```swift
299+ /// struct Player: Identifiable {
300+ /// var id: Int64?
301+ /// }
302+ ///
303+ /// // NOT RECOMMENDED: Set<Int64?>
304+ /// let ids = try Player.filter(...)
305+ /// .selectID()
306+ /// .fetchSet(db)
307+ ///
308+ /// // BETTER: Set<Int64>
309+ /// let ids = try Player.filter(...)
310+ /// .selectPrimaryKey(as: Int64.self)
311+ /// .fetchSet(db)
312+ /// ```
293313 public func selectID( ) -> QueryInterfaceRequest < RowDecoder . ID >
294314 where RowDecoder: Identifiable
295315 {
Original file line number Diff line number Diff line change @@ -435,6 +435,24 @@ extension Table {
435435 /// // SELECT id FROM player
436436 /// let request = try table.selectID()
437437 /// ```
438+ ///
439+ /// **Important**: if the record type has an `ID` type that is an
440+ /// optional, such as `Int64?`, it is recommended to prefer
441+ /// ``selectPrimaryKey(as:)`` instead:
442+ ///
443+ /// ```swift
444+ /// struct Player: Identifiable {
445+ /// var id: Int64?
446+ /// }
447+ ///
448+ /// let table = Table<Player>("player")
449+ ///
450+ /// // NOT RECOMMENDED: Set<Int64?>
451+ /// let ids = try table.selectID().fetchSet(db)
452+ ///
453+ /// // BETTER: Set<Int64>
454+ /// let ids = try table.selectPrimaryKey(as: Int64.self).fetchSet(db)
455+ /// ```
438456 public func selectID( ) -> QueryInterfaceRequest < RowDecoder . ID >
439457 where RowDecoder: Identifiable
440458 {
Original file line number Diff line number Diff line change @@ -259,6 +259,22 @@ extension TableRecord {
259259 /// // SELECT id FROM player
260260 /// let request = try Player.selectID()
261261 /// ```
262+ ///
263+ /// **Important**: if the record type has an `ID` type that is an
264+ /// optional, such as `Int64?`, it is recommended to prefer
265+ /// ``selectPrimaryKey(as:)`` instead:
266+ ///
267+ /// ```swift
268+ /// struct Player: Identifiable {
269+ /// var id: Int64?
270+ /// }
271+ ///
272+ /// // NOT RECOMMENDED: Set<Int64?>
273+ /// let ids = try Player.selectID().fetchSet(db)
274+ ///
275+ /// // BETTER: Set<Int64>
276+ /// let ids = try Player.selectPrimaryKey(as: Int64.self).fetchSet(db)
277+ /// ```
262278 public static func selectID( ) -> QueryInterfaceRequest < Self . ID >
263279 where Self: Identifiable
264280 {
You can’t perform that action at this time.
0 commit comments