From 96c9eb5699d6074f043681255bc86d18de2cb7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 19 Jan 2025 15:48:48 +0100 Subject: [PATCH] Enhance documentation of generated columns --- .../Schema/ColumnDefinition.swift | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/GRDB/QueryInterface/Schema/ColumnDefinition.swift b/GRDB/QueryInterface/Schema/ColumnDefinition.swift index c398ed11e..18ee6a983 100644 --- a/GRDB/QueryInterface/Schema/ColumnDefinition.swift +++ b/GRDB/QueryInterface/Schema/ColumnDefinition.swift @@ -370,8 +370,8 @@ public final class ColumnDefinition { /// } /// ``` /// - /// When you want to ignore generated columns in record types, instruct - /// GRDB not to select them: + /// To remove the generated columns from the selection of record types, + /// define their `databaseSelection`: /// /// ```swift /// struct Player: Codable { @@ -383,6 +383,9 @@ public final class ColumnDefinition { /// /// extension Player: FetchableRecord, PersistableRecord { /// static var databaseSelection: [any SQLSelectable] { + /// // Option 1 + /// [Column("id"), Column("score"), Column("bonus")] + /// // Option 2 /// [.allColumns(excluding: ["totalScore"])] /// } /// } @@ -432,8 +435,8 @@ public final class ColumnDefinition { /// } /// ``` /// - /// When you want to ignore generated columns in record types, instruct - /// GRDB not to select them: + /// To remove the generated columns from the selection of record types, + /// define their `databaseSelection`: /// /// ```swift /// struct Player: Codable { @@ -445,6 +448,9 @@ public final class ColumnDefinition { /// /// extension Player: FetchableRecord, PersistableRecord { /// static var databaseSelection: [any SQLSelectable] { + /// // Option 1 + /// [Column("id"), Column("score"), Column("bonus")] + /// // Option 2 /// [.allColumns(excluding: ["totalScore"])] /// } /// } @@ -493,8 +499,8 @@ public final class ColumnDefinition { /// } /// ``` /// - /// When you want to ignore generated columns in record types, instruct - /// GRDB not to select them: + /// To remove the generated columns from the selection of record types, + /// define their `databaseSelection`: /// /// ```swift /// struct Player: Codable { @@ -506,6 +512,9 @@ public final class ColumnDefinition { /// /// extension Player: FetchableRecord, PersistableRecord { /// static var databaseSelection: [any SQLSelectable] { + /// // Option 1 + /// [Column("id"), Column("score"), Column("bonus")] + /// // Option 2 /// [.allColumns(excluding: ["totalScore"])] /// } /// } @@ -556,8 +565,8 @@ public final class ColumnDefinition { /// } /// ``` /// - /// When you want to ignore generated columns in record types, instruct - /// GRDB not to select them: + /// To remove the generated columns from the selection of record types, + /// define their `databaseSelection`: /// /// ```swift /// struct Player: Codable { @@ -569,6 +578,9 @@ public final class ColumnDefinition { /// /// extension Player: FetchableRecord, PersistableRecord { /// static var databaseSelection: [any SQLSelectable] { + /// // Option 1 + /// [Column("id"), Column("score"), Column("bonus")] + /// // Option 2 /// [.allColumns(excluding: ["totalScore"])] /// } /// }