Skip to content

Commit e8b598b

Browse files
enhance: Show codec names in table preview instead of =BLOB=
- Raw blobs (no codec) now show "bytes" - Codec blobs show "<codec_name>" (e.g., <blob>, <json>) - Improves clarity when viewing table contents Before: *id data 1 =BLOB= After: *id raw_data array_data 1 bytes <blob> Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 78f4d0c commit e8b598b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/datajoint/preview.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ def _format_object_display(json_data):
2424
return "=OBJ[file]="
2525

2626

27+
def _get_blob_placeholder(heading, field_name):
28+
"""Get display placeholder for a blob field based on its codec."""
29+
attr = heading.attributes.get(field_name)
30+
if attr is None:
31+
return "=BLOB="
32+
if attr.codec is not None:
33+
return f"<{attr.codec.name}>"
34+
return "bytes"
35+
36+
2737
def preview(query_expression, limit, width):
2838
heading = query_expression.heading
2939
rel = query_expression.proj(*heading.non_blobs)
@@ -55,7 +65,7 @@ def preview(query_expression, limit, width):
5565
def get_placeholder(f):
5666
if f in object_fields:
5767
return "=OBJ[.xxx]="
58-
return "=BLOB="
68+
return _get_blob_placeholder(heading, f)
5969

6070
widths = {
6171
f: min(
@@ -72,7 +82,7 @@ def get_display_value(tup, f, idx):
7282
elif f in object_fields and idx < len(object_data_list):
7383
return _format_object_display(object_data_list[idx].get(f))
7484
else:
75-
return "=BLOB="
85+
return _get_blob_placeholder(heading, f)
7686

7787
return (
7888
" ".join([templates[f] % ("*" + f if f in rel.primary_key else f) for f in columns])
@@ -113,7 +123,7 @@ def get_html_display_value(tup, name, idx):
113123
elif name in object_fields and idx < len(object_data_list):
114124
return _format_object_display(object_data_list[idx].get(name))
115125
else:
116-
return "=BLOB="
126+
return _get_blob_placeholder(heading, name)
117127

118128
css = """
119129
<style type="text/css">

0 commit comments

Comments
 (0)