diff --git a/scylla-cql/src/types/serialize/row.rs b/scylla-cql/src/types/serialize/row.rs index deb375eec..493542113 100644 --- a/scylla-cql/src/types/serialize/row.rs +++ b/scylla-cql/src/types/serialize/row.rs @@ -1790,4 +1790,58 @@ pub(crate) mod tests { assert_eq!(reference, row); } + + #[test] + fn test_name_flatten_with_lifetimes() { + #[derive(SerializeRow)] + #[scylla(crate = crate, flavor = "enforce_order")] + struct Inner<'b> { + b: &'b bool, + } + + #[derive(SerializeRow)] + #[scylla(crate = crate, flavor = "enforce_order")] + struct Outer<'a, 'b> { + #[scylla(flatten)] + inner: &'a Inner<'b>, + } + + let b = true; + let inner = Inner { b: &b }; + + let value = Outer { inner: &inner }; + let spec = [col("b", ColumnType::Boolean)]; + + let reference = do_serialize((&value.inner.b,), &spec); + let row = do_serialize(value, &spec); + + assert_eq!(reference, row); + } + + #[test] + fn test_ordered_flatten_with_lifetimes() { + #[derive(SerializeRow)] + #[scylla(crate = crate, flavor = "enforce_order")] + struct Inner<'b> { + b: &'b bool, + } + + #[derive(SerializeRow)] + #[scylla(crate = crate, flavor = "enforce_order")] + struct Outer<'a, 'b> { + #[scylla(flatten)] + inner: &'a Inner<'b>, + } + + let b = true; + let inner = Inner { b: &b }; + + let value = Outer { inner: &inner }; + let spec = [col("b", ColumnType::Boolean)]; + + let reference = do_serialize((&value.inner.b,), &spec); + let row = do_serialize(value, &spec); + + assert_eq!(reference, row); + } } diff --git a/scylla-macros/src/serialize/row.rs b/scylla-macros/src/serialize/row.rs index 068156ad2..e0002c2d0 100644 --- a/scylla-macros/src/serialize/row.rs +++ b/scylla-macros/src/serialize/row.rs @@ -341,10 +341,10 @@ impl Generator for ColumnSortingGenerator<'_> { }; parse_quote! { - fn serialize<'b>( + fn serialize<'_scylla_ser_row_writer_buffer>( &self, ctx: &#crate_path::RowSerializationContext, - writer: &mut #crate_path::RowWriter<'b>, + writer: &mut #crate_path::RowWriter<'_scylla_ser_row_writer_buffer>, ) -> ::std::result::Result<(), #crate_path::SerializationError> { #partial_struct #partial_serialize @@ -400,10 +400,10 @@ impl Generator for ColumnOrderedGenerator<'_> { }); parse_quote! { - fn serialize<'b>( + fn serialize<'_scylla_ser_row_writer_buffer>( &self, ctx: &#crate_path::RowSerializationContext, - writer: &mut #crate_path::RowWriter<'b>, + writer: &mut #crate_path::RowWriter<'_scylla_ser_row_writer_buffer>, ) -> ::std::result::Result<(), #crate_path::SerializationError> { #[allow(non_local_definitions)] impl #impl_generics #crate_path::SerializeRowInOrder for #struct_name #ty_generics #where_clause {