Commit Graph
16 Commits
Author SHA1 Message Date
Gwendal Roué f878d99733 Use SQLITE_HAS_CODEC instead of GRDBCIPHER when testing for SQLCipher availability
GRDBCIPHER is now just a marker for importing SQLCipher with CocoaPods.

Also, enable all APIs that used to be disabled with SQLCipher, and skip tests that require a specific SQLite version.
2025-10-12 14:49:59 +02:00
Gwendal Roué 3f27fb9289 Fix #1820
The regression was introduced by c7bbebc
2025-09-29 19:35:00 +02:00
Gwendal Roué c7bbebc80f Change the way we count changes in order to support INSTEAD OF triggers
Database.changesCount calls sqlite3_changes(), whose documentation says:

> https://sqlite.org/c3ref/changes.html
> Changes to a view that are intercepted by INSTEAD OF triggers are not counted.

Since we want to support INSTEAD OF triggers well, so that record types can be based on views, we switch to sqlite3_total_changes().
2025-09-23 17:12:27 +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é cd4e853b74 [BREAKING] insertAndFetch, saveAndFetch, and updateAndFetch no longer return optionals.
Those optionals were just an annoyance. Now, nil results are replaced with `RecordError.recordNotFound`. Such an error is only expected with the IGNORE conflict policy.
2024-08-24 17:02:49 +02:00
Gwendal Roué b896923fd4 TODO GRDB7: remove painful optionals due to IGNORE 2023-10-01 15:37:27 +02:00
Gwendal Roué 5ed44b94bc More improvements to RecordTimestamps.md 2023-02-23 07:59:08 +01:00
Gwendal Roué b0d73f3126 EncodableRecord.databaseChanges(modify:) 2023-02-21 22:48:37 +01:00
Gwendal Roué d3c289a320 Availability checks cleanup 2023-01-22 12:37:40 +01:00
Gwendal Roué df3bd46346 Rename PersistenceError to RecordError 2022-11-30 19:11:07 +01:00
Gwendal Roué 3014ddb00a Enhance Documentation 2022-11-09 21:52:22 +01:00
Gwendal Roué 1818534513 DocC 2022-11-06 16:02:36 +01:00
Gwendal Roué 82b4d90a82 Xcode 14 RC doesn't ship with the Swift 5.6 stdlib
https://forums.swift.org/t/xcode-14-rc-cannot-specialize-protocol-type/60171
2022-09-09 08:16:55 +02:00
Gwendal Roué c2e4aaf51d Throw SQLITE_MISUSE in case of programmer error in the aroundXxx callbacks
While writing SingletonRecordTest.swift, I tried the solution below, in order to turn a failed update into an insert:

    func aroundUpdate(_ db: Database, columns: Set<String>, update: () throws -> PersistenceSuccess) throws {
        do {
            _ = try update()
        } catch {
            insert(db)
        }
    }

But this can't work. This `insert(db)` is unable to provide the information we need in `update()`: the result of the eventual RETURNING clause, and the PersistenceSuccess that contains the persisted PersistenceContainer.

So we now detect two misuses: 1) not calling the action method, and 2) not rethrowing the error of the action method.
2022-08-25 19:05:27 +02:00
Gwendal Roué 2789444acd Enable UPSERT and RETURNING with SQLCipher 2022-08-21 21:22:34 +02:00
Gwendal Roué a702fe6bc9 BREAKING: persistence callbacks, and support for RETURNING
- Replace performInsert, performUpdate, etc with callbacks: willInsert, aroundInsert, didInsert, etc.
- Always call didInsert, even with INSERT OR IGNORE
- Explicit conflict resolution in persistence methods
- Add ...AndFetch... methods
2022-08-21 21:22:34 +02:00