diff --git a/Tests/Public/Record/PrimaryKeyMultipleTests.swift b/Tests/Public/Record/PrimaryKeyMultipleTests.swift index c09fd6b26..3c7fdf761 100644 --- a/Tests/Public/Record/PrimaryKeyMultipleTests.swift +++ b/Tests/Public/Record/PrimaryKeyMultipleTests.swift @@ -394,6 +394,16 @@ class PrimaryKeyMultipleTests: GRDBTestCase { // MARK: - Exists + func testExistsWithNilPrimaryKeyThatDoesNotMatchAnyRowReturnsFalse() { + assertNoError { + let dbQueue = try makeDatabaseQueue() + dbQueue.inDatabase { db in + let record = Citizenship(personName: nil, countryName: nil, native: true) + XCTAssertFalse(record.exists(db)) + } + } + } + func testExistsWithNotNilPrimaryKeyThatDoesNotMatchAnyRowReturnsFalse() { assertNoError { let dbQueue = try makeDatabaseQueue() diff --git a/Tests/Public/Record/PrimaryKeyRowIDTests.swift b/Tests/Public/Record/PrimaryKeyRowIDTests.swift index 1f5058839..2303b74d7 100644 --- a/Tests/Public/Record/PrimaryKeyRowIDTests.swift +++ b/Tests/Public/Record/PrimaryKeyRowIDTests.swift @@ -537,6 +537,16 @@ class PrimaryKeyRowIDTests: GRDBTestCase { // MARK: - Exists + func testExistsWithNilPrimaryKeyReturnsFalse() { + assertNoError { + let dbQueue = try makeDatabaseQueue() + dbQueue.inDatabase { db in + let record = Person(id: nil, name: "Arthur") + XCTAssertFalse(record.exists(db)) + } + } + } + func testExistsWithNotNilPrimaryKeyThatDoesNotMatchAnyRowReturnsFalse() { assertNoError { let dbQueue = try makeDatabaseQueue() diff --git a/Tests/Public/Record/PrimaryKeySingleTests.swift b/Tests/Public/Record/PrimaryKeySingleTests.swift index 1ee011e9a..a09670fb4 100644 --- a/Tests/Public/Record/PrimaryKeySingleTests.swift +++ b/Tests/Public/Record/PrimaryKeySingleTests.swift @@ -459,6 +459,16 @@ class PrimaryKeySingleTests: GRDBTestCase { // MARK: - Exists + func testExistsWithNilPrimaryKeyThatDoesNotMatchAnyRowReturnsFalse() { + assertNoError { + let dbQueue = try makeDatabaseQueue() + dbQueue.inDatabase { db in + let record = Pet(UUID: nil, name: "Bobby") + XCTAssertFalse(record.exists(db)) + } + } + } + func testExistsWithNotNilPrimaryKeyThatDoesNotMatchAnyRowReturnsFalse() { assertNoError { let dbQueue = try makeDatabaseQueue()