Feature: #99062 - Native JSON database field support in Doctrine DBAL¶
See forge#99062
Description¶
TYPO3 Core's Database API based on Doctrine DBAL now supports the native
database field type json
, which is already available for all supported DBMS
of TYPO3 v12.
JSON-like objects or arrays are automatically serialized during writing a dataset to the database, when the native JSON type was used in the database schema definition.
Impact¶
By using the native database field declaration json
in e.g. ext_tables.sql
files within an extension, TYPO3 now converts arrays or objects of type
\JsonSerializable
into a serialized JSON value in the database when
persisting such values via Connection->insert()
or
Connection->update()
, if no explicit database types are handed in as additional
method argument.
TYPO3 now utilizes the native type mapping of Doctrine to convert special types, such as JSON database field types automatically for writing.
Example ext_tables.sql
:
CREATE TABLE tx_myextension_domain_model_book (
title varchar(200) DEFAULT '',
contents json
);
Note
However, when reading a record from the database via QueryBuilder, it is still necessary to transfer the serialized value to an array or object, performing a custom serialization for the time being.