Revert "Issue #2232477 by tstoeckler, a 'fliptable' mateescu, plach: Fixed Fatal when adding new fields with NOT NULL constraints in a base table that contains existing entities."
This reverts commit 08d3ebba69
.
8.0.x
parent
488116d759
commit
1397bd65bc
|
@ -1415,19 +1415,10 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
|
||||||
// table. For this reason the revision ID field cannot be marked as NOT
|
// table. For this reason the revision ID field cannot be marked as NOT
|
||||||
// NULL.
|
// NULL.
|
||||||
unset($keys['label'], $keys['revision']);
|
unset($keys['label'], $keys['revision']);
|
||||||
|
|
||||||
// Key fields may not be NULL.
|
// Key fields may not be NULL.
|
||||||
if (in_array($field_name, $keys)) {
|
if (in_array($field_name, $keys)) {
|
||||||
$schema['fields'][$schema_field_name]['not null'] = TRUE;
|
$schema['fields'][$schema_field_name]['not null'] = TRUE;
|
||||||
}
|
}
|
||||||
// All the other columns have to be able to be NULL regardless of the
|
|
||||||
// actual field storage schema in order to support adding a base field
|
|
||||||
// definition to an entity type with non-empty base table(s).
|
|
||||||
// @todo Revisit the strict 'not null' => FALSE requirement for all
|
|
||||||
// non-key columns in https://www.drupal.org/node/2346019.
|
|
||||||
elseif (isset($schema['fields'][$schema_field_name]['not null'])) {
|
|
||||||
$schema['fields'][$schema_field_name]['not null'] = FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($field_schema['indexes'])) {
|
if (!empty($field_schema['indexes'])) {
|
||||||
|
|
|
@ -220,7 +220,6 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
|
||||||
'columns' => array(
|
'columns' => array(
|
||||||
'target_id' => array(
|
'target_id' => array(
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
'not null' => TRUE,
|
|
||||||
),
|
),
|
||||||
'target_revision_id' => array(
|
'target_revision_id' => array(
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
|
@ -316,7 +315,6 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase {
|
||||||
'editor_revision__target_id' => array(
|
'editor_revision__target_id' => array(
|
||||||
'description' => 'The editor_revision field.',
|
'description' => 'The editor_revision field.',
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
'not null' => FALSE,
|
|
||||||
),
|
),
|
||||||
'editor_revision__target_revision_id' => array(
|
'editor_revision__target_revision_id' => array(
|
||||||
'description' => 'The editor_revision field.',
|
'description' => 'The editor_revision field.',
|
||||||
|
|
Loading…
Reference in New Issue