Commit Graph
157 Commits
Author SHA1 Message Date
Gwendal Roué 5d9e853f24 Fix typos in code samples 2026-11-01 20:45:05 +01:00
Gwendal Roué 7a216d7d34 Fix typos in public documentation 2026-11-01 20:45:05 +01:00
Gwendal Roué 7b01c9b72b Let the user choose between the two possible update strategies for upsert 2026-02-15 13:40:05 +01:00
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é 79ce0ff5f3 Avoid a compiler warning 2025-09-10 07:12:53 +02:00
Gwendal Roué d1a2cb0948 All closures that accept DatabaseComponents can throw 2025-05-12 20:33:18 +02:00
Gwendal Roué 034b241e71 Rename ColumnsProvider to DatabaseComponents 2025-05-11 13:10:19 +02:00
Gwendal Roué 814146c40d DocC 2025-05-11 11:56:21 +02:00
Gwendal Roué fedcdef65e Fix typo 2025-05-11 11:21:48 +02:00
Gwendal Roué 98e2812089 Convenience api for updating a single column 2025-05-11 10:58:09 +02:00
Gwendal Roué 004968517e Update more documentation with the closure syntax 2025-05-10 17:43:22 +02:00
Gwendal Roué d6ff3b14d4 DocC 2025-05-10 15:34:10 +02:00
Gwendal Roué 6cc3116ff4 TableAlias is generic 2025-05-10 14:52:48 +02:00
Gwendal Roué 430141344d Update more documentation with the closure syntax 2025-05-10 09:36:14 +02:00
Gwendal Roué 190ccda727 Rename deleteAndFetchStatement(_:select:) for consistency 2025-05-10 09:36:14 +02:00
Gwendal Roué ed402d5de6 Use closure syntax for batch updates 2025-05-10 09:36:14 +02:00
Gwendal Roué ed98ac30e0 DocC 2025-05-10 09:36:14 +02:00
Gwendal Roué 35fa28ab90 QueryInterfaceRequest.select(_:as:) with ColumnsProvider 2025-05-10 09:36:14 +02:00
Gwendal Roué b01f6da3cf Remove TODO 2025-05-10 09:36:14 +02:00
Gwendal Roué e7fdd65072 deleteAndFetchStatement(_,selection:) with ColumnsProvider 2025-05-10 09:36:14 +02:00
Gwendal Roué ce238b6643 Build requests from ColumnsProvider 2025-05-10 09:36:13 +02:00
Gwendal Roué 494e697e94 Warn against selectID() when the ID type is an optional. 2025-02-12 08:25:27 +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é 46e15616a7 [BREAKING] macOS 10.15+ 2024-09-21 14:28:24 +02:00
Gwendal Roué e4a4735494 [BREAKING] tvOS 13+ 2024-09-21 13:57:35 +02:00
Gwendal Roué 8c40592955 [BREAKING] iOS 13+ 2024-09-21 13:57:23 +02:00
Gwendal Roué 1036371dff DatabasePromise is Sendable 2024-08-25 18:06:29 +02:00
Gwendal Roué 79cb862478 [BREAKING] watchOS 7+
Rationale: https://github.com/groue/GRDB.swift/issues/1472#issuecomment-1960696836
2024-08-24 15:45:38 +02:00
Gwendal Roué bb789e3dee QueryInterfaceRequest.deleteAndFetchIds 2024-06-05 18:42:36 +02:00
Gwendal Roué f335123c2b Update link to SQLite RETURNING caveats 2024-06-05 18:23:56 +02:00
Gwendal Roué 7a7ee554c7 OrderedRequest.withStableOrder() 2023-10-12 09:17:50 +02:00
Gwendal Roué f4ac0ab119 Make it possible to observe the supplementary fetches 2023-10-08 20:41:05 +02:00
Gwendal Roué 4a5d4d6e49 Fix Xcode 15 warnings 2023-06-06 08:06:06 +02:00
Gwendal Roué 82d28b3167 Bitwise assignment operators &= |= <<= >>= 2023-05-23 08:16:14 +02:00
Gwendal Roué 29b5b99b89 Fix typos 2023-03-11 08:00:23 +01:00
Gwendal Roué d3c289a320 Availability checks cleanup 2023-01-22 12:37:40 +01:00
Gwendal Roué 2976e81a95 Fix failing test for #1315 2023-01-15 13:39:05 +01:00
Gwendal Roué 13c804d1cc DocC 2022-11-06 16:02:36 +01:00
Gwendal Roué 1818534513 DocC 2022-11-06 16:02:36 +01:00
Gwendal Roué b0f7493765 BREAKING: rename request methods that build a DatabasePromise
This creates an opportunity for future `request.filter { ... }` apis that look like standard ones. Why not `Player.filter { $0.score > 1000 }` eventually, perhaps with code generation?
2022-09-06 22:56:40 +02:00
Gwendal Roué c6657b7063 ColumnAssignment that does nothing
A cool upsert feature is to overwrite an existing value in case of conflict, but another cool upsert feature is to NOT overwrite an existing value. This commit makes it possible to create a ColumnAssignement that does nothing.
2022-08-23 20:02:17 +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
Gwendal Roué b2eafd4a13 SE-0361: Extensions on bound generic types
https://github.com/apple/swift-evolution/blob/main/proposals/0361-bound-generic-extensions.md
2022-08-21 21:22:34 +02:00
Gwendal Roué 36892fee55 BREAKING: Bump minimum SQLite version to 3.19.3 2022-08-21 21:22:34 +02:00
Gwendal Roué 80ec31f588 BREAKING: remove DerivableRequest.limit(_:offset:) 2022-08-21 21:22:34 +02:00
Gwendal Roué 11a6d53d8a SE-0326: closure result type inference
https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md
2022-08-21 21:22:34 +02:00
Gwendal Roué 7ffc332327 BREAKING: replace selectID() with selectPrimaryKey(as:)
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??.

Instead, we introduce selectPrimaryKey(as:), which allows the user to provide the desired type.

    Player.selectPrimaryKey(as: Int64.self) // QueryInterface<Int64>
2022-08-21 21:22:34 +02:00