Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
40f239e
table -> accessor: rust
Shubham8287 Feb 11, 2026
3b3b287
exlude test-app
Shubham8287 Feb 11, 2026
055d111
ts: name -> accessor
Shubham8287 Feb 11, 2026
3deab9d
Revert "ts: name -> accessor"
Shubham8287 Feb 11, 2026
f14234d
indexarg to accessor
Shubham8287 Feb 11, 2026
99897ab
llm docs update
Shubham8287 Feb 11, 2026
1cede00
added index name arg
Shubham8287 Feb 11, 2026
5b46a44
fix test
Shubham8287 Feb 11, 2026
9aa1cfb
Merge branch 'master' into shub/table-name-to-accessor
Shubham8287 Feb 11, 2026
076a026
define name -> accessor in views, reducer and table
Shubham8287 Feb 11, 2026
f47c1ff
ui tests
Shubham8287 Feb 11, 2026
4462684
views accessor
Shubham8287 Feb 11, 2026
c2f9ae7
Merge branch 'master' into shub/table-name-to-accessor
Shubham8287 Feb 11, 2026
ee62ea2
insta
Shubham8287 Feb 11, 2026
3f93250
Merge branch 'master' into shub/table-name-to-accessor
Shubham8287 Feb 12, 2026
80e950e
explicit names macro
Shubham8287 Feb 12, 2026
616f22b
index fix
Shubham8287 Feb 12, 2026
b78f3ca
Merge branch 'master' into shub/table-name-to-accessor
Shubham8287 Feb 12, 2026
468698d
fix cargo.toml
Shubham8287 Feb 12, 2026
973a7dd
commentary for index
Shubham8287 Feb 12, 2026
ed568f9
insta tests
Shubham8287 Feb 12, 2026
c899270
fix index arg
Shubham8287 Feb 12, 2026
c533f0f
fix smoketest
Shubham8287 Feb 12, 2026
d1f208a
fix typos
Shubham8287 Feb 12, 2026
3651538
Merge branch 'master' into shub/table-name-to-accessor
Shubham8287 Feb 12, 2026
ae8c325
stupid insta test
Shubham8287 Feb 12, 2026
c6a194d
generate ts module def
Shubham8287 Feb 12, 2026
f287d0f
fix test
Shubham8287 Feb 12, 2026
9a7a9cc
remove from RawIndexDefV10
Shubham8287 Feb 12, 2026
db82a7c
use sourceName as accessorName in ts for now
Shubham8287 Feb 12, 2026
639ea21
fmt
Shubham8287 Feb 12, 2026
0644ebf
insta tests
Shubham8287 Feb 12, 2026
2f9abc9
Merge branch 'master' into shub/table-name-to-accessor
Shubham8287 Feb 13, 2026
4ddf6ac
not modify RawINdeXDefV10
Shubham8287 Feb 13, 2026
2cdc079
Merge branch 'master' into shub/table-name-to-accessor
Shubham8287 Feb 13, 2026
901ee64
veiw name to accessor
Shubham8287 Feb 13, 2026
cd95adc
template bindings
Shubham8287 Feb 13, 2026
a2cd7a2
fix index accessor
Shubham8287 Feb 13, 2026
24fbf54
doc update
Shubham8287 Feb 13, 2026
dbefb0d
csharp autogen
Shubham8287 Feb 13, 2026
3eaca93
autogen chsharp
Shubham8287 Feb 13, 2026
4329313
Updated C# regression tests with new index names
rekhoff Feb 13, 2026
7c51205
Updated Blackholio Unity demo with new index names
rekhoff Feb 13, 2026
55dfedf
Updated C# republishing regression test bindings
rekhoff Feb 13, 2026
29da61e
Merge remote-tracking branch 'origin/master' into shub/table-name-to-…
clockwork-labs-bot Feb 13, 2026
a7ff6f8
Merge origin/master into shub/table-name-to-accessor
Feb 14, 2026
a7dc1e9
case conversion
Shubham8287 Feb 11, 2026
a8308ad
temporary acessor fix
Shubham8287 Feb 15, 2026
158f057
ts index fix and canonical naming
Shubham8287 Feb 15, 2026
c461c11
fix rust table macro
Shubham8287 Feb 15, 2026
15ede7f
explicit names
Shubham8287 Feb 16, 2026
19f1b3e
Merge origin/master into shub/table-name-to-accessor
Feb 16, 2026
e0fb227
lints
Shubham8287 Feb 16, 2026
32e57d9
fix ts bindings
Shubham8287 Feb 16, 2026
136ea81
remove index name in rust
Shubham8287 Feb 16, 2026
0d71487
merge conflict
Shubham8287 Feb 16, 2026
a406b51
Merge branch 'shub/table-name-to-accessor' into shub/case-conversion
Shubham8287 Feb 16, 2026
698f299
remove index canonical name
Shubham8287 Feb 16, 2026
34f4a2b
lint
Shubham8287 Feb 16, 2026
02c685f
more lint
Shubham8287 Feb 16, 2026
f4fd431
Merge branch 'shub/table-name-to-accessor' into shub/case-conversion
Shubham8287 Feb 16, 2026
1d3bc51
Csharp fix and table test
Shubham8287 Feb 16, 2026
a06b720
add alias field in schema && accesor in Defs
Shubham8287 Feb 16, 2026
0ed03a5
lints
Shubham8287 Feb 16, 2026
c6acc13
Resolve both accessor and canonical names in sql
joshua-spacetime Feb 16, 2026
508be98
lints
Shubham8287 Feb 16, 2026
108f0e6
test
Shubham8287 Feb 16, 2026
da75bf5
Merge branch 'master' into shub/case-conversion
Shubham8287 Feb 16, 2026
5eaae22
lint
Shubham8287 Feb 16, 2026
2ab8559
fix typo in module
Shubham8287 Feb 16, 2026
db80249
uncomment tests
Shubham8287 Feb 16, 2026
350738b
smoketest
Shubham8287 Feb 16, 2026
d4af61e
smoketest
Shubham8287 Feb 16, 2026
f2b22a1
Allow passing canonicalname to indexopts
coolreader18 Feb 16, 2026
ec9bbc7
fmt
Shubham8287 Feb 16, 2026
11a1b27
Add system tables to table, column, and index accessor name mappings
joshua-spacetime Feb 16, 2026
5241e07
Merge branch 'shub/alias' into shub/case-conversion
Shubham8287 Feb 16, 2026
e2a0617
index canonical name
Shubham8287 Feb 16, 2026
34b417b
Resolve SQL table names using st_table_accessor
joshua-spacetime Feb 16, 2026
75b8a46
Resolve SQL column names using st_column_accessor
joshua-spacetime Feb 17, 2026
096593e
Insert into accessor system tables
joshua-spacetime Feb 17, 2026
ec752e8
Resolve query builder and view accessor names
joshua-spacetime Feb 17, 2026
c896068
Merge remote-tracking branch 'origin/shub/alias' into shub/case-conve…
Shubham8287 Feb 17, 2026
2956d56
codegen fixes
Shubham8287 Feb 17, 2026
e66dc2c
autoinc
Shubham8287 Feb 17, 2026
04eece7
fix pg wire
Shubham8287 Feb 17, 2026
1a38829
Merge remote-tracking branch 'origin/master' into shub/alias
Shubham8287 Feb 17, 2026
17fe27d
disable smoketests
Shubham8287 Feb 17, 2026
fb2c9a3
index_name_or_alias
Shubham8287 Feb 17, 2026
277bd0d
uncomment assets
Shubham8287 Feb 17, 2026
d6eadc8
lint
Shubham8287 Feb 17, 2026
e82499a
Merge branch 'shub/alias' into shub/case-conversion
Shubham8287 Feb 17, 2026
a135aca
tests
Shubham8287 Feb 17, 2026
7a67134
Merge branch 'master' into shub/case-conversion
Shubham8287 Feb 17, 2026
8ed9f59
test
Shubham8287 Feb 17, 2026
f770195
benchmark module updates
Shubham8287 Feb 17, 2026
9ccfd4d
update ts test
Shubham8287 Feb 17, 2026
24588a6
update sdk test
Shubham8287 Feb 17, 2026
53d77d4
update module-test-ts
Shubham8287 Feb 17, 2026
b675846
schema tests
Shubham8287 Feb 17, 2026
bfbd592
fix integration test
Shubham8287 Feb 17, 2026
7c3b5fe
fix sql test
Shubham8287 Feb 17, 2026
ea4a984
smoketests
Shubham8287 Feb 17, 2026
497d0bc
Use `accessor_name` for generated identifiers in TS/Rust/C#/Unreal co…
cloutiertyler Feb 18, 2026
0b7434f
accessor name in raw index
Shubham8287 Feb 18, 2026
28f0771
fix tests
Shubham8287 Feb 18, 2026
69002ad
Merge branch 'master' into shub/case-conversion
Shubham8287 Feb 18, 2026
80faf30
expose accessor_name
Shubham8287 Feb 18, 2026
056495d
Merge branch 'tyler/use-accessor-name-in-codegen' into shub/case-conv…
Shubham8287 Feb 18, 2026
6625b43
snap
Shubham8287 Feb 18, 2026
3e89965
Fix ModuleDef → RawModuleDefV10 conversion to preserve names
clockwork-labs-bot Feb 18, 2026
c72f6d4
fix test
Shubham8287 Feb 18, 2026
9ff9575
reset module test
Shubham8287 Feb 18, 2026
a0d277a
insta
Shubham8287 Feb 18, 2026
ad42f97
lint
Shubham8287 Feb 18, 2026
489119f
build type generate with accessor
Shubham8287 Feb 18, 2026
762baaa
tests
Shubham8287 Feb 18, 2026
d77e6a1
delete extra file
Shubham8287 Feb 18, 2026
6a6b5a6
fix csharp doc
Shubham8287 Feb 18, 2026
142043b
Fix error
coolreader18 Feb 18, 2026
a018a49
regen csharp bindings
Shubham8287 Feb 18, 2026
780677c
Blackholio
Shubham8287 Feb 19, 2026
5766511
sdks bindings
Shubham8287 Feb 19, 2026
ed2408b
Merge branch 'master' into shub/case-conversion
Shubham8287 Feb 19, 2026
e528393
ts-regen
Shubham8287 Feb 19, 2026
39e960d
fix rust query builder
Shubham8287 Feb 19, 2026
0d426de
Merge branch 'master' into shub/case-conversion
Shubham8287 Feb 19, 2026
ebf50ed
Apply suggestion from @Shubham8287
Shubham8287 Feb 19, 2026
e96952a
fmt
Shubham8287 Feb 19, 2026
89d60dc
pnpm format
Shubham8287 Feb 19, 2026
297d833
merge fixes
Shubham8287 Feb 19, 2026
6c16fef
csharp update
Shubham8287 Feb 19, 2026
2e1d299
regen bindings
Shubham8287 Feb 19, 2026
0b0c6d8
uncomment tests
Shubham8287 Feb 19, 2026
f675259
undo test connect disocnnect
Shubham8287 Feb 19, 2026
4cce697
fix smoketest to green
Shubham8287 Feb 19, 2026
faa1437
increase counter
Shubham8287 Feb 19, 2026
1896274
Re-enable bench tests for case conversion PR (#4352)
clockwork-labs-bot Feb 19, 2026
0a5de36
Blackholio Unity bindings update
rekhoff Feb 19, 2026
13b66c9
C# Regression Test client bindings update
rekhoff Feb 19, 2026
0549340
Fix hardcoded SQL table names in test-client for case conversion
clockwork-labs-bot Feb 19, 2026
4ab4f75
Merge branch 'shub/case-conversion' of https://github.com/clockworkla…
clockwork-labs-bot Feb 19, 2026
6c1a445
Derive SQL table names from generated bindings instead of hardcoding
clockwork-labs-bot Feb 19, 2026
0a84c01
delete duplicate smoketest
Shubham8287 Feb 19, 2026
831d98f
Revert "Derive SQL table names from generated bindings instead of har…
Shubham8287 Feb 19, 2026
9dc5d6c
enable tests
Shubham8287 Feb 19, 2026
0be9546
fix index test
Shubham8287 Feb 19, 2026
4cf14e9
Don't do toCamelCase
coolreader18 Feb 19, 2026
2e6c33e
fix ts lint
joshua-spacetime Feb 19, 2026
671886d
Commented out C++ sdk tests until C++ upgrade to V10
JasonAtClockwork Feb 19, 2026
880bdad
Merge branch 'master' into shub/case-conversion
joshua-spacetime Feb 19, 2026
25d709c
Merge branch 'master' into shub/case-conversion
gefjon Feb 20, 2026
777c330
Fix TS SDK test: use camelCase table accessors directly
clockwork-labs-bot Feb 20, 2026
c3bec13
Use accessor names from definitions instead of recomputing
clockwork-labs-bot Feb 20, 2026
2c0398b
u8 -> u_8
Shubham8287 Feb 20, 2026
3b54660
u8 -> u_8 in csharp module:
Shubham8287 Feb 20, 2026
e616b05
Regenerate procedure-client and view-client bindings
clockwork-labs-bot Feb 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ spacetimedb-testing = { path = "../testing" }

ahash.workspace = true
anyhow.workspace = true
convert_case.workspace = true
anymap.workspace = true
byte-unit.workspace = true
clap.workspace = true
Expand Down
10 changes: 8 additions & 2 deletions crates/bench/src/spacetime_module.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{marker::PhantomData, path::Path};

use convert_case::{Case, Casing};
use spacetimedb::db::{Config, Storage};
use spacetimedb_lib::{
sats::{product, ArrayValue},
Expand Down Expand Up @@ -89,9 +90,14 @@ impl<L: ModuleLanguage> BenchDatabase for SpacetimeModule<L> {
table_style: crate::schemas::IndexStrategy,
) -> ResultBench<Self::TableId> {
// Noop. All tables are built into the "benchmarks" module.
// The module's default CaseConversionPolicy is SnakeCase, which
// inserts underscores at letter-digit boundaries (e.g. u32 -> u_32).
// We must match that here so reducer/table lookups succeed.
let raw = table_name::<T>(table_style);
let converted = raw.as_ref().to_case(Case::Snake);
Ok(TableId {
pascal_case: table_name::<T>(table_style),
snake_case: table_name::<T>(table_style),
pascal_case: TableName::for_test(&converted),
snake_case: TableName::for_test(&converted),
})
}

Expand Down
6 changes: 3 additions & 3 deletions crates/bindings-csharp/Codegen/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ public TableIndex(ColumnRef col, AttributeData data, DiagReporter diag)
public static bool CanParse(AttributeData data) =>
data.AttributeClass?.ToString() == BTreeAttrName;

public string GenerateIndexDef() =>
public string GenerateIndexDef(TableAccessor tableAccessor) =>
$$"""
new(
SourceName: null,
SourceName: "{{StandardIndexName(tableAccessor)}}",
AccessorName: "{{AccessorName}}",
Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.{{Type}}([{{string.Join(
", ",
Expand Down Expand Up @@ -744,7 +744,7 @@ public IEnumerable<GeneratedTableAccessor> GenerateTableAccessors()
GetConstraints(v, ColumnAttrs.Unique)
.Select(c => c.ToIndex())
.Concat(GetIndexes(v))
.Select(b => b.GenerateIndexDef())
.Select(b => b.GenerateIndexDef(v))
)}}}
],
Constraints: {{{GenConstraintList(v, ColumnAttrs.Unique, $"{iTable}.MakeUniqueConstraint")}}},
Expand Down
39 changes: 32 additions & 7 deletions crates/bindings-macro/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,21 @@ struct ScheduledArg {

struct IndexArg {
accessor: Ident,
//TODO: add canonical name
// name: Option<LitStr>,
canonical_name: Option<LitStr>,
is_unique: bool,
kind: IndexType,
}

impl IndexArg {
fn new(accessor: Ident, kind: IndexType) -> Self {
fn new(accessor: Ident, kind: IndexType, canonical_name: Option<LitStr>) -> Self {
// We don't know if its unique yet.
// We'll discover this once we have collected constraints.
let is_unique = false;
Self {
canonical_name,
accessor,
is_unique,
kind,
// name,
}
}
}
Expand Down Expand Up @@ -235,6 +234,7 @@ impl ScheduledArg {
impl IndexArg {
fn parse_meta(meta: ParseNestedMeta) -> syn::Result<Self> {
let mut accessor = None;
let mut canonical_name = None;
let mut algo = None;

meta.parse_nested_meta(|meta| {
Expand All @@ -243,6 +243,11 @@ impl IndexArg {
check_duplicate(&accessor, &meta)?;
accessor = Some(meta.value()?.parse()?);
}
sym::name => {
check_duplicate(&canonical_name, &meta)?;
canonical_name = Some(meta.value()?.parse()?);
}

sym::btree => {
check_duplicate_msg(&algo, &meta, "index algorithm specified twice")?;
algo = Some(Self::parse_btree(meta)?);
Expand Down Expand Up @@ -304,7 +309,7 @@ Did you mean to specify an `accessor` instead? Do so with `accessor = my_index`,
)
})?;

Ok(IndexArg::new(accessor, kind))
Ok(IndexArg::new(accessor, kind, canonical_name))
}

fn parse_columns(meta: &ParseNestedMeta) -> syn::Result<Option<Vec<Ident>>> {
Expand Down Expand Up @@ -390,7 +395,7 @@ Did you mean to specify an `accessor` instead? Do so with `accessor = my_index`,

// Default accessor = field name if not provided
let accessor = field.clone();
Ok(IndexArg::new(accessor, kind))
Ok(IndexArg::new(accessor, kind, None))
}

fn validate<'a>(&'a self, table_name: &str, cols: &'a [Column<'a>]) -> syn::Result<ValidatedIndex<'a>> {
Expand Down Expand Up @@ -434,6 +439,7 @@ Did you mean to specify an `accessor` instead? Do so with `accessor = my_index`,
index_name: gen_index_name(),
accessor_name: &self.accessor,
kind,
canonical_name: self.canonical_name.as_ref().map(|s| s.value()),
})
}
}
Expand Down Expand Up @@ -492,6 +498,7 @@ struct ValidatedIndex<'a> {
accessor_name: &'a Ident,
is_unique: bool,
kind: ValidatedIndexType<'a>,
canonical_name: Option<String>,
}

enum ValidatedIndexType<'a> {
Expand Down Expand Up @@ -539,11 +546,13 @@ impl ValidatedIndex<'_> {
}
};
let source_name = self.index_name.clone();
let accessor_name = self.accessor_name.to_string();
// Note: we do not pass the index_name through here.
// We trust the schema validation logic to reconstruct the name we've stored in `self.name`.
//TODO(shub): pass generated index name instead of accessor name as source_name
quote!(spacetimedb::table::IndexDesc {
source_name: #source_name,
accessor_name: #accessor_name,
algo: #algo,
})
}
Expand Down Expand Up @@ -939,6 +948,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R
//name: None,
is_unique: true,
kind: IndexType::BTree { columns },
canonical_name: None,
})
}

Expand Down Expand Up @@ -1130,7 +1140,8 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R
}
};

let explicit_names_impl = generate_explicit_names_impl(&table_name, &tablehandle_ident, &explicit_table_name);
let explicit_names_impl =
generate_explicit_names_impl(&table_name, &tablehandle_ident, &explicit_table_name, &indices);

let register_describer_symbol = format!("__preinit__20_register_describer_{table_ident}");

Expand Down Expand Up @@ -1323,6 +1334,7 @@ fn generate_explicit_names_impl(
table_name: &str,
tablehandle_ident: &Ident,
explicit_table_name: &Option<String>,
indexes: &[ValidatedIndex],
) -> TokenStream {
let mut explicit_names_body = Vec::new();

Expand All @@ -1336,6 +1348,19 @@ fn generate_explicit_names_impl(
});
};

// Index names
for index in indexes {
if let Some(canonical_name) = &index.canonical_name {
let index_name = &index.index_name;
explicit_names_body.push(quote! {
names.insert_index(
#index_name,
#canonical_name,
);
});
}
}

quote! {

impl spacetimedb::rt::ExplicitNames for #tablehandle_ident {
Expand Down
1 change: 1 addition & 0 deletions crates/bindings-typescript/src/lib/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { ColumnIsUnique } from './constraints';
* existing column names are referenced.
*/
export type IndexOpts<AllowedCol extends string> = {
accessor?: string;
name?: string;
} & (
| { algorithm: 'btree'; columns: readonly AllowedCol[] }
Expand Down
15 changes: 10 additions & 5 deletions crates/bindings-typescript/src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import {
type RowObj,
type VariantsObj,
} from './type_builders';
import type { CamelCase, Values } from './type_util';
import { toCamelCase } from './util';
import type { Values } from './type_util';

export type TableNamesOf<S extends UntypedSchemaDef> = Values<
S['tables']
Expand All @@ -58,7 +57,7 @@ export interface TableToSchema<
AccName extends string,
T extends UntypedTableSchema,
> extends UntypedTableDef {
accessorName: CamelCase<AccName>;
accessorName: AccName;
columns: T['rowType']['row'];
rowType: T['rowSpacetimeType'];
indexes: T['idxs'];
Expand Down Expand Up @@ -91,8 +90,8 @@ export function tableToSchema<

type AllowedCol = keyof T['rowType']['row'] & string;
return {
sourceName: schema.tableName ?? accName,
accessorName: toCamelCase(accName),
sourceName: accName,
accessorName: accName,
columns: schema.rowType.row, // typed as T[i]['rowType']['row'] under TablesToSchema<T>
rowType: schema.rowSpacetimeType,
constraints: tableDef.constraints.map(c => ({
Expand Down Expand Up @@ -188,6 +187,12 @@ export class ModuleContext {
value: module.rowLevelSecurity,
}
);
push(
module.explicitNames && {
tag: 'ExplicitNames',
value: module.explicitNames,
}
);
return { sections };
}

Expand Down
41 changes: 27 additions & 14 deletions crates/bindings-typescript/src/lib/table.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ProcedureExport, ReducerExport, t } from '../server';
import type { errors } from '../server/errors';
import {
ExplicitNameEntry,
RawColumnDefaultValueV10,
RawConstraintDefV10,
RawIndexAlgorithm,
Expand Down Expand Up @@ -132,7 +133,7 @@ export type TableIndexes<TableDef extends UntypedTableDef> = {
? never
: K]: ColumnIndex<K, TableDef['columns'][K]['columnMetadata']>;
} & {
[I in TableDef['indexes'][number] as I['name'] & {}]: TableIndexFromDef<
[I in TableDef['indexes'][number] as I['accessor'] & {}]: TableIndexFromDef<
TableDef,
I
>;
Expand All @@ -146,7 +147,7 @@ type TableIndexFromDef<
keyof TableDef['columns'] & string
>
? {
name: I['name'];
name: I['accessor'];
unique: AllUnique<TableDef, Cols>;
algorithm: Lowercase<I['algorithm']>;
columns: Cols;
Expand Down Expand Up @@ -322,7 +323,7 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(

// gather primary keys, per‑column indexes, uniques, sequences
const pk: ColList = [];
const indexes: RawIndexDefV10[] = [];
const indexes: (RawIndexDefV10 & { canonicalName?: string })[] = [];
const constraints: RawConstraintDefV10[] = [];
const sequences: RawSequenceDefV10[] = [];

Expand Down Expand Up @@ -426,8 +427,9 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(
// the name and accessor name of an index across all SDKs.
indexes.push({
sourceName: undefined,
accessorName: indexOpts.name,
accessorName: indexOpts.accessor,
algorithm,
canonicalName: indexOpts.name,
});
}

Expand All @@ -443,15 +445,6 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(
}
}

for (const index of indexes) {
const cols =
index.algorithm.tag === 'Direct'
? [index.algorithm.value]
: index.algorithm.value;
const colS = cols.map(i => colNameList[i]).join('_');
index.sourceName = `${name}_${colS}_idx_${index.algorithm.tag.toLowerCase()}`;
}

const productType = row.algebraicType.value as RowBuilder<
CoerceRow<Row>
>['algebraicType']['value'];
Expand All @@ -470,8 +463,28 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(
if (row.typeName === undefined) {
row.typeName = toPascalCase(tableName);
}

// Build index source names using accName
for (const index of indexes) {
const cols =
index.algorithm.tag === 'Direct'
? [index.algorithm.value]
: index.algorithm.value;

const colS = cols.map(i => colNameList[i]).join('_');
const sourceName =
(index.sourceName = `${accName}_${colS}_idx_${index.algorithm.tag.toLowerCase()}`);

const { canonicalName } = index;
if (canonicalName !== undefined) {
ctx.moduleDef.explicitNames.entries.push(
ExplicitNameEntry.Index({ sourceName, canonicalName })
);
}
}

return {
sourceName: tableName,
sourceName: accName,
productTypeRef: ctx.registerTypesRecursively(row).ref,
primaryKey: pk,
indexes,
Expand Down
5 changes: 2 additions & 3 deletions crates/bindings-typescript/src/sdk/db_connection_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import type {
} from './reducers.ts';
import type { ClientDbView } from './db_view.ts';
import type { RowType, UntypedTableDef } from '../lib/table.ts';
import { toCamelCase } from '../lib/util.ts';
import type { ProceduresView } from './procedures.ts';
import type { Values } from '../lib/type_util.ts';
import type { TransactionUpdate } from './client_api/types.ts';
Expand Down Expand Up @@ -305,7 +304,7 @@ export class DbConnectionImpl<RemoteModule extends UntypedRemoteModule>

for (const reducer of def.reducers) {
const reducerName = reducer.name;
const key = toCamelCase(reducerName);
const key = reducer.accessorName;

const { serialize: serializeArgs } =
this.#reducerArgsSerializers[reducerName];
Expand All @@ -326,7 +325,7 @@ export class DbConnectionImpl<RemoteModule extends UntypedRemoteModule>

for (const procedure of def.procedures) {
const procedureName = procedure.name;
const key = toCamelCase(procedureName);
const key = procedure.accessorName;

const { serializeArgs, deserializeReturn } =
this.#procedureSerializers[procedureName];
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-typescript/src/sdk/table_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class TableCacheImpl<
keyof TableDefForTableName<RemoteModule, TableName>['columns'] & string
>;
const index = this.#makeReadonlyIndex(this.tableDef, idxDef);
(this as any)[idx.name!] = index;
(this as any)[idxDef.name] = index;
}
}

Expand Down
Loading
Loading