Christian López Espínola Explains JSON Key-Order Issue in Drupal Canvas
Database engines handled JSON key order differently in Drupal Canvas tests, Drupal contributor Christian López Espínola writes in a 4 July 2026 post on the Penyaskito blog. In Canvas Internals - JSON data types in different databases: It works on my machine!, Christian explains how Canvas uses a JSON field for component tree item inputs while Drupal core work to add a JSON data type remains unfinished.
The problem appeared when tests compared stored inputs with assertSame. Christian says the same data could come back with different key ordering depending on the database engine: MySQL and PostgreSQL could change the order, while MariaDB and SQLite preserved it in the cases tested. That difference meant tests could pass in local environments that used SQLite or MariaDB but fail in continuous integration on MySQL and PostgreSQL.
The Canvas team addressed the issue with a custom assertSameInputs helper that sorts keys before comparison, along with a PHPStan rule that flags most uses of assertSame for these inputs. Christian connects the issue to work on symmetric translation support in Drupal Canvas. The Canvas 1.7.0 release notes say translation support is still experimental and should be tested only on non-production sites.


