Skip to content

Commit 588751b

Browse files
fix: Pass schema context to codec encode for schema-addressed paths
The SchemaCodec (used by NpyCodec and ObjectCodec) needs _schema, _table, _field, and primary key values to construct schema-addressed storage paths. Previously, key=None was passed, resulting in "unknown/unknown" paths. Now builds proper context dict from table metadata and row values, enabling navigable paths like: {schema}/{table}/objects/{pk_path}/{attribute}.npy Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 08d5c6a commit 588751b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/datajoint/table.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,16 +1177,29 @@ def __make_placeholder(self, name, value, ignore_extra_fields=False, row=None):
11771177
# Resolve full type chain
11781178
_, type_chain, resolved_store = resolve_dtype(f"<{attr.codec.name}>", store_name=attr.store)
11791179

1180+
# Build context dict for schema-addressed codecs
1181+
# Include _schema, _table, _field, and primary key values
1182+
context = {
1183+
"_schema": self.database,
1184+
"_table": self.table_name,
1185+
"_field": name,
1186+
}
1187+
# Add primary key values from row if available
1188+
if row is not None:
1189+
for pk_name in self.primary_key:
1190+
if pk_name in row:
1191+
context[pk_name] = row[pk_name]
1192+
11801193
# Apply encoders from outermost to innermost
11811194
for attr_type in type_chain:
11821195
# Pass store_name to encoders that support it (check via introspection)
11831196
import inspect
11841197

11851198
sig = inspect.signature(attr_type.encode)
11861199
if "store_name" in sig.parameters:
1187-
value = attr_type.encode(value, key=None, store_name=resolved_store)
1200+
value = attr_type.encode(value, key=context, store_name=resolved_store)
11881201
else:
1189-
value = attr_type.encode(value, key=None)
1202+
value = attr_type.encode(value, key=context)
11901203

11911204
# Handle NULL values
11921205
if value is None or (attr.numeric and (value == "" or np.isnan(float(value)))):

0 commit comments

Comments
 (0)