Problem/Motivation
For field item property values that are not set, ContentEntityDatabaseStorage inserts a NULL value for new entitites.
Proposed resolution
Do not save NULL values for new entities.
Specifically, adapt ContentEntityDatabaseStorage::mapToStorageRecord() so that $record does not contain bogus NULL values.
Remaining tasks
User interface changes
API changes
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 2279405-13.patch | 1.14 KB | amateescu |
| #10 | 2279405-10.patch | 3.35 KB | amateescu |
Comments
Comment #1
tstoecklerHere we go.
With this and #2279363: file_managed.uri should not specify a prefixed unique key I can install successfully on PostreSQL again.
Comment #2
tstoecklerAhem.
Comment #3
tstoecklerComment #4
sunIs it possible that the original code used Insert::useDefaults()?
Comment #6
tstoecklerThe original code first collected
$valuesinto a separate array, and then did:So basically the same as here except that I killed the second loop and populate
$recorddirectly.I had orginally dropped that code, because I thought it was unneeded as we now apply the defaults from the field definitions, but that a little bit hasty as it now turns out.
Comment #7
tstoecklerFairly sure this will need to be postponed on #2232477: Fatal when adding new fields with NOT NULL constraints in a base table that contains existing entities :-/. Not doing that yet, though, until we have a green patch there and then can prove that this passes with that patch on top.
Comment #8
amateescu commentedLet's try a combined patch with #2232477-32: Fatal when adding new fields with NOT NULL constraints in a base table that contains existing entities.
Comment #10
amateescu commentedLet's also try with the proper patch from there.
Comment #12
plachComment #13
amateescu commentedRerolled #2 to see if this is still a problem.
Comment #14
amateescu commented@tstoeckler, so your original patch passes but I'm not sure exactly what that means. Are we lacking some test coverage or the problem was fixed in the meantime?
Comment #16
fagoI don't see why saving NULL would be bogus if the value is NULL.
Nope, the default should be controlled by the entity API. If there is a schema default, it really has to match the entity API default. But then this is a non-issue.
Thus, setting to works as designed.