mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Warn against selectID() when the ID type is an optional.
This commit is contained in:
1 parent
87b236dfe0
commit
494e697e94
3 files changed
+54
No files matched your search
@@ -290,6 +290,26 @@ extension QueryInterfaceRequest: SelectionRequest {
|
||||
/// // SELECT id FROM player WHERE ...
|
||||
/// let request = try Player.filter(...).selectID()
|
||||
/// ```
|
||||
///
|
||||
/// **Important**: if the record type has an `ID` type that is an
|
||||
/// optional, such as `Int64?`, it is recommended to prefer
|
||||
/// ``selectPrimaryKey(as:)`` instead:
|
||||
///
|
||||
/// ```swift
|
||||
/// struct Player: Identifiable {
|
||||
/// var id: Int64?
|
||||
/// }
|
||||
///
|
||||
/// // NOT RECOMMENDED: Set<Int64?>
|
||||
/// let ids = try Player.filter(...)
|
||||
/// .selectID()
|
||||
/// .fetchSet(db)
|
||||
///
|
||||
/// // BETTER: Set<Int64>
|
||||
/// let ids = try Player.filter(...)
|
||||
/// .selectPrimaryKey(as: Int64.self)
|
||||
/// .fetchSet(db)
|
||||
/// ```
|
||||
public func selectID() -> QueryInterfaceRequest<RowDecoder.ID>
|
||||
where RowDecoder: Identifiable
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user