Skip to content

Commit 40d7871

Browse files
Fix type pattern conflicts and BLOB reference
- Rename DECIMAL to NUMERIC in native types (decimal is in core types) - Rename TEXT to NATIVE_TEXT (text is in core types) - Change BLOB references to BYTES in heading.py (bytes is the core type name) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 57af0e8 commit 40d7871

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/datajoint/declare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@
7070
**{name.upper(): pattern for name, (pattern, _) in CORE_TYPES.items()},
7171
# Native SQL types (passthrough with warning for non-standard use)
7272
INTEGER=r"((tiny|small|medium|big|)int|integer)(\s*\(.+\))?(\s+unsigned)?(\s+auto_increment)?|serial$",
73-
DECIMAL=r"(decimal|numeric)(\s*\(.+\))?(\s+unsigned)?$",
73+
NUMERIC=r"numeric(\s*\(.+\))?(\s+unsigned)?$", # numeric is SQL alias, use decimal instead
7474
FLOAT=r"(double|float|real)(\s*\(.+\))?(\s+unsigned)?$",
7575
STRING=r"(var)?char\s*\(.+\)$", # Catches char/varchar not matched by core types
7676
TEMPORAL=r"(time|timestamp|year)(\s*\(.+\))?$", # time, timestamp, year (not date/datetime)
7777
NATIVE_BLOB=r"(tiny|small|medium|long)blob$", # Specific blob variants
78-
TEXT=r"(tiny|small|medium|long)?text$", # Text types
78+
NATIVE_TEXT=r"(tiny|small|medium|long)text$", # Text variants (use plain 'text' instead)
7979
# AttributeTypes use angle brackets
8080
ADAPTED=r"<.+>$",
8181
).items()

src/datajoint/heading.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def _init_from_database(self):
283283
autoincrement=bool(re.search(r"auto_increment", attr["Extra"], flags=re.I)),
284284
numeric=any(TYPE_PATTERN[t].match(attr["type"]) for t in ("DECIMAL", "INTEGER", "FLOAT")),
285285
string=any(TYPE_PATTERN[t].match(attr["type"]) for t in ("ENUM", "TEMPORAL", "STRING")),
286-
is_blob=any(TYPE_PATTERN[t].match(attr["type"]) for t in ("BLOB", "NATIVE_BLOB")),
286+
is_blob=any(TYPE_PATTERN[t].match(attr["type"]) for t in ("BYTES", "NATIVE_BLOB")),
287287
uuid=False,
288288
json=bool(TYPE_PATTERN["JSON"].match(attr["type"])),
289289
adapter=None,
@@ -329,8 +329,8 @@ def _init_from_database(self):
329329
attr["type"] = attr["adapter"].dtype
330330
if not any(r.match(attr["type"]) for r in TYPE_PATTERN.values()):
331331
raise DataJointError(f"Invalid dtype '{attr['type']}' in attribute type <{adapter_name}>.")
332-
# Update is_blob based on resolved dtype (check both BLOB and NATIVE_BLOB patterns)
333-
attr["is_blob"] = any(TYPE_PATTERN[t].match(attr["type"]) for t in ("BLOB", "NATIVE_BLOB"))
332+
# Update is_blob based on resolved dtype (check both BYTES and NATIVE_BLOB patterns)
333+
attr["is_blob"] = any(TYPE_PATTERN[t].match(attr["type"]) for t in ("BYTES", "NATIVE_BLOB"))
334334

335335
# Handle core type aliases (uuid, float32, etc.)
336336
if special:

0 commit comments

Comments
 (0)