From b532577cd1228255a88d833ee34462686d93b89e Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 08:52:52 +0200 Subject: [PATCH 01/19] fix attempt #1 --- crates/bindings-macro/src/table.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 1cbba4c5ca1..d9ab32c94aa 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1015,7 +1015,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ident_span = col.ident.span(); Some(quote_spanned! { ident_span => // This closure enforces that `val` is of type `ty` at compile-time. - let _check: #ty = #val; + let _check: #ty = #val.into(); }) } else { None @@ -1029,7 +1029,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R Some(quote! { spacetimedb::table::ColumnDefault { col_id: #col_id, - value: #val.serialize(spacetimedb::sats::algebraic_value::ser::ValueSerializer).expect("default value serialization failed"), + value: #val.into::<#ty>().serialize(spacetimedb::sats::algebraic_value::ser::ValueSerializer).expect("default value serialization failed"), }, }) } else { From 8644d0e9cc570d97dde0918448b29e722b2196bc Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 08:59:19 +0200 Subject: [PATCH 02/19] cover in module test --- modules/module-test/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/module-test/src/lib.rs b/modules/module-test/src/lib.rs index fc1851b21b0..0b4aec21478 100644 --- a/modules/module-test/src/lib.rs +++ b/modules/module-test/src/lib.rs @@ -26,6 +26,8 @@ pub struct Person { age: u8, #[default(false)] edited: bool, + #[default("test")] + string: String, } #[cfg(not(feature = "test-add-column"))] @@ -274,6 +276,7 @@ pub fn add(ctx: &ReducerContext, name: String, age: u8) { name, age, edited: false, + string: String::new(), }); #[cfg(not(feature = "test-add-column"))] ctx.db.person().insert(Person { id: 0, name, age }); From fe61c811dff83b2381d0e0c04be967a0980769b2 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 09:17:51 +0200 Subject: [PATCH 03/19] forgot to add ty variable --- crates/bindings-macro/src/table.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index d9ab32c94aa..bf3f4749cb6 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1026,6 +1026,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let col_defaults: Vec = columns.iter().filter_map(|col| { if let Some(val) = &col.default_value { let col_id = col.index; + let ty=&col.ty; Some(quote! { spacetimedb::table::ColumnDefault { col_id: #col_id, From b3835a8ed0878f89214364202af6f745175d37b5 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 10:35:42 +0200 Subject: [PATCH 04/19] hm --- crates/bindings-macro/src/table.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index bf3f4749cb6..d9cc48a04ed 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1007,6 +1007,10 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let primary_col_id = primary_key_column.clone().into_iter().map(|col| col.index); let sequence_col_ids = sequenced_columns.iter().map(|col| col.index); + fn is_string(s: &dyn Any) -> bool { + TypeId::of::<&'static str>() == s.type_id() + } + let default_type_check: TokenStream = columns .iter() .filter_map(|col| { @@ -1015,7 +1019,10 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ident_span = col.ident.span(); Some(quote_spanned! { ident_span => // This closure enforces that `val` is of type `ty` at compile-time. - let _check: #ty = #val.into(); + if is_string(#ty) { + WAHOOOO; + } + let _check: #ty = #val; }) } else { None @@ -1030,7 +1037,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R Some(quote! { spacetimedb::table::ColumnDefault { col_id: #col_id, - value: #val.into::<#ty>().serialize(spacetimedb::sats::algebraic_value::ser::ValueSerializer).expect("default value serialization failed"), + value: #val.serialize(spacetimedb::sats::algebraic_value::ser::ValueSerializer).expect("default value serialization failed"), }, }) } else { From e033db08b1a9fbdcdaa9b3db663ffe60fb9dbc5b Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 10:37:31 +0200 Subject: [PATCH 05/19] woops --- crates/bindings-macro/src/table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index d9cc48a04ed..ff66e62f86f 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1008,7 +1008,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let sequence_col_ids = sequenced_columns.iter().map(|col| col.index); fn is_string(s: &dyn Any) -> bool { - TypeId::of::<&'static str>() == s.type_id() + std::any::TypeId::of::<&'static str>() == s.type_id() } let default_type_check: TokenStream = columns From f5e844067473b5da140d2fabd874a2d06279440c Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 10:38:56 +0200 Subject: [PATCH 06/19] ughhh --- crates/bindings-macro/src/table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index ff66e62f86f..721c3efcaa5 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1007,7 +1007,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let primary_col_id = primary_key_column.clone().into_iter().map(|col| col.index); let sequence_col_ids = sequenced_columns.iter().map(|col| col.index); - fn is_string(s: &dyn Any) -> bool { + fn is_string(s: &dyn std::any::Any) -> bool { std::any::TypeId::of::<&'static str>() == s.type_id() } From bafcbebc826126eff1b9840a6e169bdbc06b95e0 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 10:40:54 +0200 Subject: [PATCH 07/19] bang --- crates/bindings-macro/src/table.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 721c3efcaa5..7adb0f8069a 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1007,20 +1007,21 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let primary_col_id = primary_key_column.clone().into_iter().map(|col| col.index); let sequence_col_ids = sequenced_columns.iter().map(|col| col.index); - fn is_string(s: &dyn std::any::Any) -> bool { - std::any::TypeId::of::<&'static str>() == s.type_id() - } - let default_type_check: TokenStream = columns .iter() .filter_map(|col| { if let Some(val) = &col.default_value { let ty = &col.ty; let ident_span = col.ident.span(); + + fn is_string(s: &dyn std::any::Any) -> bool { + std::any::TypeId::of::<&'static str>() == s.type_id() + } + Some(quote_spanned! { ident_span => // This closure enforces that `val` is of type `ty` at compile-time. if is_string(#ty) { - WAHOOOO; + "bang" } let _check: #ty = #val; }) From b7e6406688e859fdeaa7e1ca5706cf326f0859eb Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 10:44:13 +0200 Subject: [PATCH 08/19] hmmge --- crates/bindings-macro/src/table.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 7adb0f8069a..4392280b794 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1014,15 +1014,14 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ty = &col.ty; let ident_span = col.ident.span(); - fn is_string(s: &dyn std::any::Any) -> bool { - std::any::TypeId::of::<&'static str>() == s.type_id() - } - Some(quote_spanned! { ident_span => - // This closure enforces that `val` is of type `ty` at compile-time. + fn is_string(s: &dyn std::any::Any) -> bool { + std::any::TypeId::of::<&'static str>() == s.type_id() + } if is_string(#ty) { - "bang" + "bang"; } + // This closure enforces that `val` is of type `ty` at compile-time. let _check: #ty = #val; }) } else { From c9eb6ca1cf978a0c647e0fed38d34bdf2e32b1c8 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 10:46:59 +0200 Subject: [PATCH 09/19] ahhh --- crates/bindings-macro/src/table.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 4392280b794..08be26b9a97 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1015,10 +1015,10 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ident_span = col.ident.span(); Some(quote_spanned! { ident_span => - fn is_string(s: &dyn std::any::Any) -> bool { + /* fn is_string(s: &dyn std::any::Any) -> bool { std::any::TypeId::of::<&'static str>() == s.type_id() - } - if is_string(#ty) { + } */ + if std::any::TypeId::of::<&'static str>() == s.type_id::<#ty>() { "bang"; } // This closure enforces that `val` is of type `ty` at compile-time. From 33e8221247f24f9eec9a02ba7674e23f33c6fbb2 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 10:47:22 +0200 Subject: [PATCH 10/19] aha --- crates/bindings-macro/src/table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 08be26b9a97..68b42458604 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1018,7 +1018,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R /* fn is_string(s: &dyn std::any::Any) -> bool { std::any::TypeId::of::<&'static str>() == s.type_id() } */ - if std::any::TypeId::of::<&'static str>() == s.type_id::<#ty>() { + if std::any::TypeId::of::<&'static str>() == std::any::TypeId::of::<#ty>() { "bang"; } // This closure enforces that `val` is of type `ty` at compile-time. From e25d3b3ecdb1fa6b18357ad11c896f14bc774a70 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 10:56:33 +0200 Subject: [PATCH 11/19] idk man --- crates/bindings-macro/src/table.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 68b42458604..19abaa62857 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1014,13 +1014,16 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ty = &col.ty; let ident_span = col.ident.span(); + if std::any::TypeId::of::<&'static str>() == std::any::TypeId::of::#ty}>() + { + "bang"; + } + Some(quote_spanned! { ident_span => /* fn is_string(s: &dyn std::any::Any) -> bool { std::any::TypeId::of::<&'static str>() == s.type_id() } */ - if std::any::TypeId::of::<&'static str>() == std::any::TypeId::of::<#ty>() { - "bang"; - } + // This closure enforces that `val` is of type `ty` at compile-time. let _check: #ty = #val; }) From 49265cd2aed11378b7acd612b22f8bd4423a74de Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 11:06:45 +0200 Subject: [PATCH 12/19] wthelly --- crates/bindings-macro/src/table.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 19abaa62857..d10546b1762 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1014,18 +1014,16 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ty = &col.ty; let ident_span = col.ident.span(); - if std::any::TypeId::of::<&'static str>() == std::any::TypeId::of::#ty}>() - { - "bang"; - } - Some(quote_spanned! { ident_span => - /* fn is_string(s: &dyn std::any::Any) -> bool { - std::any::TypeId::of::<&'static str>() == s.type_id() - } */ // This closure enforces that `val` is of type `ty` at compile-time. - let _check: #ty = #val; + if std::any::TypeId::of::<&'static str>() == std::any::TypeId::of::<#ty>() { + let _check: &'static str = #val; + } else { + + + let _check: #ty = #val; + } }) } else { None From fae833ed7fc0a30baea180720626af17c439d9a6 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 11:11:55 +0200 Subject: [PATCH 13/19] hmmge --- crates/bindings-macro/src/table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index d10546b1762..b95c349db6b 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1017,7 +1017,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R Some(quote_spanned! { ident_span => // This closure enforces that `val` is of type `ty` at compile-time. - if std::any::TypeId::of::<&'static str>() == std::any::TypeId::of::<#ty>() { + if std::any::TypeId::of::() == std::any::TypeId::of::<#ty>() { let _check: &'static str = #val; } else { From 12d3ba94885e7935ad5b2c0147d25cfc0537ea11 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 17:35:57 +0200 Subject: [PATCH 14/19] jaaa --- crates/bindings-macro/src/table.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index b95c349db6b..ee3eb161e0d 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1014,17 +1014,21 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ty = &col.ty; let ident_span = col.ident.span(); - Some(quote_spanned! { ident_span => - + // The upper branch of this if clause is special handling for the string type. + if let Type::Path(type_path) = ty + && let Some(segment) = type_path.path.segments.last() + && segment.ident.to_string() == "String" + { + Some(quote_spanned! { ident_span => + + let _check: &'static str = #val; + }) + } else { // This closure enforces that `val` is of type `ty` at compile-time. - if std::any::TypeId::of::() == std::any::TypeId::of::<#ty>() { - let _check: &'static str = #val; - } else { - - - let _check: #ty = #val; - } - }) + Some(quote_spanned! { ident_span => + let _check: #ty = #val; + }) + } } else { None } From 59633ebee1ae77bc3e9e3c71c2a39ac8dfd77974 Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 17:38:34 +0200 Subject: [PATCH 15/19] import missing yek --- crates/bindings-macro/src/table.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index ee3eb161e0d..4f2a5a221a2 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1015,12 +1015,11 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ident_span = col.ident.span(); // The upper branch of this if clause is special handling for the string type. - if let Type::Path(type_path) = ty + if let syn::ty::Type::Path(type_path) = ty && let Some(segment) = type_path.path.segments.last() && segment.ident.to_string() == "String" { Some(quote_spanned! { ident_span => - let _check: &'static str = #val; }) } else { From e1b3afc6301b392008c6d37c864619f7b3c3a9cf Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 17:40:37 +0200 Subject: [PATCH 16/19] yek --- crates/bindings-macro/src/table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 4f2a5a221a2..19fcaec0c9f 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1015,7 +1015,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let ident_span = col.ident.span(); // The upper branch of this if clause is special handling for the string type. - if let syn::ty::Type::Path(type_path) = ty + if let syn::Type::Path(type_path) = ty && let Some(segment) = type_path.path.segments.last() && segment.ident.to_string() == "String" { From 842b4145840af115e4f698ddea51b08114e484b3 Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Tue, 28 Jul 2026 05:16:54 -0400 Subject: [PATCH 17/19] Test string column defaults in module migration --- .../smoketests/tests/smoketests/cli/publish.rs | 11 +++++++++++ modules/module-test/src/lib.rs | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/smoketests/tests/smoketests/cli/publish.rs b/crates/smoketests/tests/smoketests/cli/publish.rs index 7fe5fab5fc0..af56cf64c3a 100644 --- a/crates/smoketests/tests/smoketests/cli/publish.rs +++ b/crates/smoketests/tests/smoketests/cli/publish.rs @@ -67,6 +67,14 @@ fn migration_test(module_name: &str, republish_args: &[&str], expect_success: bo ]) .unwrap(); + let should_assert_added_column_defaults = republish_args.iter().any(|arg| arg.contains("test-add-column")) + && !republish_args.contains(&"--delete-data") + && expect_success; + + if should_assert_added_column_defaults { + test.call("add", &["Arthur", "42"]).unwrap(); + } + let dir = dir.to_string(); let mut args = vec![ "publish", @@ -85,6 +93,9 @@ fn migration_test(module_name: &str, republish_args: &[&str], expect_success: bo "republish should have succeeded: {}", String::from_utf8_lossy(&output.stderr) ); + if should_assert_added_column_defaults { + test.call("assert_person_string_default", &["Arthur", "test"]).unwrap(); + } } else { assert!(!output.status.success(), "republish should have failed but succeeded"); } diff --git a/modules/module-test/src/lib.rs b/modules/module-test/src/lib.rs index 0b4aec21478..e300ab65621 100644 --- a/modules/module-test/src/lib.rs +++ b/modules/module-test/src/lib.rs @@ -282,6 +282,24 @@ pub fn add(ctx: &ReducerContext, name: String, age: u8) { ctx.db.person().insert(Person { id: 0, name, age }); } +#[cfg(feature = "test-add-column")] +#[spacetimedb::reducer] +pub fn assert_person_string_default(ctx: &ReducerContext, name: String, expected: String) { + let mut found = false; + + for person in ctx.db.person().iter().filter(|person| person.name == name) { + found = true; + assert_eq!( + person.string.as_str(), + expected.as_str(), + "migrated person row {} has the wrong string default", + person.id + ); + } + + assert!(found, "expected to find a migrated person row named {name}"); +} + #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { From e8a0dd0f15028f26e7f6fad79e03be278d74dbcd Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Tue, 28 Jul 2026 05:26:56 -0400 Subject: [PATCH 18/19] Move string default test to automigration coverage --- .../tests/smoketests/auto_migration.rs | 15 +++++++++------ .../smoketests/tests/smoketests/cli/publish.rs | 11 ----------- modules/module-test/src/lib.rs | 18 ------------------ 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/crates/smoketests/tests/smoketests/auto_migration.rs b/crates/smoketests/tests/smoketests/auto_migration.rs index 70f84b394b6..8fd7169b395 100644 --- a/crates/smoketests/tests/smoketests/auto_migration.rs +++ b/crates/smoketests/tests/smoketests/auto_migration.rs @@ -290,11 +290,13 @@ pub struct Person { age: u16, #[default(19)] mass: u16, + #[default("Student")] + title: String, } #[spacetimedb::reducer] pub fn add_person(ctx: &ReducerContext, name: String) { - ctx.db.person().insert(Person { name, age: 70, mass: 180 }); + ctx.db.person().insert(Person { name, age: 70, mass: 180, title: "Professor".to_string() }); } #[spacetimedb::reducer] @@ -320,13 +322,14 @@ pub struct Person { age: u16, #[default(19)] mass: u16, + title: String, #[default(160)] height: u32, } #[spacetimedb::reducer] pub fn add_person(ctx: &ReducerContext, name: String) { - ctx.db.person().insert(Person { name, age: 70, mass: 180, height: 72 }); + ctx.db.person().insert(Person { name, age: 70, mass: 180, title: "Professor".to_string(), height: 72 }); } #[spacetimedb::reducer] @@ -369,7 +372,7 @@ fn test_add_table_columns() { assert!( logs1 .iter() - .any(|l| l.contains("FIRST_UPDATE: Person { name: \"Robert\", age: 0, mass: 19 }")), + .any(|l| l.contains("FIRST_UPDATE: Person { name: \"Robert\", age: 0, mass: 19, title: \"Student\" }")), "Expected migrated person with defaults in logs: {:?}", logs1 ); @@ -400,9 +403,9 @@ fn test_add_table_columns() { let logs2 = test.logs(100).unwrap(); assert!( - logs2 - .iter() - .any(|l| { l.contains("UPDATE_2: Person { name: \"Robert2\", age: 70, mass: 180, height: 160 }") }), + logs2.iter().any(|l| { + l.contains("UPDATE_2: Person { name: \"Robert2\", age: 70, mass: 180, title: \"Professor\", height: 160 }") + }), "Expected updated schema with default height in logs: {:?}", logs2 ); diff --git a/crates/smoketests/tests/smoketests/cli/publish.rs b/crates/smoketests/tests/smoketests/cli/publish.rs index af56cf64c3a..7fe5fab5fc0 100644 --- a/crates/smoketests/tests/smoketests/cli/publish.rs +++ b/crates/smoketests/tests/smoketests/cli/publish.rs @@ -67,14 +67,6 @@ fn migration_test(module_name: &str, republish_args: &[&str], expect_success: bo ]) .unwrap(); - let should_assert_added_column_defaults = republish_args.iter().any(|arg| arg.contains("test-add-column")) - && !republish_args.contains(&"--delete-data") - && expect_success; - - if should_assert_added_column_defaults { - test.call("add", &["Arthur", "42"]).unwrap(); - } - let dir = dir.to_string(); let mut args = vec![ "publish", @@ -93,9 +85,6 @@ fn migration_test(module_name: &str, republish_args: &[&str], expect_success: bo "republish should have succeeded: {}", String::from_utf8_lossy(&output.stderr) ); - if should_assert_added_column_defaults { - test.call("assert_person_string_default", &["Arthur", "test"]).unwrap(); - } } else { assert!(!output.status.success(), "republish should have failed but succeeded"); } diff --git a/modules/module-test/src/lib.rs b/modules/module-test/src/lib.rs index e300ab65621..0b4aec21478 100644 --- a/modules/module-test/src/lib.rs +++ b/modules/module-test/src/lib.rs @@ -282,24 +282,6 @@ pub fn add(ctx: &ReducerContext, name: String, age: u8) { ctx.db.person().insert(Person { id: 0, name, age }); } -#[cfg(feature = "test-add-column")] -#[spacetimedb::reducer] -pub fn assert_person_string_default(ctx: &ReducerContext, name: String, expected: String) { - let mut found = false; - - for person in ctx.db.person().iter().filter(|person| person.name == name) { - found = true; - assert_eq!( - person.string.as_str(), - expected.as_str(), - "migrated person row {} has the wrong string default", - person.id - ); - } - - assert!(found, "expected to find a migrated person row named {name}"); -} - #[spacetimedb::reducer] pub fn say_hello(ctx: &ReducerContext) { for person in ctx.db.person().iter() { From 4bb3f45585abff7bcd543b39821c2a5ce71e6e54 Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Tue, 28 Jul 2026 05:42:46 -0400 Subject: [PATCH 19/19] Fix string default macro lints --- crates/bindings-macro/src/table.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 19fcaec0c9f..e6755b75d19 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -1017,7 +1017,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R // The upper branch of this if clause is special handling for the string type. if let syn::Type::Path(type_path) = ty && let Some(segment) = type_path.path.segments.last() - && segment.ident.to_string() == "String" + && segment.ident == "String" { Some(quote_spanned! { ident_span => let _check: &'static str = #val; @@ -1025,7 +1025,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R } else { // This closure enforces that `val` is of type `ty` at compile-time. Some(quote_spanned! { ident_span => - let _check: #ty = #val; + let _check: #ty = #val; }) } } else { @@ -1037,7 +1037,6 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let col_defaults: Vec = columns.iter().filter_map(|col| { if let Some(val) = &col.default_value { let col_id = col.index; - let ty=&col.ty; Some(quote! { spacetimedb::table::ColumnDefault { col_id: #col_id,