Commit Graph
164 Commits
Author SHA1 Message Date
Gwendal Roué 9ef5e2c8eb Simplify error messages 2025-09-23 17:12:27 +02:00
Gwendal Roué b210ec7428 View Records guide 2025-09-23 17:12:27 +02:00
Gwendal Roué d7d61add23 DatabaseSchemaSource customizes the primary key of database views 2025-09-23 17:12:27 +02:00
Gwendal Roué 30313623eb Make DatabaseSchemaID and DatabaseObjectID public
This is also a big cleanup opportunity.

We need public schema identifiers in order to support the customization of schema introspection.
2025-09-23 17:12:27 +02:00
Gwendal Roué 6a25b3538e DocC for GRDBSendableMetatype 2025-09-10 07:41:42 +02:00
Gwendal Roué d242421862 Async methods accept a non-escaping closure 2025-07-19 16:42:17 +02:00
Gwendal Roué c2e6c86934 Warn against the independent observation of each element in a list. 2025-05-11 13:32:50 +02:00
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é 430141344d Update more documentation with the closure syntax 2025-05-10 09:36:14 +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é f2aa6b386f Improve the documentation for table recreation 2025-03-15 12:06:31 +01:00
Gwendal Roué 71e09a38d4 Document that migrations that rename foreign key columns should use immediate foreign key checks
Fix #1740
2025-03-15 12:06:14 +01:00
Gwendal Roué b48a56ae03 Revert "Merge pull request #1732 from groue/dev/sending-closures"
This reverts commit bbd1eab402, reversing
changes made to 9b09c5342e.
2025-02-23 18:43:45 +01:00
Gwendal Roué 53c9d12d29 Async database access no longer require Sendable closures. 2025-02-23 15:16:36 +01:00
Gwendal Roué aed22fe0bc Support for temporary virtual tables. 2025-02-23 13:45:46 +01: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é 6df8e2bd34 Fix casing of swiftpackageindex.com urls 2025-01-26 15:31:12 +01:00
Gwendal Roué fa0985eb01 Documentation: add @retroactive to Tagged extensions 2025-01-21 08:03:46 +01:00
Gwendal Roué c5366f4a01 AllColumnsExcluding documentation 2025-01-19 16:26:59 +01:00
Gwendal Roué 1e354ba79c Delete the rationale for Sendable records
... because the reality is that I just don't know how to relax this requirement.

See:

- https://www.youtube.com/watch?v=JmrnE7HUaDE
- https://forums.swift.org/t/swiftserverconf-feedback-on-leveraging-structured-concurrency-in-your-applications/75176
2025-01-02 17:07:55 +01:00
Gwendal Roué c97f633022 More documentation of database schema methods 2024-10-13 11:28:14 +02: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é a9fa2871aa Document the requirements 2024-10-06 18:19:11 +02:00
Rob Amos 8c5396898a Add DatabaseValueConvertible tip 2024-10-06 23:18:13 +11:00
Gwendal Roué a6b15684c3 Improve migration notes for ValueObservation 2024-09-29 13:27:07 +02:00
Gwendal Roué bb712a612e Rewrite the "Choosing between Synchronous and Asynchronous Database Accesses" section 2024-09-28 17:45:59 +02:00
Gwendal Roué 20818ee819 Remove the Record class from the documentation 2024-09-28 13:35:11 +02:00
Gwendal Roué 8dbce53ec5 SwiftConcurrency.md 2024-09-27 17:34:32 +02:00
Gwendal Roué 9b6a3b9ec6 SwiftConcurrency.md
ChatGPT remarks:

# Overview Section:

The phrase "GRDB optimally schedules those database access closures, in the best interest of the application" is vague and could benefit from more detail on how the scheduling optimizes for concurrency.

# Concurrency Warnings in Swift 6:

"We will address these issues, and provide general guidance in the following sections." This sentence suggests that detailed solutions will be discussed, but it is unclear how each error is related to the following section titles. A more specific reference to which section will cover what would help orient the reader.

# Non-Sendable Record Types Section:

The FAQ format is useful, but it could overwhelm the reader. Breaking up the FAQ into subsections with more concise answers or reordering it based on common issues could improve readability.

# Shorthand Closure Notation Section:

