Skip to content

Commit c3df7b3

Browse files
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.
1 parent db42c26 commit c3df7b3

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/datajoint/heading.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,16 @@ def _init_from_database(self) -> None:
508508
if category == "UUID":
509509
attr["uuid"] = True
510510
elif category in CORE_TYPE_NAMES:
511-
# Core type alias - already resolved in DB
512-
pass
511+
# Core type alias - already resolved in DB.
512+
# MariaDB-specific recovery: MariaDB stores `json` columns
513+
# as `longtext` and reports them back that way through
514+
# information_schema, so the DB-type-based detection above
515+
# leaves attr["json"] False. The :json: comment marker
516+
# survives this aliasing, so we recover the json flag here
517+
# from the original declared type. No-op on MySQL/PostgreSQL
518+
# (attr["json"] is already True from the regex match above).
519+
if category == "JSON":
520+
attr["json"] = True
513521

514522
# Check primary key constraints
515523
if attr["in_key"] and (attr["is_blob"] or attr["json"]):

0 commit comments

Comments
 (0)