From 8511cfd3994e6a64bc2e9dc1b08fdd90209d1cac Mon Sep 17 00:00:00 2001 From: Chris Kolbu Date: Tue, 18 Aug 2026 16:59:53 +1000 Subject: [PATCH] Document INTEGER PRIMARY KEY in WITHOUT ROWID tables --- GRDB/Core/Database+Schema.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/GRDB/Core/Database+Schema.swift b/GRDB/Core/Database+Schema.swift index 1525912c3..68f459a9e 100644 --- a/GRDB/Core/Database+Schema.swift +++ b/GRDB/Core/Database+Schema.swift @@ -1606,7 +1606,19 @@ extension ForeignKeyViolation: CustomStringConvertible { /// pk.columns // ["citizenID", "countryIsoCode"] /// pk.rowIDColumn // nil /// pk.isRowID // false +/// +/// // CREATE TABLE passport ( +/// // id INTEGER PRIMARY KEY, +/// // name TEXT +/// // ) WITHOUT ROWID +/// let pk = try db.primaryKey("passport") +/// pk.columns // ["id"] +/// pk.rowIDColumn // nil +/// pk.isRowID // false /// ``` +/// +/// An `INTEGER PRIMARY KEY` is an alias for the rowid only in rowid +/// tables. In a `WITHOUT ROWID` table, it is a regular primary key. public struct PrimaryKeyInfo: Sendable { private enum Impl { /// The hidden rowID. @@ -1660,7 +1672,9 @@ public struct PrimaryKeyInfo: Sendable { } /// When not nil, the name of the column that contains the - /// `INTEGER PRIMARY KEY`. + /// `INTEGER PRIMARY KEY` of a rowid table. + /// + /// This is nil for `WITHOUT ROWID` tables, which have no rowid. public var rowIDColumn: String? { switch impl { case .hiddenRowID: