Skip to content

Commit ee2240b

Browse files
enhance: Show codec names in table preview instead of =BLOB=
- Raw blobs (no codec) now show "bytes" - Raw json (no codec) shows "json" - Codec fields show "<codec_name>" (e.g., <blob>, <hash>, <object>) - Improves clarity when viewing table contents Example output: *id raw_blob blob_data json_data 1 bytes <blob> json Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 78f4d0c commit ee2240b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/datajoint/preview.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ 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/json field based on its codec."""
29+
attr = heading.attributes.get(field_name)
30+
if attr is None:
31+
return "bytes"
32+
if attr.codec is not None:
33+
return f"<{attr.codec.name}>"
34+
if attr.json:
35+
return "json"
36+
return "bytes"
37+
38+
2739
def preview(query_expression, limit, width):
2840
heading = query_expression.heading
2941
rel = query_expression.proj(*heading.non_blobs)
@@ -55,7 +67,7 @@ def preview(query_expression, limit, width):
5567
def get_placeholder(f):
5668
if f in object_fields:
5769
return "=OBJ[.xxx]="
58-
return "=BLOB="
70+
return _get_blob_placeholder(heading, f)
5971

6072
widths = {
6173
f: min(
@@ -72,7 +84,7 @@ def get_display_value(tup, f, idx):
7284
elif f in object_fields and idx < len(object_data_list):
7385
return _format_object_display(object_data_list[idx].get(f))
7486
else:
75-
return "=BLOB="
87+
return _get_blob_placeholder(heading, f)
7688

7789
return (
7890
" ".join([templates[f] % ("*" + f if f in rel.primary_key else f) for f in columns])
@@ -113,7 +125,7 @@ def get_html_display_value(tup, name, idx):
113125
elif name in object_fields and idx < len(object_data_list):
114126
return _format_object_display(object_data_list[idx].get(name))
115127
else:
116-
return "=BLOB="
128+
return _get_blob_placeholder(heading, name)
117129

118130
css = """
119131
<style type="text/css">

0 commit comments

Comments
 (0)