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
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 commentedI think we should add JSON storage support in #3343634: 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
textfor thesqlite_type! XB does not.re #9 I highly doubt #3343634: 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 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 😮💨
Comment #15
wim leersIncreasing priority as suggested by @catch at
— #3520923: [PP-1] Use `json` schema type for SQLite and remove `text` workaround
Comment #16
catchI'm a bit confused by #12, ban module doesn't use a JSON field type, and it's slated for removal to contrib anyway, is #3379255: [PP-1] Replace ban_schema() implementation with ::ensureTableExists() the right issue link?
Comment #17
larowlanSounds to me like @daffie is happy for this to go in without tests - so we just need a comment explaining why we're doing a stopgap and a link to the bigger issue in a @todo? Anything else?
@catch indicated in #3520923: [PP-1] Use `json` schema type for SQLite and remove `text` workaround this could also go into a bugfix release.
Comment #18
larowlanThis isn't limited to fields, was able to add a simple test to the generic schema test that fails without this change on sqlite (only).
Ready for review
Comment #19
wim leersMR looks trivial! 🥳
Can a core committer please queue the test-only CI job on SQLite to prove @larowlan's ? 🙏
Comment #20
catchsqlite pipeline running at https://git.drupalcode.org/issue/drupal-3487533/-/pipelines/519476
Comment #21
catchThe test only job on https://git.drupalcode.org/issue/drupal-3487533/-/jobs/5524833 isn't showing a failure. This might be an issue with the test-only job though, not sure the last time we needed to run that job on a specific database.
Comment #22
larowlanOutput from running locally shows the expected error from the issue summary in the test
Comment #24
catchWanted to confirm this really does fail on gitlab just in case there's an sqlite version issue or similar, so opened https://git.drupalcode.org/project/drupal/-/merge_requests/12359 with the fix reverted. Tests are still running so hasn't answered the question yet.
Comment #25
catchHere we go, just the test only job is for whatever reason not able to show it:
https://git.drupalcode.org/issue/drupal-3487533/-/jobs/5531634#L970
Late here but now the rc is out I think we should get this in asap, so will try to commit tomorrow if no-one beats me to it.
Comment #26
larowlanThanks @catch
Comment #27
catchThis looks good.
Is the only follow-up here #3343634: Add "json" as core data type to Schema and Database API or do we need an additional small follow-up to add the mapping to the other core drivers? Tagging for follow-up to determine that but it might be existing JSON issues cover it enough.
Committed/pushed to 11.x and cherry-picked to 11.2.x, thanks!
Comment #31
catchComment #32
larowlanThanks @catch, yes that's the only follow up we need as far as I'm aware - removing the tag