function Column::generated

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Database/SchemaDefinition/Column.php \Drupal\Core\Database\SchemaDefinition\Column::generated()

Returns a Column object for a generated column.

See also

https://dev.mysql.com/doc/refman/9.7/en/create-table-generated-columns…

https://mariadb.com/docs/server/reference/sql-statements/data-definitio…

https://www.postgresql.org/docs/current/ddl-generated-columns.html

https://sqlite.org/gencol.html

4 calls to Column::generated()
DriverSpecificSchemaTestBase::testCreateTableWithGeneratedColumn in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php
Tests creating a table with a generated column.
SchemaDefinitionConversionTest::testConvertTableDefinition in core/tests/Drupal/Tests/Core/Database/SchemaDefinitionConversionTest.php
Tests Table::toArray().
SchemaDefinitionTest::testInvalidPrimaryKeyForGeneratedColumn in core/tests/Drupal/Tests/Core/Database/SchemaDefinitionTest.php
Tests that a generated column cannot be part of the primary key.
SchemaDefinitionTest::testInvalidSerialForGeneratedExpression in core/tests/Drupal/Tests/Core/Database/SchemaDefinitionTest.php
Tests Serial column.

File

core/lib/Drupal/Core/Database/SchemaDefinition/Column.php, line 486

Class

Column
Describes a database table's column.

Namespace

Drupal\Core\Database\SchemaDefinition

Code

public static function generated(string $name, ColumnType $type, GeneratedColumnExpression $expression, GeneratedColumnStorage $storage, ?string $description = NULL, ?ColumnSize $size = NULL, ?int $length = NULL, ?bool $unsigned = NULL, ?int $precision = NULL, ?int $scale = NULL, ?bool $binary = NULL, ?array $dbSpecificExtra = NULL) : self {
  $column = new self(type: $type, name: $name, description: $description, size: $size, length: $length, unsigned: $unsigned, precision: $precision, scale: $scale, binary: $binary, generatedStorage: $storage, generatedExpression: $expression, dbSpecificExtra: $dbSpecificExtra);
  $column->validate();
  return $column;
}

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