-
-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QueryInterfaceRequest.deleteAndFetchIds
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: "[email protected]").insert(db) | ||
try Person(id: 2, name: "Barbara", email: "[email protected]").insert(db) | ||
try Person(id: 3, name: "Craig", email: "[email protected]").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 { | ||
|