You are here

public function UpdateLobTest::testUpdateNullBlob in Drupal 9

Tests that we can update a blob column to null.

File

core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php, line 37

Class

UpdateLobTest
Tests the Update query builder with LOB fields.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testUpdateNullBlob() {
  $id = $this->connection
    ->insert('test_one_blob')
    ->fields([
    'blob1' => 'test',
  ])
    ->execute();
  $r = $this->connection
    ->query('SELECT * FROM {test_one_blob} WHERE [id] = :id', [
    ':id' => $id,
  ])
    ->fetchAssoc();
  $this
    ->assertSame('test', $r['blob1']);
  $this->connection
    ->update('test_one_blob')
    ->fields([
    'blob1' => NULL,
  ])
    ->condition('id', $id)
    ->execute();
  $r = $this->connection
    ->query('SELECT * FROM {test_one_blob} WHERE [id] = :id', [
    ':id' => $id,
  ])
    ->fetchAssoc();
  $this
    ->assertNull($r['blob1']);
}