diff --git a/.github/workflows/scylla.yml b/.github/workflows/scylla.yml index 0d43eaf..1aeb71c 100644 --- a/.github/workflows/scylla.yml +++ b/.github/workflows/scylla.yml @@ -15,7 +15,7 @@ jobs: # Locally scylla can be started like so: docker run --name scylla -p 19042:19042 -p 9042:9042 --rm scylladb/scylla services: scylladb: - image: scylladb/scylla + image: scylladb/scylla:5.4 ports: - 9042:9042 - 19042:19042 diff --git a/Cargo.lock b/Cargo.lock index 40f1247..c4327e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,7 +125,7 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "catalytic" -version = "0.1.20" +version = "0.1.21" dependencies = [ "dotenv", "futures-util", @@ -140,7 +140,7 @@ dependencies = [ [[package]] name = "catalytic_macro" -version = "0.1.20" +version = "0.1.21" dependencies = [ "catalytic", "catalytic_query_parser", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "catalytic_query_parser" -version = "0.1.20" +version = "0.1.21" dependencies = [ "catalytic", "catalytic_macro", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "catalytic_table_to_struct" -version = "0.1.20" +version = "0.1.21" dependencies = [ "catalytic", "heck 0.4.1", @@ -209,6 +209,41 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.31", +] + +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.31", +] + [[package]] name = "dashmap" version = "5.4.0" @@ -242,7 +277,7 @@ checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" [[package]] name = "example_project" -version = "0.1.20" +version = "0.1.21" dependencies = [ "catalytic", "catalytic_macro", @@ -258,6 +293,12 @@ dependencies = [ "uuid", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "futures" version = "0.3.28" @@ -432,6 +473,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indexmap" version = "2.0.0" @@ -793,9 +840,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scylla" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b30067d0d0313a0bbcda9c31a503678f18dacd5426dd8a63c3f581cf80f5c30" +checksum = "db4bca1987121cceb419f0644cf064416f719c73c44b6cbe849b62fd3b7adc3c" dependencies = [ "arc-swap", "async-trait", @@ -827,15 +874,14 @@ dependencies = [ [[package]] name = "scylla-cql" -version = "0.0.9" +version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9642864295085ef2fe62493eec405a109fbaae9f3a9b80ea087556af4a97df2" +checksum = "50938b1bbb5c6364617977939c09644384495f658dc899ec37fd90bce73e6f37" dependencies = [ "async-trait", "bigdecimal", "byteorder", "bytes", - "chrono", "lz4_flex", "num-bigint", "num_enum", @@ -848,10 +894,11 @@ dependencies = [ [[package]] name = "scylla-macros" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5757ded3dfb10967ca7d1ff1084d072d565b5e10b2b21c286d5335c245425a7e" +checksum = "22b6659cdeed34c5b83719edd4d9f023c18357677e3fbe14237a59f00403acce" dependencies = [ + "darling", "proc-macro2", "quote", "syn 2.0.31", @@ -934,6 +981,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strum" version = "0.23.0" diff --git a/Cargo.toml b/Cargo.toml index 6d5cf09..de9322b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ resolver = "2" [workspace.package] edition = "2021" -version = "0.1.20" +version = "0.1.21" authors = ["Jasper Visser "] repository = "https://github.com/Jasperav/catalytic" readme = "./README.md" @@ -19,7 +19,7 @@ categories = ["database"] license = "MIT" [workspace.dependencies] -scylla = "0.10.1" # This crate is specifically build for this version +scylla = "0.11.1" # This crate is specifically build for this version once_cell = "1" heck = "0.4" tokio = { version = "1", features = ["time", "rt-multi-thread", "io-util"] } diff --git a/catalytic/src/query_transform.rs b/catalytic/src/query_transform.rs index 5644925..ee20253 100644 --- a/catalytic/src/query_transform.rs +++ b/catalytic/src/query_transform.rs @@ -3,9 +3,9 @@ /// methods, but specific methods, like 'update', 'delete' etc use crate::Cursor; use futures_util::{StreamExt, TryStreamExt}; +use scylla::_macro_internal::{LegacySerializedValues, SerializeRow}; use scylla::cql_to_rust::FromRowError; -use scylla::frame::value::SerializedValues; -use scylla::frame::value::{SerializeValuesError, ValueList}; +use scylla::frame::value::SerializeValuesError; use scylla::query::Query; use scylla::transport::errors::QueryError; use scylla::transport::iterator::TypedRowIterator; @@ -199,12 +199,12 @@ impl QueryResultUniqueRowExpect { } } -pub struct Qv = &'static str, V: ValueList = SerializedValues> { +pub struct Qv = &'static str, V: SerializeRow = LegacySerializedValues> { pub query: R, pub values: V, } -impl + Clone, V: ValueList + Clone> Clone for Qv { +impl + Clone, V: SerializeRow + Clone> Clone for Qv { fn clone(&self) -> Self { Qv { query: self.query.clone(), @@ -213,7 +213,7 @@ impl + Clone, V: ValueList + Clone> Clone for Qv { } } -impl, V: ValueList> Debug for Qv { +impl, V: SerializeRow> Debug for Qv { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.debug_struct("Qv") .field("query", &self.query.as_ref()) @@ -221,7 +221,7 @@ impl, V: ValueList> Debug for Qv { } } -impl, V: ValueList> Qv { +impl, V: SerializeRow> Qv { async fn execute(&self, session: &CachingSession) -> ScyllaQueryResult { let as_ref = self.query.as_ref(); @@ -339,10 +339,10 @@ impl, V: ValueList> Qv { macro_rules! simple_qv_holder { ($ ident : ident , $ method : ident) => { #[derive(Debug)] - pub struct $ident = &'static str, V: ValueList = SerializedValues> { + pub struct $ident = &'static str, V: SerializeRow = LegacySerializedValues> { pub qv: Qv, } - impl, V: ValueList> $ident { + impl, V: SerializeRow> $ident { pub fn new(qv: Qv) -> Self { Self { qv } } @@ -352,7 +352,7 @@ macro_rules! simple_qv_holder { } } - impl, V: ValueList> Deref for $ident { + impl, V: SerializeRow> Deref for $ident { type Target = Qv; fn deref(&self) -> &Self::Target { @@ -360,7 +360,7 @@ macro_rules! simple_qv_holder { } } - impl + Clone, V: ValueList + Clone> Clone for $ident { + impl + Clone, V: SerializeRow + Clone> Clone for $ident { fn clone(&self) -> Self { $ident::new(self.qv.clone()) } @@ -376,19 +376,22 @@ simple_qv_holder!(Truncate, truncate); macro_rules! read_transform { ($ ident : ident) => { #[derive(Debug)] - pub struct $ident = &'static str, V: ValueList = SerializedValues> - { + pub struct $ident< + T: FromRow, + R: AsRef = &'static str, + V: SerializeRow = LegacySerializedValues, + > { pub qv: Qv, p: PhantomData, } - impl, V: ValueList> $ident { + impl, V: SerializeRow> $ident { pub fn new(qv: Qv) -> $ident { $ident { qv, p: PhantomData } } } - impl, V: ValueList> Deref for $ident { + impl, V: SerializeRow> Deref for $ident { type Target = Qv; fn deref(&self) -> &Self::Target { @@ -396,7 +399,7 @@ macro_rules! read_transform { } } - impl + Clone, V: ValueList + Clone> Clone for $ident { + impl + Clone, V: SerializeRow + Clone> Clone for $ident { fn clone(&self) -> Self { $ident::new(self.qv.clone()) } @@ -407,7 +410,7 @@ read_transform!(SelectMultiple); read_transform!(SelectUnique); read_transform!(SelectUniqueExpect); -impl, V: ValueList> SelectUnique { +impl, V: SerializeRow> SelectUnique { pub fn expect(self) -> SelectUniqueExpect { SelectUniqueExpect::new(self.qv) } @@ -423,7 +426,7 @@ impl, V: ValueList> SelectUnique { } } -impl, V: ValueList> SelectUniqueExpect { +impl, V: SerializeRow> SelectUniqueExpect { pub async fn select( &self, session: &CachingSession, @@ -435,7 +438,7 @@ impl, V: ValueList> SelectUniqueExpect { } } -impl, V: ValueList> SelectUniqueExpect { +impl, V: SerializeRow> SelectUniqueExpect { pub async fn select_count( &self, session: &CachingSession, @@ -448,7 +451,7 @@ impl, V: ValueList> SelectUniqueExpect { } } -impl, V: ValueList> SelectMultiple { +impl, V: SerializeRow> SelectMultiple { pub async fn select( &self, session: &CachingSession, diff --git a/catalytic/src/runtime.rs b/catalytic/src/runtime.rs index e965aa0..cffdec6 100644 --- a/catalytic/src/runtime.rs +++ b/catalytic/src/runtime.rs @@ -1,8 +1,8 @@ use crate::env_property_reader::{database_url, keyspace, password, username}; use once_cell::sync::Lazy; +use scylla::_macro_internal::SerializeRow; use scylla::execution_profile::ExecutionProfileBuilder; use scylla::frame::types::Consistency; -use scylla::frame::value::ValueList; use scylla::query::Query; use scylla::{FromRow, IntoTypedRows, Session, SessionBuilder}; use tokio::runtime::{self, Runtime}; @@ -21,7 +21,7 @@ pub static RUNTIME: Lazy = Lazy::new(|| { pub fn query_collect_to_vec( query: impl Into, - values: impl ValueList, + values: impl SerializeRow, ) -> Vec { touch_global_connection(); @@ -38,7 +38,7 @@ pub fn query_collect_to_vec( }) } -pub fn query(query: impl Into, values: impl ValueList) { +pub fn query(query: impl Into, values: impl SerializeRow) { touch_global_connection(); block_on(async move { GLOBAL_CONNECTION.query(query, values).await.unwrap() }); diff --git a/catalytic/src/table_metadata.rs b/catalytic/src/table_metadata.rs index a1221cf..c71d57a 100644 --- a/catalytic/src/table_metadata.rs +++ b/catalytic/src/table_metadata.rs @@ -31,7 +31,7 @@ impl ToString for ColumnKind { } /// Meta data about a column for a table -#[derive(Debug, scylla::ValueList, scylla::FromRow)] +#[derive(Debug, scylla::SerializeRow, scylla::FromRow)] pub struct ColumnInTable { /// Name of the column pub column_name: String, @@ -123,4 +123,25 @@ impl ColumnType { result.to_string() } + + /// Since Catalytic doesn't support every time, there is a separate enum with convertion + pub fn scylla_column_type(&self) -> scylla::frame::response::result::ColumnType { + match self { + ColumnType::TinyInt => scylla::frame::response::result::ColumnType::TinyInt, + ColumnType::SmallInt => scylla::frame::response::result::ColumnType::SmallInt, + ColumnType::Int => scylla::frame::response::result::ColumnType::Int, + ColumnType::BigInt => scylla::frame::response::result::ColumnType::BigInt, + ColumnType::Text => scylla::frame::response::result::ColumnType::Text, + ColumnType::Ascii => scylla::frame::response::result::ColumnType::Ascii, + ColumnType::Varchar => scylla::frame::response::result::ColumnType::Varint, + ColumnType::Boolean => scylla::frame::response::result::ColumnType::Boolean, + ColumnType::Time => scylla::frame::response::result::ColumnType::Time, + ColumnType::Timestamp => scylla::frame::response::result::ColumnType::Timestamp, + ColumnType::Float => scylla::frame::response::result::ColumnType::Float, + ColumnType::Double => scylla::frame::response::result::ColumnType::Double, + ColumnType::Uuid => scylla::frame::response::result::ColumnType::Uuid, + ColumnType::Counter => scylla::frame::response::result::ColumnType::Counter, + ColumnType::Custom(s) => scylla::frame::response::result::ColumnType::Custom(s.clone()), + } + } } diff --git a/catalytic_macro/src/json.rs b/catalytic_macro/src/json.rs index ee70a9a..21ba549 100644 --- a/catalytic_macro/src/json.rs +++ b/catalytic_macro/src/json.rs @@ -6,6 +6,18 @@ pub(crate) fn json(derive_input: DeriveInput) -> TokenStream { let name = derive_input.ident; quote! { + impl catalytic::scylla::_macro_internal::SerializeCql for #name { + fn serialize<'b>( + &self, + typ: &catalytic::scylla::_macro_internal::ColumnType, + writer: catalytic::scylla::_macro_internal::CellWriter<'b>, + ) -> Result, catalytic::scylla::_macro_internal::SerializationError> { + let serialized: String = serde_json::to_string(&self).unwrap().into(); + + serialized.serialize(typ, writer) + } + } + impl catalytic::scylla::frame::value::Value for #name { fn serialize(&self, buf: &mut Vec) -> Result<(), catalytic::scylla::frame::value::ValueTooBig> { let serialized: String = serde_json::to_string(&self).unwrap().into(); diff --git a/catalytic_query_parser/src/extract_query_metadata.rs b/catalytic_query_parser/src/extract_query_metadata.rs index 982dfd3..ebb1a9d 100644 --- a/catalytic_query_parser/src/extract_query_metadata.rs +++ b/catalytic_query_parser/src/extract_query_metadata.rs @@ -5,9 +5,9 @@ use catalytic::query_metadata::{ query_columns, ColumnInQuery, ParameterizedColumnType, ParameterizedValue, QueryMetadata, Ttl, }; use catalytic::runtime::{block_on, GLOBAL_CONNECTION}; -use catalytic::scylla::frame::value::SerializedValues; use catalytic::table_metadata::{ColumnInTable, ColumnType}; use std::collections::HashSet; +use catalytic::scylla::_macro_internal::LegacySerializedValues; /// Extract the query meta data from a query pub fn extract_query_meta_data(query: impl AsRef) -> QueryMetadata { @@ -118,7 +118,7 @@ pub fn replace_select_wildcard(query: &str, columns: &[ColumnInTable]) -> String pub fn test_query(query: impl AsRef) -> QueryMetadata { let query = query.as_ref(); let qmd = extract_query_meta_data(query); - let mut values = SerializedValues::new(); + let mut values = LegacySerializedValues::new(); for parameterized_column_type in &qmd.parameterized_columns_types { add_random_value(&mut values, parameterized_column_type); @@ -188,7 +188,7 @@ fn create_parameterized_column_types( /// Generates a random value for a given data type fn add_random_value( - serialized_values: &mut SerializedValues, + serialized_values: &mut LegacySerializedValues, parameterized_column_type: &ParameterizedColumnType, ) { let uses_in_query = match ¶meterized_column_type.value { diff --git a/catalytic_query_parser/src/lib.rs b/catalytic_query_parser/src/lib.rs index aa588dc..8a4aa00 100644 --- a/catalytic_query_parser/src/lib.rs +++ b/catalytic_query_parser/src/lib.rs @@ -212,7 +212,7 @@ impl Parse for Query { // )* // // let mut serialized_values = catalytic::scylla::frame::value::SerializedValues::with_capacity(size); - let mut serialized_values = catalytic::scylla::frame::value::SerializedValues::new(); + let mut serialized_values = catalytic::scylla::frame::value::LegacySerializedValues::new(); #( // Check if the type is correct diff --git a/catalytic_table_to_struct/example/src/generated/another_test_table.rs b/catalytic_table_to_struct/example/src/generated/another_test_table.rs index a946192..8e0ec3b 100644 --- a/catalytic_table_to_struct/example/src/generated/another_test_table.rs +++ b/catalytic_table_to_struct/example/src/generated/another_test_table.rs @@ -7,9 +7,9 @@ use catalytic::query_transform::{ TtlType, Update, }; use catalytic::scylla; +use scylla::frame::value::LegacySerializedValues; #[allow(unused_imports)] use scylla::frame::value::SerializeValuesError; -use scylla::frame::value::SerializedValues; use scylla::transport::errors::QueryError; use scylla::transport::iterator::TypedRowIterator; use scylla::CachingSession; @@ -39,8 +39,9 @@ pub const DELETE_QUERY: &str = "delete from another_test_table where a = ? and b #[doc = r" When you converted this struct to the specified type, you will have methods available"] #[doc = r" for the things you want"] #[derive( - scylla :: FromRow, scylla :: ValueList, catalytic_macro :: Mirror, Debug, Clone, PartialEq, + scylla :: FromRow, scylla :: SerializeRow, catalytic_macro :: Mirror, Debug, Clone, PartialEq, )] +# [scylla (crate = scylla , flavor = "enforce_order" , skip_name_checks)] pub struct AnotherTestTable { #[partition_key] pub a: i32, @@ -171,7 +172,7 @@ pub async fn truncate(session: &CachingSession) -> ScyllaQueryResult { impl<'a> AnotherTestTableRef<'a> { #[doc = r" Returns a struct that can perform an insert operation"] pub fn insert_qv(&self) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.a)?; serialized.add_value(&self.b)?; serialized.add_value(&self.c)?; @@ -188,7 +189,7 @@ impl<'a> AnotherTestTableRef<'a> { } #[doc = r" Returns a struct that can perform an insert operation with a TTL"] pub fn insert_ttl_qv(&self, ttl: TtlType) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.a)?; serialized.add_value(&self.b)?; serialized.add_value(&self.c)?; @@ -281,7 +282,7 @@ impl From> for PrimaryKey { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a unique row selection"] pub fn select_unique_qv(&self) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.a)?; serialized_values.add_value(&self.b)?; serialized_values.add_value(&self.c)?; @@ -308,7 +309,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_expect_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.a)?; serialized_values.add_value(&self.b)?; serialized_values.add_value(&self.c)?; @@ -333,7 +334,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = "Returns a struct that can perform an update operation for column d"] pub fn update_d_qv(&self, val: &i32) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; serialized_values.add_value(&self.a)?; serialized_values.add_value(&self.b)?; @@ -378,12 +379,12 @@ impl PrimaryKeyRef<'_> { pub fn update_dyn_multiple_qv( &self, val: &[UpdatableColumnRef<'_>], - ) -> Result, SerializeValuesError> { + ) -> Result, SerializeValuesError> { if val.is_empty() { panic!("Empty update array") } let mut query = vec![]; - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); for v in val { match v { UpdatableColumnRef::D(v) => { @@ -423,7 +424,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a single row deletion"] pub fn delete_qv(&self) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.a)?; serialized_values.add_value(&self.b)?; serialized_values.add_value(&self.c)?; diff --git a/catalytic_table_to_struct/example/src/generated/child.rs b/catalytic_table_to_struct/example/src/generated/child.rs index b983f15..4ce9411 100644 --- a/catalytic_table_to_struct/example/src/generated/child.rs +++ b/catalytic_table_to_struct/example/src/generated/child.rs @@ -7,9 +7,9 @@ use catalytic::query_transform::{ TtlType, Update, }; use catalytic::scylla; +use scylla::frame::value::LegacySerializedValues; #[allow(unused_imports)] use scylla::frame::value::SerializeValuesError; -use scylla::frame::value::SerializedValues; use scylla::transport::errors::QueryError; use scylla::transport::iterator::TypedRowIterator; use scylla::CachingSession; @@ -44,8 +44,9 @@ pub const DELETE_QUERY: &str = "delete from child where birthday = ?"; #[doc = r" When you converted this struct to the specified type, you will have methods available"] #[doc = r" for the things you want"] #[derive( - scylla :: FromRow, scylla :: ValueList, catalytic_macro :: Mirror, Debug, Clone, PartialEq, + scylla :: FromRow, scylla :: SerializeRow, catalytic_macro :: Mirror, Debug, Clone, PartialEq, )] +# [scylla (crate = scylla , flavor = "enforce_order" , skip_name_checks)] pub struct Child { #[partition_key] pub birthday: i32, @@ -171,7 +172,7 @@ pub async fn truncate(session: &CachingSession) -> ScyllaQueryResult { impl<'a> ChildRef<'a> { #[doc = r" Returns a struct that can perform an insert operation"] pub fn insert_qv(&self) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.birthday)?; serialized.add_value(&self.enum_json)?; serialized.add_value(&self.json)?; @@ -188,7 +189,7 @@ impl<'a> ChildRef<'a> { } #[doc = r" Returns a struct that can perform an insert operation with a TTL"] pub fn insert_ttl_qv(&self, ttl: TtlType) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.birthday)?; serialized.add_value(&self.enum_json)?; serialized.add_value(&self.json)?; @@ -277,7 +278,7 @@ impl From> for PrimaryKey { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a unique row selection"] pub fn select_unique_qv(&self) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.birthday)?; Ok(SelectUnique::new(Qv { query: SELECT_UNIQUE_QUERY, @@ -302,7 +303,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_expect_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.birthday)?; Ok(SelectUniqueExpect::new(Qv { query: SELECT_UNIQUE_QUERY, @@ -328,7 +329,7 @@ impl PrimaryKeyRef<'_> { &self, val: &crate::MyJsonEnum, ) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; serialized_values.add_value(&self.birthday)?; Ok(Update::new(Qv { @@ -354,7 +355,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = "Returns a struct that can perform an update operation for column json"] pub fn update_json_qv(&self, val: &crate::MyJsonType) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; serialized_values.add_value(&self.birthday)?; Ok(Update::new(Qv { @@ -383,7 +384,7 @@ impl PrimaryKeyRef<'_> { &self, val: &std::option::Option, ) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; serialized_values.add_value(&self.birthday)?; Ok(Update::new(Qv { @@ -432,12 +433,12 @@ impl PrimaryKeyRef<'_> { pub fn update_dyn_multiple_qv( &self, val: &[UpdatableColumnRef<'_>], - ) -> Result, SerializeValuesError> { + ) -> Result, SerializeValuesError> { if val.is_empty() { panic!("Empty update array") } let mut query = vec![]; - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); for v in val { match v { UpdatableColumnRef::EnumJson(v) => { @@ -483,7 +484,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a single row deletion"] pub fn delete_qv(&self) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.birthday)?; Ok(DeleteUnique::new(Qv { query: DELETE_QUERY, diff --git a/catalytic_table_to_struct/example/src/generated/field_name_different_combined.rs b/catalytic_table_to_struct/example/src/generated/field_name_different_combined.rs index 455cbed..fd53f86 100644 --- a/catalytic_table_to_struct/example/src/generated/field_name_different_combined.rs +++ b/catalytic_table_to_struct/example/src/generated/field_name_different_combined.rs @@ -7,9 +7,9 @@ use catalytic::query_transform::{ TtlType, Update, }; use catalytic::scylla; +use scylla::frame::value::LegacySerializedValues; #[allow(unused_imports)] use scylla::frame::value::SerializeValuesError; -use scylla::frame::value::SerializedValues; use scylla::transport::errors::QueryError; use scylla::transport::iterator::TypedRowIterator; use scylla::CachingSession; @@ -41,8 +41,9 @@ pub const DELETE_QUERY: &str = #[doc = r" When you converted this struct to the specified type, you will have methods available"] #[doc = r" for the things you want"] #[derive( - scylla :: FromRow, scylla :: ValueList, catalytic_macro :: Mirror, Debug, Clone, PartialEq, + scylla :: FromRow, scylla :: SerializeRow, catalytic_macro :: Mirror, Debug, Clone, PartialEq, )] +# [scylla (crate = scylla , flavor = "enforce_order" , skip_name_checks)] pub struct FieldNameDifferentCombined { #[partition_key] pub row_type: i32, @@ -166,7 +167,7 @@ pub async fn truncate(session: &CachingSession) -> ScyllaQueryResult { impl<'a> FieldNameDifferentCombinedRef<'a> { #[doc = r" Returns a struct that can perform an insert operation"] pub fn insert_qv(&self) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.row_type)?; serialized.add_value(&self.row_pub)?; serialized.add_value(&self.row_struct)?; @@ -182,7 +183,7 @@ impl<'a> FieldNameDifferentCombinedRef<'a> { } #[doc = r" Returns a struct that can perform an insert operation with a TTL"] pub fn insert_ttl_qv(&self, ttl: TtlType) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.row_type)?; serialized.add_value(&self.row_pub)?; serialized.add_value(&self.row_struct)?; @@ -271,7 +272,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.row_type)?; serialized_values.add_value(&self.row_pub)?; Ok(SelectUnique::new(Qv { @@ -298,7 +299,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_expect_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.row_type)?; serialized_values.add_value(&self.row_pub)?; Ok(SelectUniqueExpect::new(Qv { @@ -325,7 +326,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = "Returns a struct that can perform an update operation for column struct"] pub fn update_row_struct_qv(&self, val: &str) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; serialized_values.add_value(&self.row_type)?; serialized_values.add_value(&self.row_pub)?; @@ -373,12 +374,12 @@ impl PrimaryKeyRef<'_> { pub fn update_dyn_multiple_qv( &self, val: &[UpdatableColumnRef<'_>], - ) -> Result, SerializeValuesError> { + ) -> Result, SerializeValuesError> { if val.is_empty() { panic!("Empty update array") } let mut query = vec![]; - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); for v in val { match v { UpdatableColumnRef::RowStruct(v) => { @@ -417,7 +418,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a single row deletion"] pub fn delete_qv(&self) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.row_type)?; serialized_values.add_value(&self.row_pub)?; Ok(DeleteUnique::new(Qv { diff --git a/catalytic_table_to_struct/example/src/generated/person.rs b/catalytic_table_to_struct/example/src/generated/person.rs index d8ce79d..530adb6 100644 --- a/catalytic_table_to_struct/example/src/generated/person.rs +++ b/catalytic_table_to_struct/example/src/generated/person.rs @@ -7,9 +7,9 @@ use catalytic::query_transform::{ TtlType, Update, }; use catalytic::scylla; +use scylla::frame::value::LegacySerializedValues; #[allow(unused_imports)] use scylla::frame::value::SerializeValuesError; -use scylla::frame::value::SerializedValues; use scylla::transport::errors::QueryError; use scylla::transport::iterator::TypedRowIterator; use scylla::CachingSession; @@ -40,8 +40,9 @@ pub const DELETE_QUERY: &str = "delete from person where name = ? and age = ?"; #[doc = r" When you converted this struct to the specified type, you will have methods available"] #[doc = r" for the things you want"] #[derive( - scylla :: FromRow, scylla :: ValueList, catalytic_macro :: Mirror, Debug, Clone, PartialEq, + scylla :: FromRow, scylla :: SerializeRow, catalytic_macro :: Mirror, Debug, Clone, PartialEq, )] +# [scylla (crate = scylla , flavor = "enforce_order" , skip_name_checks)] pub struct Person { #[partition_key] pub name: String, @@ -168,7 +169,7 @@ pub async fn truncate(session: &CachingSession) -> ScyllaQueryResult { impl<'a> PersonRef<'a> { #[doc = r" Returns a struct that can perform an insert operation"] pub fn insert_qv(&self) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.name)?; serialized.add_value(&self.age)?; serialized.add_value(&self.email)?; @@ -185,7 +186,7 @@ impl<'a> PersonRef<'a> { } #[doc = r" Returns a struct that can perform an insert operation with a TTL"] pub fn insert_ttl_qv(&self, ttl: TtlType) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.name)?; serialized.add_value(&self.age)?; serialized.add_value(&self.email)?; @@ -276,7 +277,7 @@ impl From> for PrimaryKey { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a unique row selection"] pub fn select_unique_qv(&self) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; Ok(SelectUnique::new(Qv { @@ -302,7 +303,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_expect_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; Ok(SelectUniqueExpect::new(Qv { @@ -326,7 +327,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = "Returns a struct that can perform an update operation for column email"] pub fn update_email_qv(&self, val: &str) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; @@ -349,7 +350,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = "Returns a struct that can perform an update operation for column type"] pub fn update_row_type_qv(&self, val: &str) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; @@ -394,12 +395,12 @@ impl PrimaryKeyRef<'_> { pub fn update_dyn_multiple_qv( &self, val: &[UpdatableColumnRef<'_>], - ) -> Result, SerializeValuesError> { + ) -> Result, SerializeValuesError> { if val.is_empty() { panic!("Empty update array") } let mut query = vec![]; - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); for v in val { match v { UpdatableColumnRef::Email(v) => { @@ -442,7 +443,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a single row deletion"] pub fn delete_qv(&self) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; Ok(DeleteUnique::new(Qv { diff --git a/catalytic_table_to_struct/example/src/generated/person_by_email.rs b/catalytic_table_to_struct/example/src/generated/person_by_email.rs index 96a0231..d326e1e 100644 --- a/catalytic_table_to_struct/example/src/generated/person_by_email.rs +++ b/catalytic_table_to_struct/example/src/generated/person_by_email.rs @@ -8,9 +8,9 @@ use catalytic::query_transform::{ TtlType, Update, }; use catalytic::scylla; +use scylla::frame::value::LegacySerializedValues; #[allow(unused_imports)] use scylla::frame::value::SerializeValuesError; -use scylla::frame::value::SerializedValues; use scylla::transport::errors::QueryError; use scylla::transport::iterator::TypedRowIterator; use scylla::CachingSession; @@ -35,8 +35,9 @@ pub const SELECT_UNIQUE_QUERY_BASE_TABLE: &str = #[doc = r" When you converted this struct to the specified type, you will have methods available"] #[doc = r" for the things you want"] #[derive( - scylla :: FromRow, scylla :: ValueList, catalytic_macro :: Mirror, Debug, Clone, PartialEq, + scylla :: FromRow, scylla :: SerializeRow, catalytic_macro :: Mirror, Debug, Clone, PartialEq, )] +# [scylla (crate = scylla , flavor = "enforce_order" , skip_name_checks)] pub struct PersonByEmail { #[partition_key] pub email: String, @@ -225,7 +226,7 @@ impl From> for PrimaryKey { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a unique row selection"] pub fn select_unique_qv(&self) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.email)?; serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; @@ -252,7 +253,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_expect_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.email)?; serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; @@ -279,7 +280,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_base_table_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.email)?; serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; @@ -306,7 +307,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_expect_base_table_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.email)?; serialized_values.add_value(&self.name)?; serialized_values.add_value(&self.age)?; diff --git a/catalytic_table_to_struct/example/src/generated/test_table.rs b/catalytic_table_to_struct/example/src/generated/test_table.rs index ccf9c40..33463c2 100644 --- a/catalytic_table_to_struct/example/src/generated/test_table.rs +++ b/catalytic_table_to_struct/example/src/generated/test_table.rs @@ -7,9 +7,9 @@ use catalytic::query_transform::{ TtlType, Update, }; use catalytic::scylla; +use scylla::frame::value::LegacySerializedValues; #[allow(unused_imports)] use scylla::frame::value::SerializeValuesError; -use scylla::frame::value::SerializedValues; use scylla::transport::errors::QueryError; use scylla::transport::iterator::TypedRowIterator; use scylla::CachingSession; @@ -39,8 +39,9 @@ pub const DELETE_QUERY: &str = "delete from test_table where b = ? and c = ? and #[doc = r" When you converted this struct to the specified type, you will have methods available"] #[doc = r" for the things you want"] #[derive( - scylla :: FromRow, scylla :: ValueList, catalytic_macro :: Mirror, Debug, Clone, PartialEq, + scylla :: FromRow, scylla :: SerializeRow, catalytic_macro :: Mirror, Debug, Clone, PartialEq, )] +# [scylla (crate = scylla , flavor = "enforce_order" , skip_name_checks)] pub struct TestTable { #[partition_key] pub b: i32, @@ -179,7 +180,7 @@ pub async fn truncate(session: &CachingSession) -> ScyllaQueryResult { impl<'a> TestTableRef<'a> { #[doc = r" Returns a struct that can perform an insert operation"] pub fn insert_qv(&self) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.b)?; serialized.add_value(&self.c)?; serialized.add_value(&self.d)?; @@ -197,7 +198,7 @@ impl<'a> TestTableRef<'a> { } #[doc = r" Returns a struct that can perform an insert operation with a TTL"] pub fn insert_ttl_qv(&self, ttl: TtlType) -> Result { - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); serialized.add_value(&self.b)?; serialized.add_value(&self.c)?; serialized.add_value(&self.d)?; @@ -296,7 +297,7 @@ impl From> for PrimaryKey { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a unique row selection"] pub fn select_unique_qv(&self) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.b)?; serialized_values.add_value(&self.c)?; serialized_values.add_value(&self.d)?; @@ -324,7 +325,7 @@ impl PrimaryKeyRef<'_> { pub fn select_unique_expect_qv( &self, ) -> Result, SerializeValuesError> { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.b)?; serialized_values.add_value(&self.c)?; serialized_values.add_value(&self.d)?; @@ -350,7 +351,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = "Returns a struct that can perform an update operation for column e"] pub fn update_e_qv(&self, val: &i32) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; serialized_values.add_value(&self.b)?; serialized_values.add_value(&self.c)?; @@ -396,12 +397,12 @@ impl PrimaryKeyRef<'_> { pub fn update_dyn_multiple_qv( &self, val: &[UpdatableColumnRef<'_>], - ) -> Result, SerializeValuesError> { + ) -> Result, SerializeValuesError> { if val.is_empty() { panic!("Empty update array") } let mut query = vec![]; - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); for v in val { match v { UpdatableColumnRef::E(v) => { @@ -442,7 +443,7 @@ impl PrimaryKeyRef<'_> { impl PrimaryKeyRef<'_> { #[doc = r" Returns a struct that can perform a single row deletion"] pub fn delete_qv(&self) -> Result { - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&self.b)?; serialized_values.add_value(&self.c)?; serialized_values.add_value(&self.d)?; diff --git a/catalytic_table_to_struct/example/src/lib.rs b/catalytic_table_to_struct/example/src/lib.rs index c315f16..9f47276 100644 --- a/catalytic_table_to_struct/example/src/lib.rs +++ b/catalytic_table_to_struct/example/src/lib.rs @@ -26,7 +26,7 @@ mod test { use catalytic::scylla; use catalytic_macro::{query, query_base_table}; use futures_util::StreamExt; - use scylla::frame::value::{SerializeValuesError, SerializedValues}; + use scylla::frame::value::{SerializeValuesError, LegacySerializedValues}; use scylla::CachingSession; #[tokio::test] @@ -235,7 +235,7 @@ mod test { macro_rules! assert_serialized_values { ($sv: expr, $($val: expr),*) => {{ - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); $(serialized_values.add_value(&$val).unwrap();)* @@ -446,7 +446,7 @@ mod test { "select b, c, d, a, e from test_table where b = 1 and c = 2 and d = 3", transformed_type.query ); - assert_eq!(SerializedValues::new(), transformed_type.qv.values); + assert_eq!(LegacySerializedValues::new(), transformed_type.qv.values); let _ = query!("select * from test_table where b = 1 and c = 2 and d > 3"); let val = &1; @@ -461,7 +461,7 @@ mod test { "select b, c, d, a, e from test_table limit 1", transformed_type.query ); - assert_eq!(SerializedValues::new(), transformed_type.qv.values); + assert_eq!(LegacySerializedValues::new(), transformed_type.qv.values); let transformed_type = query!("select count(*) from test_table where b = 1 and c = 2"); @@ -469,7 +469,7 @@ mod test { "select count(*) from test_table where b = 1 and c = 2", transformed_type.query ); - assert_eq!(SerializedValues::new(), transformed_type.qv.values); + assert_eq!(LegacySerializedValues::new(), transformed_type.qv.values); let transformed_type = query!("delete from test_table where b = 1 and c = 3"); @@ -477,7 +477,7 @@ mod test { "delete from test_table where b = 1 and c = 3", transformed_type.query ); - assert_eq!(SerializedValues::new(), transformed_type.qv.values); + assert_eq!(LegacySerializedValues::new(), transformed_type.qv.values); let a = &1; let transformed_type = query!("select * from test_table where b = 1 and c = ?", a); diff --git a/catalytic_table_to_struct/src/entity_writer.rs b/catalytic_table_to_struct/src/entity_writer.rs index a3b49c4..98c39fb 100644 --- a/catalytic_table_to_struct/src/entity_writer.rs +++ b/catalytic_table_to_struct/src/entity_writer.rs @@ -39,7 +39,7 @@ impl EntityWriter<'_, T> { use scylla::transport::iterator::TypedRowIterator; #disallow_partitionless_queries use scylla::transport::errors::QueryError; - use scylla::frame::value::SerializedValues; + use scylla::frame::value::LegacySerializedValues; #[allow(unused_imports)] use scylla::frame::value::SerializeValuesError; #[allow(unused_imports)] diff --git a/catalytic_table_to_struct/src/entity_writer/write_primary_key.rs b/catalytic_table_to_struct/src/entity_writer/write_primary_key.rs index 8c08b49..36d640d 100644 --- a/catalytic_table_to_struct/src/entity_writer/write_primary_key.rs +++ b/catalytic_table_to_struct/src/entity_writer/write_primary_key.rs @@ -54,7 +54,7 @@ pub(crate) fn write( // )* // // let mut serialized_values = SerializedValues::with_capacity(size); - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); #( serialized_values.add_value(&self.#ident_field_names)?; @@ -222,7 +222,7 @@ pub(crate) fn write( pub fn #method_name_qv(&self, val: &#ty) -> Result { // https://github.com/Jasperav/Catalytic/issues/11 //let mut serialized_values = SerializedValues::with_capacity(std::mem::size_of_val(val)); - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); serialized_values.add_value(&val)?; @@ -297,7 +297,7 @@ pub(crate) fn write( tokens_type.extend(quote! { impl #primary_key_struct_ref<'_> { /// Returns a struct that can perform a dynamic amount of column updates - pub fn #update_dyn_multiple_qv(&self, val: &[#updatable_column_ref<'_>]) -> Result, SerializeValuesError> { + pub fn #update_dyn_multiple_qv(&self, val: &[#updatable_column_ref<'_>]) -> Result, SerializeValuesError> { if val.is_empty() { panic!("Empty update array") } @@ -306,7 +306,7 @@ pub(crate) fn write( // Hard to calculate the size in advance, I guess it's not performant to loop over the values // and calculate the sizes then - let mut serialized_values = SerializedValues::new(); + let mut serialized_values = LegacySerializedValues::new(); for v in val { match v { diff --git a/catalytic_table_to_struct/src/entity_writer/write_struct.rs b/catalytic_table_to_struct/src/entity_writer/write_struct.rs index 59d5239..06a1159 100644 --- a/catalytic_table_to_struct/src/entity_writer/write_struct.rs +++ b/catalytic_table_to_struct/src/entity_writer/write_struct.rs @@ -19,6 +19,7 @@ pub(crate) fn write( .transformer .struct_metadata(entity_writer.struct_table()) .into_tokenstream(); + let custom_macro = entity_writer.transformer.struct_custom_macros(entity_writer.struct_table()); let struct_name_ident = entity_writer.struct_ident(); let field_ts = &entity_writer.struct_field_metadata.field_ts; @@ -71,6 +72,7 @@ pub(crate) fn write( /// When you converted this struct to the specified type, you will have methods available /// for the things you want #meta_data + #custom_macro pub struct #struct_name_ident { #field_ts } @@ -254,7 +256,7 @@ pub(crate) fn write( // )*; // // let mut serialized = SerializedValues::with_capacity(size); - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); #(serialized.add_value(&self.#idents)?);*; @@ -284,7 +286,7 @@ pub(crate) fn write( // size += std::mem::size_of_val(&ttl); // // let mut serialized = SerializedValues::with_capacity(size); - let mut serialized = SerializedValues::new(); + let mut serialized = LegacySerializedValues::new(); #(serialized.add_value(&self.#idents)?);*; diff --git a/catalytic_table_to_struct/src/transformer.rs b/catalytic_table_to_struct/src/transformer.rs index 19acd87..7545222 100644 --- a/catalytic_table_to_struct/src/transformer.rs +++ b/catalytic_table_to_struct/src/transformer.rs @@ -99,11 +99,17 @@ pub trait Transformer { fn struct_metadata(&self, _struct_table: StructTable) -> TypeMetadata { TypeMetadata::with_default_values(&[ "scylla::FromRow", - "scylla::ValueList", + "scylla::SerializeRow", "catalytic_macro::Mirror", ]) } + fn struct_custom_macros(&self, _struct_table: StructTable) -> TokenStream { + quote! { + #[scylla(crate = scylla, flavor = "enforce_order", skip_name_checks)] + } + } + /// Add custom derives to the ref struct fn struct_ref_metadata(&self, _struct_table: StructTable) -> TypeMetadata { TypeMetadata::with_default_values(&["Copy"])