From b532577cd1228255a88d833ee34462686d93b89e Mon Sep 17 00:00:00 2001 From: Kilian Strunz Date: Fri, 17 Jul 2026 08:52:52 +0200 Subject: [PATCH 01/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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" {