diff --git a/crates/bindings-typescript/src/lib/schema.ts b/crates/bindings-typescript/src/lib/schema.ts index be9edc9e113..952402a57c6 100644 --- a/crates/bindings-typescript/src/lib/schema.ts +++ b/crates/bindings-typescript/src/lib/schema.ts @@ -108,14 +108,12 @@ export function tableToSchema< // Build fully-resolved runtime index metadata from the host-facing RawTableDef. // This is intentionally separate from `schema.idxs`, which keeps the original // user-declared `IndexOpts` shape for type-level inference. - const resolvedIndexes: UntypedIndex[] = tableDef.indexes.map( - idx => { - const accessorName = idx.accessorName; - if (typeof accessorName !== 'string' || accessorName.length === 0) { - throw new TypeError( - `Index '${idx.sourceName ?? ''}' on table '${tableDef.sourceName}' is missing accessor name` - ); - } + const resolvedIndexes: UntypedIndex[] = tableDef.indexes + .filter( + idx => typeof idx.accessorName === 'string' && idx.accessorName.length > 0 + ) + .map(idx => { + const accessorName = idx.accessorName!; const columnIds = idx.algorithm.tag === 'Direct' @@ -142,8 +140,7 @@ export function tableToSchema< algorithm, columns: columnIds.map(getColName) as AllowedCol[], }; - } - ); + }); return { // For client,`schama.tableName` will always be there as canonical name. diff --git a/crates/bindings-typescript/src/server/runtime.ts b/crates/bindings-typescript/src/server/runtime.ts index 705a569b20a..67cce1e46c0 100644 --- a/crates/bindings-typescript/src/server/runtime.ts +++ b/crates/bindings-typescript/src/server/runtime.ts @@ -796,13 +796,15 @@ function makeTableView( } as RangedIndex; } - // IMPORTANT: duplicate accessor handling. - // When multiple raw indexes share the same accessor name, we merge index - // methods onto a single accessor object instead of throwing. - if (Object.hasOwn(tableView, accessorName)) { - freeze(Object.assign((tableView as any)[accessorName], index)); - } else { - (tableView as any)[accessorName] = freeze(index); + if (accessorName) { + // IMPORTANT: duplicate accessor handling. + // When multiple raw indexes share the same accessor name, we merge index + // methods onto a single accessor object instead of throwing. + if (Object.hasOwn(tableView, accessorName)) { + freeze(Object.assign((tableView as any)[accessorName], index)); + } else { + (tableView as any)[accessorName] = freeze(index); + } } }