Skip to content

Commit db82a7c

Browse files
committed
use sourceName as accessorName in ts for now
1 parent 9a7a9cc commit db82a7c

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

crates/bindings-typescript/src/lib/schema.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ function tableToSchema<T extends UntypedTableSchema>(
100100
? [idx.algorithm.value]
101101
: idx.algorithm.value;
102102
return {
103-
name: idx.name!,
103+
// use accessor name?
104+
name: idx.sourceName!,
104105
unique: tableDef.constraints.some(c =>
105106
c.data.value.columns.every(col => columnIds.includes(col))
106107
),
@@ -141,10 +142,7 @@ export class ModuleContext {
141142
views: [],
142143
lifeCycleReducers: [],
143144
caseConversionPolicy: { tag: 'SnakeCase' },
144-
explicitNames: {
145-
tables: [],
146-
funcs: [],
147-
},
145+
explicitNames: { entries: [] },
148146
};
149147

150148
get moduleDef(): ModuleDef {

crates/bindings-typescript/src/lib/table.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(
350350
}
351351
indexes.push({
352352
sourceName: undefined, // Unnamed indexes will be assigned a globally unique name
353-
name, // The name of this column will be used as the accessor name
354353
algorithm,
355354
});
356355
}
@@ -420,7 +419,6 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(
420419
// the name and accessor name of an index across all SDKs.
421420
indexes.push({
422421
sourceName: undefined,
423-
name: indexOpts.name,
424422
algorithm,
425423
});
426424
}

crates/bindings-typescript/src/server/runtime.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,11 @@ function makeTableView(
783783
} as RangedIndex<any, any>;
784784
}
785785

786-
if (Object.hasOwn(tableView, indexDef.name!)) {
787-
freeze(Object.assign(tableView[indexDef.name!], index));
786+
//TODO: use accessor name
787+
if (Object.hasOwn(tableView, indexDef.sourceName!)) {
788+
freeze(Object.assign(tableView[indexDef.sourceName!], index));
788789
} else {
789-
tableView[indexDef.name!] = freeze(index) as any;
790+
tableView[indexDef.sourceName!] = freeze(index) as any;
790791
}
791792
}
792793

0 commit comments

Comments
 (0)