Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
bc75ff2e
Unverified
Commit
bc75ff2e
authored
Jul 14, 2020
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#3145076
by johnwebdev, Sam152, alexpott: MapItem base fields cannot be uninstalled
(cherry picked from commit
32bf1e8b
)
parent
f6a64b3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
1 deletion
+70
-1
core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
.../Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
+5
-1
core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php
.../tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php
+65
-0
No files found.
core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
View file @
bc75ff2e
...
...
@@ -2322,7 +2322,11 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor
// A dedicated table only contain rows for actual field values, and no
// rows for entities where the field is empty. Thus, we can safely
// enforce 'not null' on the columns for the field's required properties.
$data_schema
[
'fields'
][
$real_name
][
'not null'
]
=
$properties
[
$column_name
]
->
isRequired
();
// Fields can have dynamic properties, so we need to make sure that the
// property is statically defined.
if
(
isset
(
$properties
[
$column_name
]))
{
$data_schema
[
'fields'
][
$real_name
][
'not null'
]
=
$properties
[
$column_name
]
->
isRequired
();
}
}
// Add indexes.
...
...
core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php
0 → 100644
View file @
bc75ff2e
<?php
namespace
Drupal\KernelTests\Core\Field
;
use
Drupal\Core\Field\BaseFieldDefinition
;
use
Drupal\entity_test_update
\
Entity\EntityTestUpdate
;
use
Drupal\KernelTests\Core\Entity\EntityKernelTestBase
;
/**
* Tests map base fields.
*
* @group Field
*/
class
MapBaseFieldTest
extends
EntityKernelTestBase
{
/**
* The entity definition update manager.
*
* @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface
*/
protected
$entityDefinitionUpdateManager
;
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'entity_test_update'
];
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
entityDefinitionUpdateManager
=
$this
->
container
->
get
(
'entity.definition_update_manager'
);
// Install every entity type's schema that wasn't installed in the parent
// method.
foreach
(
array_diff_key
(
$this
->
entityTypeManager
->
getDefinitions
(),
array_flip
([
'user'
,
'entity_test'
]))
as
$entity_type_id
=>
$entity_type
)
{
$this
->
installEntitySchema
(
$entity_type_id
);
}
}
/**
* Tests uninstalling map item base field.
*/
public
function
testUninstallMapItemBaseField
()
{
$definitions
[
'data_map'
]
=
BaseFieldDefinition
::
create
(
'map'
)
->
setLabel
(
t
(
'Data'
))
->
setRequired
(
TRUE
);
$this
->
state
->
set
(
'entity_test_update.additional_base_field_definitions'
,
$definitions
);
$this
->
entityDefinitionUpdateManager
->
installFieldStorageDefinition
(
'data_map'
,
'entity_test_update'
,
'entity_test'
,
$definitions
[
'data_map'
]);
$entity
=
EntityTestUpdate
::
create
([
'data_map'
=>
[
'key'
=>
'value'
,
],
]);
$entity
->
save
();
$this
->
entityDefinitionUpdateManager
->
uninstallFieldStorageDefinition
(
$definitions
[
'data_map'
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment