Commit Graph
11 Commits
Author SHA1 Message Date
Gwendal Roué 2316fb3831 Prefer key paths when possible 2025-05-11 11:12:19 +02:00
Gwendal Roué 96d04716c2 Update more documentation with the closure syntax 2025-05-11 10:57:20 +02:00
Gwendal Roué 352f77f225 Stop recommending String enums for Columns.
We now recommend:

    enum Columns {
        static let id = Column("id")
        static let title = Column("title")
        static let latitude = Column("latitude")
        static let longitude = Column("longitude")
    }

Instead of the previous recommendation:

    enum Columns: String, ColumnExpression {
        case id, title, latitude, longitude
    }

This is because SE-0438 does not support Metatype Keypaths for enums. A request like `Place.order(\.title)` does not compile with a String enum.
2025-05-10 09:36:14 +02:00
Gwendal Roué 87b236dfe0 selectID
This reverts 7ffc332327

At the time, selectID was replaced with selectPrimaryKey(as:) because:

> Since Optional is a database value like others, selectID would be a request of optionals for records with an optional ID type:
>
>     struct Player: Identifiable, MutablePersistableRecord {
>         var id: Int64?
>     }
>
>     Player.selectID() // QueryInterface<Int64?>
>
> This is not good, because primary keys are not null. And those requests would fetch impractical types such as [Int64?], Set<Int64?>, Int64??.

This problem is reintroduced, but we now recommend against optional ids in https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/recordrecommendedpractices. And record with optional ids can use selectPrimaryKey(as:).
2025-02-11 20:47:49 +01:00
Gwendal Roué 13b6c9d36b Split database schema documentation into several files, and restore the overview of database schema features
Fixes #1623
2024-10-13 10:54:13 +02:00
Gwendal Roué 0eb973b6db Record types with an auto-incremented id should avoid the Identifiable protocol. 2023-10-04 22:02:18 +02:00
Gwendal Roué 466ecd5ba5 Documentation 2023-07-09 17:22:38 +02:00
Gwendal Roué 0d49d7612f Enhance wording 2023-05-01 12:16:48 +02:00
Gwendal Roué 18cdf4956e Fix typos 2023-04-10 16:52:03 +02:00
Gwendal Roué 859a1d6184 Enhance Recommended Practices for Designing Record Types 2023-04-10 14:11:39 +02:00
Gwendal Roué 52a3d6ba23 Move the "Recommended Practices for Designing Record Types" to DocC 2023-04-10 09:51:38 +02:00