function UpdateLobTest::testUpdateNullBlob

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php \Drupal\KernelTests\Core\Database\UpdateLobTest::testUpdateNullBlob()
  2. 11.x core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php \Drupal\KernelTests\Core\Database\UpdateLobTest::testUpdateNullBlob()

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']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.