function SchemaTest::checkGeneratedColumnStorage

Same name in this branch
  1. main core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::checkGeneratedColumnStorage()
  2. main core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest::checkGeneratedColumnStorage()
Same name and namespace in other branches
  1. 11.x core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest::checkGeneratedColumnStorage()
  2. 11.x core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest::checkGeneratedColumnStorage()
  3. 11.x core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest::checkGeneratedColumnStorage()

Checks that the database computes a column with the given storage.

Parameters

\Drupal\Core\Database\SchemaDefinition\GeneratedColumnStorage $storage: The asserted storage.

string $table: The table to test.

string $column: The generated column to test.

Overrides DriverSpecificSchemaTestBase::checkGeneratedColumnStorage

File

core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php, line 36

Class

SchemaTest
Tests schema API for the PostgreSQL driver.

Namespace

Drupal\Tests\pgsql\Kernel\pgsql

Code

public function checkGeneratedColumnStorage(GeneratedColumnStorage $storage, string $table, string $column) : void {
  $generated = $this->connection
    ->query("SELECT [attgenerated] FROM [pg_attribute] WHERE [attrelid] = '{" . $table . "}'::regclass AND [attname] = :column", [
    ':column' => $column,
  ])
    ->fetchField();
  $expected = match ($storage) {  GeneratedColumnStorage::Virtual => 'v',
    GeneratedColumnStorage::Stored => 's',
  
  };
  $this->assertSame($expected, $generated);
}

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