From 1831017d64ef14fb083acb986e85133af3d12782 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Wed, 1 May 2024 13:38:14 +0200
Subject: [PATCH 01/16] TODO
Related issue: https://github.com/groue/GRDB.swift/issues/1539
---
TODO.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/TODO.md b/TODO.md
index b8fbe3ff3..096a98127 100644
--- a/TODO.md
+++ b/TODO.md
@@ -17,6 +17,7 @@
## Features
+- [ ] Detect when `ColumnExpression.noOverwrite` excludes a non-existing column. Code is in DOA.upsertStatement()`. We should not silently ignore non-existing columns, as demonstrated by .
- [ ] Can Swift 5.5 help us with `select(.all)` (request of RowDecoder), `select(.id)` (request of RowDecoder.ID), `select(.rowid)` (request of Int64)?
- [ ] Direct access to statement for bindings
- [ ] Property wrapper that decodes dictionaries (but how to tell the key column?)
From 0f2e993790171724722dd3f0b3ddeb04831ce4d0 Mon Sep 17 00:00:00 2001
From: Joe Parker
Date: Fri, 10 May 2024 17:19:01 +0100
Subject: [PATCH 02/16] Update example snippet in CommonTableExpressions.md
---
Documentation/CommonTableExpressions.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/CommonTableExpressions.md b/Documentation/CommonTableExpressions.md
index 16373db74..4f447ad2b 100644
--- a/Documentation/CommonTableExpressions.md
+++ b/Documentation/CommonTableExpressions.md
@@ -251,7 +251,7 @@ let rightCTE = ...
let association = LeftRecord.association(
to: rightCTE,
on: { left, right in
- left[Column("x")] = right[Column("y")]
+ left[Column("x")] == right[Column("y")]
})
```
From f335123c2bd92e3b4786e5b71da74cccaca1291a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Wed, 5 Jun 2024 18:23:56 +0200
Subject: [PATCH 03/16] Update link to SQLite RETURNING caveats
---
.../Request/QueryInterfaceRequest.swift | 32 +++++++++----------
README.md | 2 +-
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
index c573a2f3c..2371ae81d 100644
--- a/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
+++ b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
@@ -528,7 +528,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter selection: The returned columns (must not be empty).
@@ -561,7 +561,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - returns: A ``RecordCursor`` over the deleted records.
@@ -588,7 +588,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - returns: An array of deleted records.
@@ -614,7 +614,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - returns: A set of deleted records.
@@ -640,7 +640,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter selection: The returned columns (must not be empty).
@@ -674,7 +674,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - returns: A ``RecordCursor`` over the deleted records.
@@ -702,7 +702,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - returns: An array of deleted records.
@@ -729,7 +729,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - returns: A set of deleted records.
@@ -844,7 +844,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution.
@@ -893,7 +893,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution.
@@ -930,7 +930,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution.
@@ -962,7 +962,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution.
@@ -996,7 +996,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution.
@@ -1046,7 +1046,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution.
@@ -1084,7 +1084,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution.
@@ -1117,7 +1117,7 @@ extension QueryInterfaceRequest {
///
/// - important: Make sure you check the documentation of the `RETURNING`
/// clause, which describes important limitations and caveats:
- /// .
+ /// .
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution.
diff --git a/README.md b/README.md
index cfef0ead4..7077cd6e7 100644
--- a/README.md
+++ b/README.md
@@ -2343,7 +2343,7 @@ See [Persistence Methods], [Upsert](#upsert), and [`updateChanges` methods](#the
**Batch operations** can return updated or deleted values:
-> **Warning**: Make sure you check the [documentation of the `RETURNING` clause](https://www.sqlite.org/lang_returning.html), which describes important limitations and caveats for batch operations.
+> **Warning**: Make sure you check the [documentation of the `RETURNING` clause](https://www.sqlite.org/lang_returning.html#limitations_and_caveats), which describes important limitations and caveats for batch operations.
```swift
let request = Player.filter(...)...
From b312d4cf5ab64b5a7c35ff376557ac8bc9732306 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Wed, 5 Jun 2024 18:36:24 +0200
Subject: [PATCH 04/16] Add missing DocC links to cast(_:as:)
---
.../Request/Association/AssociationAggregate.swift | 1 +
GRDB/QueryInterface/SQL/SQLExpression.swift | 1 +
2 files changed, 2 insertions(+)
diff --git a/GRDB/QueryInterface/Request/Association/AssociationAggregate.swift b/GRDB/QueryInterface/Request/Association/AssociationAggregate.swift
index 028cfcc42..944d5c0f8 100644
--- a/GRDB/QueryInterface/Request/Association/AssociationAggregate.swift
+++ b/GRDB/QueryInterface/Request/Association/AssociationAggregate.swift
@@ -366,6 +366,7 @@ extension AssociationToMany {
/// ### Top-Level Functions
///
/// - ``abs(_:)-43n8v``
+/// - ``cast(_:as:)-63ttx``
/// - ``length(_:)-9dr2v``
public struct AssociationAggregate {
fileprivate let preparation: AssociationAggregatePreparation
diff --git a/GRDB/QueryInterface/SQL/SQLExpression.swift b/GRDB/QueryInterface/SQL/SQLExpression.swift
index ad772c8df..eb63e59c4 100644
--- a/GRDB/QueryInterface/SQL/SQLExpression.swift
+++ b/GRDB/QueryInterface/SQL/SQLExpression.swift
@@ -2167,6 +2167,7 @@ extension SQLExpressible where Self == Column {
/// - ``average(_:)``
/// - ``average(_:filter:)``
/// - ``capitalized``
+/// - ``cast(_:as:)-1dmu3``
/// - ``count(_:)``
/// - ``count(distinct:)``
/// - ``dateTime(_:_:)``
From bb789e3deece914f5538b59374ec8b2fe03f1951 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Wed, 5 Jun 2024 18:40:42 +0200
Subject: [PATCH 05/16] QueryInterfaceRequest.deleteAndFetchIds
---
CHANGELOG.md | 4 ++
.../Request/QueryInterfaceRequest.swift | 71 +++++++++++++++++++
Tests/GRDBTests/TableRecordDeleteTests.swift | 24 +++++++
3 files changed, 99 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c11a06535..4b24b020c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -125,6 +125,10 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
---
+## Next Release
+
+- **New**: Added `QueryInterfaceRequest.deleteAndFetchIds(_:)` which returns the set of deleted ids.
+
## 6.27.0
Released April 21, 2024
diff --git a/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
index 2371ae81d..1d0d7cdad 100644
--- a/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
+++ b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift
@@ -61,6 +61,7 @@
/// ### Batch Delete
///
/// - ``deleteAll(_:)``
+/// - ``deleteAndFetchIds(_:)``
/// - ``deleteAndFetchCursor(_:)``
/// - ``deleteAndFetchAll(_:)``
/// - ``deleteAndFetchSet(_:)``
@@ -625,6 +626,41 @@ extension QueryInterfaceRequest {
{
try Set(deleteAndFetchCursor(db))
}
+
+ /// Executes a `DELETE RETURNING` statement and returns the set of
+ /// deleted ids.
+ ///
+ /// For example:
+ ///
+ /// ```swift
+ /// // Fetch the ids of deleted players
+ /// // DELETE FROM player RETURNING id
+ /// let request = Player.all()
+ /// let deletedPlayerIds = try request.deleteAndFetchIds(db)
+ /// ```
+ ///
+ /// - important: Make sure you check the documentation of the `RETURNING`
+ /// clause, which describes important limitations and caveats:
+ /// .
+ ///
+ /// - parameter db: A database connection.
+ /// - returns: A set of deleted ids.
+ /// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
+ @available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) // Identifiable
+ public func deleteAndFetchIds(_ db: Database)
+ throws -> Set
+ where RowDecoder: TableRecord & Identifiable,
+ RowDecoder.ID: Hashable & DatabaseValueConvertible & StatementColumnConvertible
+ {
+ let primaryKey = try db.primaryKey(RowDecoder.databaseTableName)
+ GRDBPrecondition(
+ primaryKey.columns.count == 1,
+ "Fetching id requires a single-column primary key in the table \(databaseTableName)")
+
+ let statement = try deleteAndFetchStatement(db, selection: [Column(primaryKey.columns[0])])
+
+ return try RowDecoder.ID.fetchSet(statement)
+ }
#else
/// Returns a `DELETE RETURNING` prepared statement.
///
@@ -741,6 +777,41 @@ extension QueryInterfaceRequest {
{
try Set(deleteAndFetchCursor(db))
}
+
+ /// Executes a `DELETE RETURNING` statement and returns the set of
+ /// deleted ids.
+ ///
+ /// For example:
+ ///
+ /// ```swift
+ /// // Fetch the ids of deleted players
+ /// // DELETE FROM player RETURNING id
+ /// let request = Player.all()
+ /// let deletedPlayerIds = try request.deleteAndFetchIds(db)
+ /// ```
+ ///
+ /// - important: Make sure you check the documentation of the `RETURNING`
+ /// clause, which describes important limitations and caveats:
+ /// .
+ ///
+ /// - parameter db: A database connection.
+ /// - returns: A set of deleted ids.
+ /// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
+ @available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
+ public func deleteAndFetchIds(_ db: Database)
+ throws -> Set
+ where RowDecoder: TableRecord & Identifiable,
+ RowDecoder.ID: Hashable & DatabaseValueConvertible & StatementColumnConvertible
+ {
+ let primaryKey = try db.primaryKey(RowDecoder.databaseTableName)
+ GRDBPrecondition(
+ primaryKey.columns.count == 1,
+ "Fetching id requires a single-column primary key in the table \(databaseTableName)")
+
+ let statement = try deleteAndFetchStatement(db, selection: [Column(primaryKey.columns[0])])
+
+ return try RowDecoder.ID.fetchSet(statement)
+ }
#endif
}
diff --git a/Tests/GRDBTests/TableRecordDeleteTests.swift b/Tests/GRDBTests/TableRecordDeleteTests.swift
index 88e9c8174..e45252a55 100644
--- a/Tests/GRDBTests/TableRecordDeleteTests.swift
+++ b/Tests/GRDBTests/TableRecordDeleteTests.swift
@@ -364,6 +364,30 @@ class TableRecordDeleteTests: GRDBTestCase {
}
}
+ @available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) // Identifiable
+ func testRequestDeleteAndFetchIds() throws {
+#if GRDBCUSTOMSQLITE || GRDBCIPHER
+ guard sqlite3_libversion_number() >= 3035000 else {
+ throw XCTSkip("RETURNING clause is not available")
+ }
+#else
+ guard #available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) else {
+ throw XCTSkip("RETURNING clause is not available")
+ }
+#endif
+
+ let dbQueue = try makeDatabaseQueue()
+ try dbQueue.inDatabase { db in
+ try Person(id: 1, name: "Arthur", email: "arthur@example.com").insert(db)
+ try Person(id: 2, name: "Barbara", email: "barbara@example.com").insert(db)
+ try Person(id: 3, name: "Craig", email: "craig@example.com").insert(db)
+
+ let request = Person.filter(Column("id") != 2)
+ let deletedIds = try request.deleteAndFetchIds(db)
+ XCTAssertEqual(deletedIds, [1, 3])
+ }
+ }
+
func testJoinedRequestDeleteAll() throws {
try makeDatabaseQueue().inDatabase { db in
struct Player: MutablePersistableRecord {
From bbbd6bba90300b6cd2f3663d43fbba1702bdcb77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Wed, 5 Jun 2024 19:38:16 +0200
Subject: [PATCH 06/16] Add `Set` methods `union`, `formUnion`, `intersection`
and `formIntersection` that accept a cursor.
---
CHANGELOG.md | 1 +
GRDB/Core/Cursor.swift | 50 +++++++++++++++++++++++++++++++
Tests/GRDBTests/CursorTests.swift | 26 ++++++++++++++++
3 files changed, 77 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b24b020c..97d107b07 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -128,6 +128,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
## Next Release
- **New**: Added `QueryInterfaceRequest.deleteAndFetchIds(_:)` which returns the set of deleted ids.
+- **New**: Added `Set` methods `union`, `formUnion`, `intersection` and `formIntersection` that accept a cursor.
## 6.27.0
diff --git a/GRDB/Core/Cursor.swift b/GRDB/Core/Cursor.swift
index b8ee02155..af874297c 100644
--- a/GRDB/Core/Cursor.swift
+++ b/GRDB/Core/Cursor.swift
@@ -195,6 +195,56 @@ extension Set {
// database cursors.
try cursor.forEach { insert($0) }
}
+
+ /// Returns a new set with the elements of both this set and the
+ /// given cursor.
+ ///
+ /// If the set already contains one or more elements that are also in
+ /// the cursor, the existing members are kept. If the cursor contains
+ /// multiple instances of equivalent elements, only the first instance
+ /// is kept.
+ ///
+ /// - parameter cursor: A cursor of elements.
+ /// - returns: A new set with the unique elements of this set
+ /// and `cursor`.
+ public func union(_ cursor: some Cursor) throws -> Set {
+ var result = self
+ try result.formUnion(cursor)
+ return result
+ }
+
+ /// Inserts the elements of the given cursor into the set.
+ ///
+ /// If the set already contains one or more elements that are also in
+ /// the cursor, the existing members are kept. If the cursor contains
+ /// multiple instances of equivalent elements, only the first instance
+ /// is kept.
+ ///
+ /// - parameter cursor: A cursor of elements.
+ public mutating func formUnion(_ cursor: some Cursor) throws {
+ while let element = try cursor.next() {
+ insert(element)
+ }
+ }
+
+ /// Returns a new set with the elements that are common to both this set
+ /// and the given cursor.
+ ///
+ /// - parameter cursor: A cursor of elements.
+ /// - returns: A new set.
+ public func intersection(_ cursor: some Cursor) throws -> Set {
+ var result = self
+ try result.formIntersection(cursor)
+ return result
+ }
+
+ /// Removes the elements of the set that aren’t also in the
+ /// given cursor.
+ ///
+ /// - parameter cursor: A cursor of elements.
+ public mutating func formIntersection(_ cursor: some Cursor) throws {
+ try formIntersection(Set(cursor))
+ }
}
extension Sequence {
diff --git a/Tests/GRDBTests/CursorTests.swift b/Tests/GRDBTests/CursorTests.swift
index 29930f223..01c104d8c 100644
--- a/Tests/GRDBTests/CursorTests.swift
+++ b/Tests/GRDBTests/CursorTests.swift
@@ -223,6 +223,32 @@ class CursorTests: GRDBTestCase {
let set = try Set(cursor, minimumCapacity: 100)
XCTAssertEqual(set, [1, 2, 3])
}
+
+ do {
+ let cursor = AnyCursor([1, 2, 1, 3])
+ let set: Set = [1, 4]
+ try XCTAssertEqual(set.union(cursor), [1, 2, 3, 4])
+ }
+
+ do {
+ let cursor = AnyCursor([1, 2, 1, 3])
+ var set: Set = [1, 4]
+ try set.formUnion(cursor)
+ XCTAssertEqual(set, [1, 2, 3, 4])
+ }
+
+ do {
+ let cursor = AnyCursor([1, 2, 1, 3])
+ let set: Set = [1, 3, 4]
+ try XCTAssertEqual(set.intersection(cursor), [1, 3])
+ }
+
+ do {
+ let cursor = AnyCursor([1, 2, 1, 3])
+ var set: Set = [1, 3, 4]
+ try set.formIntersection(cursor)
+ XCTAssertEqual(set, [1, 3])
+ }
}
func testDictionaryGrouping() throws {
From 66894704575ad88030ab26baaeca9fec040c3e76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Thu, 6 Jun 2024 07:50:02 +0200
Subject: [PATCH 07/16] Remove Double infinities from database dump tests
Some SQLite versions store or read +inf and -inf as 9.0e+999 and -9.0e+999, and this makes some tests fail.
Known failure: SQLCipher4, test_quote_value_formatting(), https://github.com/groue/GRDB.swift/actions/runs/9388768610/job/25854709627
I could not reproduce.
---
Tests/GRDBTests/DatabaseDumpTests.swift | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/Tests/GRDBTests/DatabaseDumpTests.swift b/Tests/GRDBTests/DatabaseDumpTests.swift
index c0551a0e8..06d86ccb2 100644
--- a/Tests/GRDBTests/DatabaseDumpTests.swift
+++ b/Tests/GRDBTests/DatabaseDumpTests.swift
@@ -51,10 +51,8 @@ final class DatabaseDumpTests: GRDBTestCase {
blob: utf8 short|您好🙂
blob: uuid|69BF8A9C-D9F0-4777-BD11-93451D84CBCF
double: -1.0|-1.0
- double: -inf|-inf
double: 0.0|0.0
double: 123.45|123.45
- double: inf|inf
double: nan|
integer: -1|-1
integer: 0|0
@@ -250,10 +248,8 @@ final class DatabaseDumpTests: GRDBTestCase {
{"name":"blob: utf8 short","value":"5oKo5aW98J+Zgg=="},
{"name":"blob: uuid","value":"ab+KnNnwR3e9EZNFHYTLzw=="},
{"name":"double: -1.0","value":-1},
- {"name":"double: -inf","value":"-inf"},
{"name":"double: 0.0","value":0},
{"name":"double: 123.45","value":123.45},
- {"name":"double: inf","value":"inf"},
{"name":"double: nan","value":null},
{"name":"integer: -1","value":-1},
{"name":"integer: 0","value":0},
@@ -413,18 +409,12 @@ final class DatabaseDumpTests: GRDBTestCase {
name = double: -1.0
value = -1.0
- name = double: -inf
- value = -inf
-
name = double: 0.0
value = 0.0
name = double: 123.45
value = 123.45
- name = double: inf
- value = inf
-
name = double: nan
value = \n\
@@ -604,10 +594,8 @@ final class DatabaseDumpTests: GRDBTestCase {
blob: utf8 short|您好🙂
blob: uuid|\("i\u{fffd}\u{fffd}\u{fffd}\u{fffd}\u{fffd}Gw\u{fffd}\u{11}\u{fffd}E\u{1d}\u{fffd}\u{fffd}\u{fffd}")
double: -1.0|-1.0
- double: -inf|-inf
double: 0.0|0.0
double: 123.45|123.45
- double: inf|inf
double: nan|
integer: -1|-1
integer: 0|0
@@ -799,10 +787,8 @@ final class DatabaseDumpTests: GRDBTestCase {
'blob: utf8 short',X'E682A8E5A5BDF09F9982'
'blob: uuid',X'69BF8A9CD9F04777BD1193451D84CBCF'
'double: -1.0',-1.0
- 'double: -inf',-Inf
'double: 0.0',0.0
'double: 123.45',123.45
- 'double: inf',Inf
'double: nan',NULL
'integer: -1',-1
'integer: 0',0
@@ -1586,10 +1572,8 @@ final class DatabaseDumpTests: GRDBTestCase {
INSERT INTO value VALUES ('blob: uuid', x'69BF8A9CD9F04777BD1193451D84CBCF');
INSERT INTO value VALUES ('double: -1.0', -1.0);
- INSERT INTO value VALUES ('double: -inf', \(-1.0 / 0));
INSERT INTO value VALUES ('double: 0.0', 0.0);
INSERT INTO value VALUES ('double: 123.45', 123.45);
- INSERT INTO value VALUES ('double: inf', \(1.0 / 0));
INSERT INTO value VALUES ('double: nan', \(0.0 / 0));
INSERT INTO value VALUES ('integer: 0', 0);
From 263a549c21069b57e2d606e0c3bb96b7ac614b48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Sat, 8 Jun 2024 13:47:21 +0200
Subject: [PATCH 08/16] Test that a cancelled ValueObservation does not notify
of changes that were enqueued before cancellation.
This is a test for #1550
---
.../Observers/ValueConcurrentObserver.swift | 2 +
.../Observers/ValueWriteOnlyObserver.swift | 2 +
Tests/GRDBTests/ValueObservationTests.swift | 47 +++++++++++++++++++
3 files changed, 51 insertions(+)
diff --git a/GRDB/ValueObservation/Observers/ValueConcurrentObserver.swift b/GRDB/ValueObservation/Observers/ValueConcurrentObserver.swift
index 78cc9352c..a287a3767 100644
--- a/GRDB/ValueObservation/Observers/ValueConcurrentObserver.swift
+++ b/GRDB/ValueObservation/Observers/ValueConcurrentObserver.swift
@@ -865,6 +865,8 @@ extension ValueConcurrentObserver: DatabaseCancellable {
// Notify cancellation
let (events, dbPool): (ValueObservationEvents?, DatabasePool?) = lock.synchronized {
let events = notificationCallbacks?.events
+ // Set callbacks to nil so that we can't notify anything after
+ // the cancellation.
notificationCallbacks = nil
return (events, databaseAccess?.dbPool)
}
diff --git a/GRDB/ValueObservation/Observers/ValueWriteOnlyObserver.swift b/GRDB/ValueObservation/Observers/ValueWriteOnlyObserver.swift
index ea084cce8..e7dc67bda 100644
--- a/GRDB/ValueObservation/Observers/ValueWriteOnlyObserver.swift
+++ b/GRDB/ValueObservation/Observers/ValueWriteOnlyObserver.swift
@@ -448,6 +448,8 @@ extension ValueWriteOnlyObserver: DatabaseCancellable {
// Notify cancellation
let (events, writer) = lock.synchronized {
let events = notificationCallbacks?.events
+ // Set callbacks to nil so that we can't notify anything after
+ // the cancellation.
notificationCallbacks = nil
return (events, databaseAccess?.writer)
}
diff --git a/Tests/GRDBTests/ValueObservationTests.swift b/Tests/GRDBTests/ValueObservationTests.swift
index f5c1e4908..952264105 100644
--- a/Tests/GRDBTests/ValueObservationTests.swift
+++ b/Tests/GRDBTests/ValueObservationTests.swift
@@ -748,6 +748,53 @@ class ValueObservationTests: GRDBTestCase {
try test(makeDatabasePool())
}
+ func testIssue1550() throws {
+ func test(_ writer: some DatabaseWriter) throws {
+ try writer.write { try $0.execute(sql: "CREATE TABLE t(id INTEGER PRIMARY KEY AUTOINCREMENT)") }
+
+ // Start observing
+ var counts: [Int] = []
+ let cancellable = ValueObservation
+ .trackingConstantRegion { try Table("t").fetchCount($0) }
+ .start(in: writer) { error in
+ XCTFail("Unexpected error: \(error)")
+ } onChange: { count in
+ counts.append(count)
+ }
+
+ // Perform a write after cancellation, but before the
+ // observation could schedule the removal of its transaction
+ // observer from the writer dispatch queue.
+ let semaphore = DispatchSemaphore(value: 0)
+ writer.asyncWriteWithoutTransaction { db in
+ semaphore.wait()
+ do {
+ try db.execute(sql: "INSERT INTO t(id) VALUES (NULL)")
+ } catch {
+ XCTFail("Unexpected error: \(error)")
+ }
+ }
+ cancellable.cancel()
+ semaphore.signal()
+
+ // Wait until a second write could run, after the observation
+ // has removed its transaction observer from the writer
+ // dispatch queue.
+ let secondWriteExpectation = expectation(description: "cancelled")
+ writer.asyncWriteWithoutTransaction { _ in
+ secondWriteExpectation.fulfill()
+ }
+ wait(for: [secondWriteExpectation], timeout: 5)
+
+ // We should not have been notified of the first write, because
+ // it was performed after cancellation.
+ XCTAssertFalse(counts.contains(1))
+ }
+
+ try test(makeDatabaseQueue())
+ try test(makeDatabasePool())
+ }
+
func testIssue1209() throws {
func test(_ dbWriter: some DatabaseWriter) throws {
try dbWriter.write {
From 78545f2c8c14409c647457326812782ab98991c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Sun, 9 Jun 2024 11:19:29 +0200
Subject: [PATCH 09/16] Tests for #1541
---
Tests/GRDBTests/BackupTestCase.swift | 9 +++++++
Tests/GRDBTests/DatabaseMigratorTests.swift | 6 +++++
Tests/GRDBTests/DatabaseReaderTests.swift | 18 ++++++++++++-
.../DatabaseRegionObservationTests.swift | 12 +++++++++
.../SharedValueObservationTests.swift | 16 +++++++++++
Tests/GRDBTests/ValueObservationTests.swift | 27 +++++++++++++++++++
6 files changed, 87 insertions(+), 1 deletion(-)
diff --git a/Tests/GRDBTests/BackupTestCase.swift b/Tests/GRDBTests/BackupTestCase.swift
index 1d969c6cb..33b2f1ac6 100644
--- a/Tests/GRDBTests/BackupTestCase.swift
+++ b/Tests/GRDBTests/BackupTestCase.swift
@@ -139,4 +139,13 @@ class BackupTestCase: GRDBTestCase {
XCTAssertFalse(try db.tableExists("items"))
}
}
+
+ // Test passes if it compiles.
+ // See
+ func testBackupToAnyDatabaseWriter(
+ _ reader: some DatabaseReader,
+ destination: any DatabaseWriter
+ ) throws {
+ try reader.backup(to: destination)
+ }
}
diff --git a/Tests/GRDBTests/DatabaseMigratorTests.swift b/Tests/GRDBTests/DatabaseMigratorTests.swift
index e9a65cba4..9f9815824 100644
--- a/Tests/GRDBTests/DatabaseMigratorTests.swift
+++ b/Tests/GRDBTests/DatabaseMigratorTests.swift
@@ -2,6 +2,12 @@ import XCTest
import GRDB
class DatabaseMigratorTests : GRDBTestCase {
+ // Test passes if it compiles.
+ // See
+ func testMigrateAnyDatabaseWriter(writer: any DatabaseWriter) throws {
+ let migrator = DatabaseMigrator()
+ try migrator.migrate(writer)
+ }
func testEmptyMigratorSync() throws {
func test(writer: some DatabaseWriter) throws {
diff --git a/Tests/GRDBTests/DatabaseReaderTests.swift b/Tests/GRDBTests/DatabaseReaderTests.swift
index df99cf9cc..bf2d51c3f 100644
--- a/Tests/GRDBTests/DatabaseReaderTests.swift
+++ b/Tests/GRDBTests/DatabaseReaderTests.swift
@@ -2,13 +2,29 @@ import XCTest
import GRDB
class DatabaseReaderTests : GRDBTestCase {
-
func testAnyDatabaseReader() throws {
// This test passes if this code compiles.
let dbQueue = try DatabaseQueue()
let _: any DatabaseReader = AnyDatabaseReader(dbQueue)
}
+ // Test passes if it compiles.
+ func testInitFromGeneric(_ reader: some DatabaseReader) {
+ _ = AnyDatabaseReader(reader)
+ }
+
+ // Test passes if it compiles.
+ // See
+ func testInitFromExistentialReader(_ reader: any DatabaseReader) {
+ _ = AnyDatabaseReader(reader)
+ }
+
+ // Test passes if it compiles.
+ // See
+ func testInitFromExistentialWriter(_ writer: any DatabaseWriter) {
+ _ = AnyDatabaseReader(writer)
+ }
+
// MARK: - Read
func testReadCanRead() throws {
diff --git a/Tests/GRDBTests/DatabaseRegionObservationTests.swift b/Tests/GRDBTests/DatabaseRegionObservationTests.swift
index dd4218a00..0625d91c6 100644
--- a/Tests/GRDBTests/DatabaseRegionObservationTests.swift
+++ b/Tests/GRDBTests/DatabaseRegionObservationTests.swift
@@ -2,6 +2,18 @@ import XCTest
import GRDB
class DatabaseRegionObservationTests: GRDBTestCase {
+ // Test passes if it compiles.
+ // See
+ func testAnyDatabaseWriter(writer: any DatabaseWriter) throws {
+ let observation = DatabaseRegionObservation(tracking: .fullDatabase)
+
+ _ = observation.start(in: writer, onError: { _ in }, onChange: { _ in })
+
+ if #available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) {
+ _ = observation.publisher(in: writer)
+ }
+ }
+
func testDatabaseRegionObservation_FullDatabase() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.write {
diff --git a/Tests/GRDBTests/SharedValueObservationTests.swift b/Tests/GRDBTests/SharedValueObservationTests.swift
index ca53c61d9..156960805 100644
--- a/Tests/GRDBTests/SharedValueObservationTests.swift
+++ b/Tests/GRDBTests/SharedValueObservationTests.swift
@@ -2,6 +2,22 @@ import XCTest
import GRDB
class SharedValueObservationTests: GRDBTestCase {
+ // Test passes if it compiles.
+ // See
+ func testInitFromAnyDatabaseReader(reader: any DatabaseReader) {
+ _ = ValueObservation
+ .trackingConstantRegion { _ in }
+ .shared(in: reader)
+ }
+
+ // Test passes if it compiles.
+ // See
+ func testInitFromAnyDatabaseWriter(writer: any DatabaseWriter) {
+ _ = ValueObservation
+ .trackingConstantRegion { _ in }
+ .shared(in: writer)
+ }
+
func test_immediate_observationLifetime() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.write { db in
diff --git a/Tests/GRDBTests/ValueObservationTests.swift b/Tests/GRDBTests/ValueObservationTests.swift
index 952264105..7beeb4d6f 100644
--- a/Tests/GRDBTests/ValueObservationTests.swift
+++ b/Tests/GRDBTests/ValueObservationTests.swift
@@ -3,6 +3,33 @@ import Dispatch
@testable import GRDB
class ValueObservationTests: GRDBTestCase {
+ // Test passes if it compiles.
+ // See
+ func testStartFromAnyDatabaseReader(reader: any DatabaseReader) {
+ _ = ValueObservation
+ .trackingConstantRegion { _ in }
+ .start(in: reader, onError: { _ in }, onChange: { })
+ }
+
+ // Test passes if it compiles.
+ // See
+ func testStartFromAnyDatabaseWriter(writer: any DatabaseWriter) {
+ _ = ValueObservation
+ .trackingConstantRegion { _ in }
+ .start(in: writer, onError: { _ in }, onChange: { })
+ }
+
+ // Test passes if it compiles.
+ // See
+ @available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *)
+ func testValuesFromAnyDatabaseWriter(writer: any DatabaseWriter) {
+ func observe(
+ fetch: @Sendable @escaping (Database) throws -> T
+ ) throws -> AsyncValueObservation {
+ ValueObservation.tracking(fetch).values(in: writer)
+ }
+ }
+
func testImmediateError() throws {
struct TestError: Error { }
From 5999227c010488c91be410ce4a060339f3869cd0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Rou=C3=A9?=
Date: Tue, 9 Jul 2024 13:31:54 +0200
Subject: [PATCH 10/16] Failing test for #1565
---
...tablePersistableRecordEncodableTests.swift | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/Tests/GRDBTests/MutablePersistableRecordEncodableTests.swift b/Tests/GRDBTests/MutablePersistableRecordEncodableTests.swift
index b6aa66fa8..9ccd862e1 100644
--- a/Tests/GRDBTests/MutablePersistableRecordEncodableTests.swift
+++ b/Tests/GRDBTests/MutablePersistableRecordEncodableTests.swift
@@ -83,6 +83,47 @@ extension MutablePersistableRecordEncodableTests {
XCTAssertEqual(string, "foo (MutablePersistableRecord)")
}
}
+
+ // Regression test for
+ func testSingleValueContainer() throws {
+ struct Struct: Encodable {
+ let value: String
+ }
+
+ struct Wrapper: MutablePersistableRecord, Encodable {
+ static var databaseTableName: String { "t1" }
+ var model: Model
+ var otherValue: String
+
+ enum CodingKeys: String, CodingKey {
+ case otherValue
+ }
+
+ func encode(to encoder: any Encoder) throws {
+ var modelContainer = encoder.singleValueContainer()
+ try modelContainer.encode(model)
+
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ try container.encode(otherValue, forKey: .otherValue)
+ }
+ }
+
+ let dbQueue = try makeDatabaseQueue()
+ try dbQueue.inDatabase { db in
+ try db.create(table: "t1") { t in
+ t.column("value", .text)
+ t.column("otherValue", .text)
+ }
+
+ var value = Wrapper(model: Struct(value: "foo"), otherValue: "bar")
+ try assert(value, isEncodedIn: ["value": "foo", "otherValue": "bar"])
+
+ try value.insert(db)
+ let row = try Row.fetchOne(db, sql: "SELECT value, otherValue FROM t1")!
+ XCTAssertEqual(row[0], "foo")
+ XCTAssertEqual(row[1], "bar")
+ }
+ }
}
// MARK: - Different kinds of single-value properties
From ba3c938eb9beb8734fbf6c790c18e01b1664fc11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Rou=C3=A9?=
Date: Tue, 9 Jul 2024 13:32:06 +0200
Subject: [PATCH 11/16] Fix failing test for #1565
---
GRDB/Record/EncodableRecord+Encodable.swift | 83 ++++++++++++++++++---
1 file changed, 71 insertions(+), 12 deletions(-)
diff --git a/GRDB/Record/EncodableRecord+Encodable.swift b/GRDB/Record/EncodableRecord+Encodable.swift
index c7816c672..500a4814d 100644
--- a/GRDB/Record/EncodableRecord+Encodable.swift
+++ b/GRDB/Record/EncodableRecord+Encodable.swift
@@ -34,18 +34,7 @@ private class RecordEncoder: Encoder {
}
func singleValueContainer() -> SingleValueEncodingContainer {
- // @itaiferber on https://forums.swift.org/t/how-to-encode-objects-of-unknown-type/12253/11
- //
- // > Encoding a value into a single-value container is equivalent to
- // > encoding the value directly into the encoder, with the primary
- // > difference being the above: encoding into the encoder writes the
- // > contents of a type into the encoder, while encoding to a
- // > single-value container gives the encoder a chance to intercept the
- // > type as a whole.
- //
- // Wait for somebody hitting this fatal error so that we can write a
- // meaningful regression test.
- fatalError("single value encoding is not supported")
+ self
}
private struct KeyedContainer: KeyedEncodingContainerProtocol {
@@ -169,6 +158,76 @@ private class RecordEncoder: Encoder {
}
}
+extension RecordEncoder: SingleValueEncodingContainer {
+ private func unsupportedSingleValueEncoding() {
+ fatalError("Can't encode a single value in a database row.")
+ }
+
+ func encodeNil() throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: Bool) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: String) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: Double) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: Float) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: Int) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: Int8) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: Int16) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: Int32) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: Int64) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: UInt) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: UInt8) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: UInt16) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: UInt32) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: UInt64) throws {
+ unsupportedSingleValueEncoding()
+ }
+
+ func encode(_ value: T) throws where T : Encodable {
+ try value.encode(to: self)
+ }
+}
+
// MARK: - ColumnEncoder
/// The encoder that encodes into a database column
From e6d4223b14cd1b9efa650923226ae43e12ed110f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Rou=C3=A9?=
Date: Wed, 10 Jul 2024 08:47:49 +0200
Subject: [PATCH 12/16] EncodableRecord takes precedence over Encodable when a
record is encoded with a SingleValueEncodingContainer.
---
GRDB/Record/EncodableRecord+Encodable.swift | 6 ++-
...tablePersistableRecordEncodableTests.swift | 50 +++++++++++++++++++
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/GRDB/Record/EncodableRecord+Encodable.swift b/GRDB/Record/EncodableRecord+Encodable.swift
index 500a4814d..4ecbd5f80 100644
--- a/GRDB/Record/EncodableRecord+Encodable.swift
+++ b/GRDB/Record/EncodableRecord+Encodable.swift
@@ -224,7 +224,11 @@ extension RecordEncoder: SingleValueEncodingContainer {
}
func encode(_ value: T) throws where T : Encodable {
- try value.encode(to: self)
+ if let record = value as? EncodableRecord {
+ try record.encode(to: &_persistenceContainer)
+ } else {
+ try value.encode(to: self)
+ }
}
}
diff --git a/Tests/GRDBTests/MutablePersistableRecordEncodableTests.swift b/Tests/GRDBTests/MutablePersistableRecordEncodableTests.swift
index 9ccd862e1..339a4a497 100644
--- a/Tests/GRDBTests/MutablePersistableRecordEncodableTests.swift
+++ b/Tests/GRDBTests/MutablePersistableRecordEncodableTests.swift
@@ -124,6 +124,56 @@ extension MutablePersistableRecordEncodableTests {
XCTAssertEqual(row[1], "bar")
}
}
+
+ // Regression test for
+ // Here we test that `EncodableRecord` takes precedence over `Encodable`
+ // when a record is encoded with a `SingleValueEncodingContainer`.
+ func testSingleValueContainerWithEncodableRecord() throws {
+ struct Struct: Encodable, EncodableRecord {
+ let value: String
+
+ func encode(to container: inout PersistenceContainer) throws {
+ container["column1"] = "test"
+ container["column2"] = 12
+ }
+ }
+
+ struct Wrapper: MutablePersistableRecord, Encodable {
+ static var databaseTableName: String { "t1" }
+ var model: Model
+ var otherValue: String
+
+ enum CodingKeys: String, CodingKey {
+ case otherValue
+ }
+
+ func encode(to encoder: any Encoder) throws {
+ var modelContainer = encoder.singleValueContainer()
+ try modelContainer.encode(model)
+
+ var container = encoder.container(keyedBy: CodingKeys.self)
+ try container.encode(otherValue, forKey: .otherValue)
+ }
+ }
+
+ let dbQueue = try makeDatabaseQueue()
+ try dbQueue.inDatabase { db in
+ try db.create(table: "t1") { t in
+ t.column("column1", .text)
+ t.column("column2", .integer)
+ t.column("otherValue", .text)
+ }
+
+ var value = Wrapper(model: Struct(value: "foo"), otherValue: "bar")
+ try assert(value, isEncodedIn: ["column1": "test", "column2": 12, "otherValue": "bar"])
+
+ try value.insert(db)
+ let row = try Row.fetchOne(db, sql: "SELECT column1, column2, otherValue FROM t1")!
+ XCTAssertEqual(row[0], "test")
+ XCTAssertEqual(row[1], 12)
+ XCTAssertEqual(row[2], "bar")
+ }
+ }
}
// MARK: - Different kinds of single-value properties
From d2dd757d0cc9376c9730706f99f6d43d46685b49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Thu, 11 Jul 2024 07:44:30 +0200
Subject: [PATCH 13/16] CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97d107b07..818ff5d6f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -127,6 +127,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
## Next Release
+- **New**: [#1570](https://github.com/groue/GRDB.swift/pull/1570) by [@groue](https://github.com/groue): Support single-value encoding
- **New**: Added `QueryInterfaceRequest.deleteAndFetchIds(_:)` which returns the set of deleted ids.
- **New**: Added `Set` methods `union`, `formUnion`, `intersection` and `formIntersection` that accept a cursor.
From 3043d7dca5728967e84da1e819a5bd9e525b454d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Thu, 11 Jul 2024 07:45:53 +0200
Subject: [PATCH 14/16] DatabaseUUIDEncodingStrategy is Sendable
Fix #1567
---
GRDB/Record/EncodableRecord.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/GRDB/Record/EncodableRecord.swift b/GRDB/Record/EncodableRecord.swift
index 30bf4bb48..b1015c751 100644
--- a/GRDB/Record/EncodableRecord.swift
+++ b/GRDB/Record/EncodableRecord.swift
@@ -585,7 +585,7 @@ public enum DatabaseDateEncodingStrategy {
/// var uuid: UUID
/// }
/// ```
-public enum DatabaseUUIDEncodingStrategy {
+public enum DatabaseUUIDEncodingStrategy: Sendable {
/// The strategy that uses formatting from the UUID type.
///
/// It encodes UUIDs as 16-bytes data blobs.
From 7a1196263d9f44ab7c3b77df729e658da5df1dbc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Thu, 11 Jul 2024 07:46:32 +0200
Subject: [PATCH 15/16] CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 818ff5d6f..662e84cf3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -130,6 +130,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
- **New**: [#1570](https://github.com/groue/GRDB.swift/pull/1570) by [@groue](https://github.com/groue): Support single-value encoding
- **New**: Added `QueryInterfaceRequest.deleteAndFetchIds(_:)` which returns the set of deleted ids.
- **New**: Added `Set` methods `union`, `formUnion`, `intersection` and `formIntersection` that accept a cursor.
+- **New**: `DatabaseUUIDEncodingStrategy` is Sendable.
## 6.27.0
From 30de9853d63a617d988e3e8f772dcb06022053fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gwendal=20Roue=CC=81?=
Date: Thu, 11 Jul 2024 07:48:54 +0200
Subject: [PATCH 16/16] v6.28.0
---
CHANGELOG.md | 5 ++++-
GRDB.swift.podspec | 2 +-
README.md | 2 +-
Support/Info.plist | 2 +-
4 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 662e84cf3..9d31c3a7e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
#### 6.x Releases
+- `6.28.x` Releases - [6.28.0](#6280)
- `6.27.x` Releases - [6.27.0](#6270)
- `6.26.x` Releases - [6.26.0](#6260)
- `6.25.x` Releases - [6.25.0](#6250)
@@ -125,7 +126,9 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
---
-## Next Release
+## 6.28.0
+
+Released July 11, 2024
- **New**: [#1570](https://github.com/groue/GRDB.swift/pull/1570) by [@groue](https://github.com/groue): Support single-value encoding
- **New**: Added `QueryInterfaceRequest.deleteAndFetchIds(_:)` which returns the set of deleted ids.
diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec
index 5ae61b42b..9c58025bc 100644
--- a/GRDB.swift.podspec
+++ b/GRDB.swift.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GRDB.swift'
- s.version = '6.27.0'
+ s.version = '6.28.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
diff --git a/README.md b/README.md
index 7077cd6e7..79838cbd2 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@
-**Latest release**: April 21, 2024 • [version 6.27.0](https://github.com/groue/GRDB.swift/tree/v6.27.0) • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 5 to GRDB 6](Documentation/GRDB6MigrationGuide.md)
+**Latest release**: July 11, 2024 • [version 6.28.0](https://github.com/groue/GRDB.swift/tree/v6.28.0) • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 5 to GRDB 6](Documentation/GRDB6MigrationGuide.md)
**Requirements**: iOS 11.0+ / macOS 10.13+ / tvOS 11.0+ / watchOS 4.0+ • SQLite 3.19.3+ • Swift 5.7+ / Xcode 14+
diff --git a/Support/Info.plist b/Support/Info.plist
index 43d72a701..a9a6ba2d3 100644
--- a/Support/Info.plist
+++ b/Support/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 6.27.0
+ 6.28.0
CFBundleSignature
????
CFBundleVersion