Problem/Motivation
Discovered in #3487077: Page has Metatag integration.
When trying to uninstall Experience Builder, it crashes with "Unable to parse the column type JSON".
That's because \Drupal\sqlite\Driver\Database\sqlite\Schema::getFieldTypeMap
does not contain a mapping for JSON fields. No other driver errors for this. That's because \Drupal\sqlite\Driver\Database\sqlite\Schema::introspectSchema
is SQLite specific.
So when deleting the field it crashes.
Steps to reproduce
Install XB or any field using json
type. Try to uninstall or delete field. It crashes
'pgsql_type' => 'jsonb',
'mysql_type' => 'json',
'sqlite_type' => 'json',
'not null' => FALSE,
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3487533
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3487533-sqlite-json-fieldmap changes, plain diff MR !10188
- 3487533-cannot-delete-a compare
Comments
Comment #2
mglamanugh picked the wrong branch
Comment #5
mglamanComment #6
dmitry.korhovLooks straightforward, so there are no issues with merging this.
Comment #7
longwaveFor consistency should we add this to
getFieldTypeMap()
for the other drivers anyway?Comment #8
wim leersSo this bit in the Experience Builder module revealed this bug:
—
\Drupal\experience_builder\Plugin\Field\FieldType\ComponentTreeItem::schema()
But I made this use exactly the same pattern that Metatag uses, hence this bit:
—
\Drupal\experience_builder\Plugin\Field\FieldType\ComponentTreeItem
.So why is the Metatag module not running into the same problem? 🤔
Comment #9
daffie CreditAttribution: daffie at Finalist commentedI think we should add JSON storage support in #3343634: [PP-1] Add "json" as core data type to Schema and Database API. If that takes too long, we should at least at testing for the change and a comment about why the change is done.
Comment #10
longwaveNW for #9. I think this is OK as a stopgap if we can get test coverage (and also answer #7). I would definitely like to see JSON support done properly in core but I'm also concerned about how long it will take given the tight timelines we have on Experience Builder.
Comment #11
mglaman@wim leers metatag uses text for all? https://git.drupalcode.org/project/metatag/-/blob/2.0.x/src/Plugin/Field.... I think I know what you're talking about, though. Is it the json_field? https://git.drupalcode.org/project/json_field/-/blob/8.x-1.x/src/Plugin/...
Note they use
text
for thesqlite_type
! XB does not.re #9 I highly doubt #3343634: [PP-1] Add "json" as core data type to Schema and Database API is going to make enough progress anytime soon.
I'll see if I can make a quick enough test.Hopefully without a field type and just manipulating a table with a JSON column.I don't have capacity to write the test.
Comment #12
daffie CreditAttribution: daffie at Finalist commentedLets skip the test. We can do that in #3379255: [PP-1] Replace ban_schema() implementation with ::ensureTableExists().
Comment #13
mglamanOkay, so what's left? Add this line to each driver? I don't know what value the in-code comment would provide. Or would the comment be for why we only added it to SQLite and not the others?
Something like this?
Comment #14
wim leers#11: oh, damn, mea culpa! 😬 I failed to document that correctly then 😮💨