function DriverSpecificSchemaTestBase::testInvalidPrimaryKeyColumnsOnAddField
Tests invalid primary key columns on add field.
Attributes
#[IgnoreDeprecations]
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ DriverSpecificSchemaTestBase.php, line 890
Class
- DriverSpecificSchemaTestBase
- Tests table creation and modification via the schema API.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testInvalidPrimaryKeyColumnsOnAddField() : void {
$this->expectUserDeprecationMessage("Specification of primary key with column length is deprecated in drupal:12.1.0 and will throw a SchemaException from drupal:13.0.0. Specify full columns for a primary key, or use an index for columns with partial length. See https://www.drupal.org/node/3375071");
// Test with partial column length.
$this->schema
->createTable('table_with_invalid_pk', [
'description' => 'Table with partial column length primary key.',
'fields' => [
'test_field_1' => [
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
],
],
]);
$this->schema
->addField('table_with_invalid_pk', 'new_test_field', [
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
], [
'primary key' => [
[
'new_test_field',
10,
],
],
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.