diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 3433de491fa6..4941ba78a739 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -2111,7 +2111,7 @@ protected function _update(string $table, array $values): string /** * This method is used by both update() and getCompiledUpdate() to * validate that data is actually being set and that a table has been - * chosen to be update. + * chosen to be updated. * * @throws DatabaseException */ diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index ed8f9c620856..82ffcf20bf34 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -148,12 +148,13 @@ public function testOnlyDeleted(): void } /** - * If where condition is set, beyond the value was empty (0,'', NULL, etc.), - * Exception should not be thrown because condition was explicity set + * Given an explicit empty value in the WHERE condition + * When executing a soft delete + * Then an exception should not be thrown * * @dataProvider emptyPkValues * - * @param mixed $emptyValue + * @param int|string|null $emptyValue */ public function testDontThrowExceptionWhenSoftDeleteConditionIsSetWithEmptyValue($emptyValue): void { @@ -167,7 +168,7 @@ public function testDontThrowExceptionWhenSoftDeleteConditionIsSetWithEmptyValue /** * @dataProvider emptyPkValues * - * @param mixed $emptyValue + * @param int|string|null $emptyValue */ public function testThrowExceptionWhenSoftDeleteParamIsEmptyValue($emptyValue): void { @@ -175,22 +176,25 @@ public function testThrowExceptionWhenSoftDeleteParamIsEmptyValue($emptyValue): $this->expectExceptionMessage('Deletes are not allowed unless they contain a "where" or "like" clause.'); $this->seeInDatabase('user', ['name' => 'Derek Jones', 'deleted_at IS NULL' => null]); + $this->createModel(UserModel::class)->delete($emptyValue); } /** * @dataProvider emptyPkValues * - * @param mixed $emptyValue + * @param int|string|null $emptyValue */ public function testDontDeleteRowsWhenSoftDeleteParamIsEmpty($emptyValue): void { - $this->expectException(DatabaseException::class); - $this->expectExceptionMessage('Deletes are not allowed unless they contain a "where" or "like" clause.'); - $this->seeInDatabase('user', ['name' => 'Derek Jones', 'deleted_at IS NULL' => null]); - $this->createModel(UserModel::class)->delete($emptyValue); + try { + $this->createModel(UserModel::class)->delete($emptyValue); + } catch (DatabaseException $e) { + // Do nothing. + } + $this->seeInDatabase('user', ['name' => 'Derek Jones', 'deleted_at IS NULL' => null]); }