From c3df7b34d6e648ab0c29c4873a724fdda2de9fb5 Mon Sep 17 00:00:00 2001 From: Dimitri Yatsenko Date: Wed, 29 Apr 2026 18:19:20 -0500 Subject: [PATCH] fix(#1438): preserve json flag for MariaDB longtext-aliased columns MariaDB stores `json` columns as `longtext` and reports them back through information_schema as `longtext`, so the DB-type-based detection in _init_from_database() leaves attr["json"] False. The :json: comment marker written at declare-time survives the aliasing, so recover the json flag from the original declared type alongside the existing UUID recovery. No-op on MySQL/PostgreSQL where the regex match against the DB-reported type already sets attr["json"] = True. --- src/datajoint/heading.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/datajoint/heading.py b/src/datajoint/heading.py index abcffc3f1..8bd91ad3e 100644 --- a/src/datajoint/heading.py +++ b/src/datajoint/heading.py @@ -508,8 +508,16 @@ def _init_from_database(self) -> None: if category == "UUID": attr["uuid"] = True elif category in CORE_TYPE_NAMES: - # Core type alias - already resolved in DB - pass + # Core type alias - already resolved in DB. + # MariaDB-specific recovery: MariaDB stores `json` columns + # as `longtext` and reports them back that way through + # information_schema, so the DB-type-based detection above + # leaves attr["json"] False. The :json: comment marker + # survives this aliasing, so we recover the json flag here + # from the original declared type. No-op on MySQL/PostgreSQL + # (attr["json"] is already True from the regex match above). + if category == "JSON": + attr["json"] = True # Check primary key constraints if attr["in_key"] and (attr["is_blob"] or attr["json"]):