From e61550841b46616c5cb029a08ae356105ea3fcb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 10 Aug 2016 08:00:27 +0200 Subject: [PATCH] Failing tests that exists() returns false when primary key is nil --- Tests/Public/Record/PrimaryKeyMultipleTests.swift | 10 ++++++++++ Tests/Public/Record/PrimaryKeyRowIDTests.swift | 10 ++++++++++ Tests/Public/Record/PrimaryKeySingleTests.swift | 10 ++++++++++ 3 files changed, 30 insertions(+) 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()