Skip to content

Commit bdf94f1

Browse files
authored
Fix table codegen wrt table names (#1689)
1 parent c8279e1 commit bdf94f1

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

crates/cli/src/subcommands/generate/rust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ fn print_handle_table_update_defn(ctx: &GenCtx, out: &mut Indenter, items: &[Gen
860860
writeln!(
861861
out,
862862
"{:?} => client_cache.{}::<{}::{}>(callbacks, table_update),",
863-
type_name(ctx, table_desc.data),
863+
table.table_name,
864864
if find_primary_key_column_index(&table).is_some() {
865865
"handle_table_update_with_primary_key"
866866
} else {
@@ -916,7 +916,7 @@ fn print_handle_resubscribe_defn(ctx: &GenCtx, out: &mut Indenter, items: &[GenI
916916
writeln!(
917917
out,
918918
"{:?} => client_cache.handle_resubscribe_for_type::<{}::{}>(callbacks, new_subs),",
919-
type_name(ctx, table.data),
919+
table.schema.table_name,
920920
type_name(ctx, table.data).to_case(Case::Snake),
921921
type_name(ctx, table.data).to_case(Case::Pascal),
922922
);

crates/cli/tests/snapshots/codegen__codegen_rust.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,14 @@ impl SpacetimeModule for Module {
393393
fn handle_table_update(&self, table_update: TableUpdate, client_cache: &mut ClientCache, callbacks: &mut RowCallbackReminders) {
394394
let table_name = &table_update.table_name[..];
395395
match table_name {
396-
"HasSpecialStuff" => client_cache.handle_table_update_no_primary_key::<has_special_stuff::HasSpecialStuff>(callbacks, table_update),
397-
"PkMultiIdentity" => client_cache.handle_table_update_with_primary_key::<pk_multi_identity::PkMultiIdentity>(callbacks, table_update),
398-
"Point" => client_cache.handle_table_update_no_primary_key::<point::Point>(callbacks, table_update),
399-
"Private" => client_cache.handle_table_update_no_primary_key::<private::Private>(callbacks, table_update),
400-
"RepeatingTestArg" => client_cache.handle_table_update_with_primary_key::<repeating_test_arg::RepeatingTestArg>(callbacks, table_update),
401-
"TestA" => client_cache.handle_table_update_no_primary_key::<test_a::TestA>(callbacks, table_update),
402-
"TestD" => client_cache.handle_table_update_no_primary_key::<test_d::TestD>(callbacks, table_update),
403-
"TestE" => client_cache.handle_table_update_with_primary_key::<test_e::TestE>(callbacks, table_update),
396+
"has_special_stuff" => client_cache.handle_table_update_no_primary_key::<has_special_stuff::HasSpecialStuff>(callbacks, table_update),
397+
"pk_multi_identity" => client_cache.handle_table_update_with_primary_key::<pk_multi_identity::PkMultiIdentity>(callbacks, table_update),
398+
"points" => client_cache.handle_table_update_no_primary_key::<point::Point>(callbacks, table_update),
399+
"private" => client_cache.handle_table_update_no_primary_key::<private::Private>(callbacks, table_update),
400+
"repeating_test_args" => client_cache.handle_table_update_with_primary_key::<repeating_test_arg::RepeatingTestArg>(callbacks, table_update),
401+
"test_a" => client_cache.handle_table_update_no_primary_key::<test_a::TestA>(callbacks, table_update),
402+
"test_d" => client_cache.handle_table_update_no_primary_key::<test_d::TestD>(callbacks, table_update),
403+
"test_e" => client_cache.handle_table_update_with_primary_key::<test_e::TestE>(callbacks, table_update),
404404
_ => spacetimedb_sdk::log::error!("TableRowOperation on unknown table {:?}", table_name),
405405
}
406406
}
@@ -431,14 +431,14 @@ match &reducer_call.reducer_name[..] {
431431
fn handle_resubscribe(&self, new_subs: TableUpdate, client_cache: &mut ClientCache, callbacks: &mut RowCallbackReminders) {
432432
let table_name = &new_subs.table_name[..];
433433
match table_name {
434-
"HasSpecialStuff" => client_cache.handle_resubscribe_for_type::<has_special_stuff::HasSpecialStuff>(callbacks, new_subs),
435-
"PkMultiIdentity" => client_cache.handle_resubscribe_for_type::<pk_multi_identity::PkMultiIdentity>(callbacks, new_subs),
436-
"Point" => client_cache.handle_resubscribe_for_type::<point::Point>(callbacks, new_subs),
437-
"Private" => client_cache.handle_resubscribe_for_type::<private::Private>(callbacks, new_subs),
438-
"RepeatingTestArg" => client_cache.handle_resubscribe_for_type::<repeating_test_arg::RepeatingTestArg>(callbacks, new_subs),
439-
"TestA" => client_cache.handle_resubscribe_for_type::<test_a::TestA>(callbacks, new_subs),
440-
"TestD" => client_cache.handle_resubscribe_for_type::<test_d::TestD>(callbacks, new_subs),
441-
"TestE" => client_cache.handle_resubscribe_for_type::<test_e::TestE>(callbacks, new_subs),
434+
"has_special_stuff" => client_cache.handle_resubscribe_for_type::<has_special_stuff::HasSpecialStuff>(callbacks, new_subs),
435+
"pk_multi_identity" => client_cache.handle_resubscribe_for_type::<pk_multi_identity::PkMultiIdentity>(callbacks, new_subs),
436+
"points" => client_cache.handle_resubscribe_for_type::<point::Point>(callbacks, new_subs),
437+
"private" => client_cache.handle_resubscribe_for_type::<private::Private>(callbacks, new_subs),
438+
"repeating_test_args" => client_cache.handle_resubscribe_for_type::<repeating_test_arg::RepeatingTestArg>(callbacks, new_subs),
439+
"test_a" => client_cache.handle_resubscribe_for_type::<test_a::TestA>(callbacks, new_subs),
440+
"test_d" => client_cache.handle_resubscribe_for_type::<test_d::TestD>(callbacks, new_subs),
441+
"test_e" => client_cache.handle_resubscribe_for_type::<test_e::TestE>(callbacks, new_subs),
442442
_ => spacetimedb_sdk::log::error!("TableRowOperation on unknown table {:?}", table_name),
443443
}
444444
}

0 commit comments

Comments
 (0)