The explanation of why shorthand notation leads to warnings is somewhat technical. It may be helpful to clarify what "may introduce data races" means in practical terms for less experienced developers.

# Choosing Between Synchronous and Asynchronous Database Access:

The section recommends using asynchronous access but leaves open-ended guidance like "this may slow down other tasks". Adding a more concrete explanation of how to balance performance between synchronous and asynchronous approaches would benefit developers.

# General Clarification on Sendable:

Throughout the document, Sendable is mentioned frequently, but less-experienced developers might not fully understand why it matters. A short section or footnote on what Sendable is and why it’s important in Swift 6 concurrency might help provide context for readers unfamiliar with the concept.
2024-09-26 13:27:13 +02:00
Gwendal Roué cb001cbaa3 SwiftConcurrency.md 2024-09-26 09:43:19 +02:00
Gwendal Roué 521d7847a4 More GRDB 7 migration and Swift concurrency documentation 2024-09-25 20:05:57 +02:00
Gwendal Roué bc98fdb359 SwiftConcurrency.md 2024-09-24 08:58:07 +02:00
Gwendal Roué e7e5956698 SwiftConcurrency.md 2024-09-23 18:42:45 +02:00
Gwendal Roué aa7c528ef3 Swift Concurrency Guide: GlobalActorIsolatedTypesUsability 2024-09-22 13:50:10 +02:00
Gwendal Roué 7f1a3fd813 Swift Concurrency Guide WIP 2024-09-22 13:50:10 +02:00
Gwendal Roué 173f363bdc TableRecord.databaseSelection should be declared as a computed property 2024-09-21 17:21:59 +02:00
Gwendal Roué 900180dafd [BREAKING] Prefer any DatabaseReader and DatabaseWriter 2024-09-21 16:50:03 +02:00
Gwendal Roué 58a2e04736 Mark ValueObservation starting methods as @preconcurrency
I guess the compiler will learn to stop emitting warnings eventually.

https://mjtsai.com/blog/2024/09/20/unwanted-swift-concurrency-checking/
2024-09-21 12:30:38 +02:00
Gwendal Roué bdb7d84086 [BREAKING] ValueObservation MainActor scheduling
Breaking because before iOS 13, macOS 10.15, tvOS 13, there is no longer any default scheduler
2024-09-21 12:30:38 +02:00
Gwendal Roué e1a384009a [BREAKING] Async sequences built from ValueObservation schedule values and errors on the cooperative thread pool by default. 2024-09-21 12:19:39 +02:00
Gwendal Roué 2845570929 Fix DocC warnings 2024-09-15 14:27:19 +02:00
Gwendal Roué 6a29d6c081 [BREAKING] Prefer Collection over Sequence for filter(keys:) and derived APIs
We were frequently turning those sequences into an Array in order to check their emptiness, and generally were not sure we'd iterate a sequence only once.

Also use `some Sequence` and `some Collection` whenever possible.
2024-09-08 12:52:27 +02:00
Gwendal Roué cb1bd83777 Document that async methods can throw CancellationError 2024-09-01 15:35:37 +02:00
Gwendal Roué d6b91eec85 [BREAKING] DatabaseReader async methods support Task cancellation 2024-09-01 15:35:37 +02:00
Gwendal Roué 849bba2820 Refactor ValueReducer for Swift concurrency
The fetching facet of a ValueReducer is Sendable.
2024-08-27 08:31:28 +02:00
Gwendal Roué 1fe4df9438 [BREAKING] databaseDataEncodingStrategy depends on the column 2024-08-25 14:00:53 +02:00
Gwendal Roué 1de32c267b [BREAKING] Remove DatabaseFuture and concurrentRead
That's one less DispatchSemaphore. We don't need this method anymore.
2024-08-25 11:07:05 +02:00
Gwendal Roué 451a9eb493 [BREAKING] Remove Configuration.defaultTransactionKind
GRDB now defaults read-only transactions to DEFERRED, and write transactions to IMMEDIATE. See https://github.com/groue/GRDB.swift/issues/1483 for some context.
2024-08-25 08:22:07 +02:00
Gwendal Roué 29eb04c39a [BREAKING] iOS 12+ 2024-08-24 15:45:38 +02:00