Support sqlite; set sqlite_type to native JSON field

Created on 3 December 2021, almost 3 years ago
Updated 24 June 2023, over 1 year ago

Problem/Motivation

NativeJSONItem field sets 'type' => 'json' in its schema definition. In case you have json_native field and running tests with SQLite database this results in an exception:

Undefined array key "json:normal"

/web/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php:142
/web/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php:97
/web/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php:61
/web/core/lib/Drupal/Core/Database/Schema.php:616
/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php:421

The reason is that json datatype does not exist in SQLite https://www.sqlite.org/datatype3.html.

Steps to reproduce

* Add json_native field to an entity
* Run tests with SQLite database
* Undefined array key "json:normal" message occurs

Proposed resolution

Add 'sqlite_type' => 'text' in NativeJSONItem class.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024