diff --git a/codegen/src/worktable/generator/queries/in_place.rs b/codegen/src/worktable/generator/queries/in_place.rs index 126097a..60efdd9 100644 --- a/codegen/src/worktable/generator/queries/in_place.rs +++ b/codegen/src/worktable/generator/queries/in_place.rs @@ -36,7 +36,6 @@ impl Generator { .from_case(Case::Pascal) .to_case(Case::Snake); let index = self.columns.indexes.values().find(|idx| idx.field == op.by); - let by_type = self.columns.columns_map.get(&op.by).unwrap(); if let Some(index) = index { let _index_name = &index.name; @@ -46,7 +45,7 @@ impl Generator { todo!() } } else if self.columns.primary_keys.len() == 1 { - self.gen_primary_key_in_place(snake_case_name, by_type, &op.columns) + self.gen_primary_key_in_place(snake_case_name, &op.columns) } else { todo!() } @@ -58,12 +57,7 @@ impl Generator { } } - fn gen_primary_key_in_place( - &self, - snake_case_name: String, - by_type: &TokenStream, - columns: &[Ident], - ) -> TokenStream { + fn gen_primary_key_in_place(&self, snake_case_name: String, columns: &[Ident]) -> TokenStream { let name_generator = WorktableNameGenerator::from_table_name(self.name.to_string()); let pk_type = name_generator.get_primary_key_type_ident(); let lock_ident = @@ -111,11 +105,13 @@ impl Generator { let custom_lock = self.gen_custom_lock_for_update(lock_ident); quote! { - pub async fn #method_ident( + pub async fn #method_ident( &self, mut f: F, - by: #by_type, - ) -> eyre::Result<()> { + by: Pk, + ) -> eyre::Result<()> + where #pk_type: From + { let pk: #pk_type = by.into(); let lock = { #custom_lock diff --git a/codegen/src/worktable/generator/queries/update.rs b/codegen/src/worktable/generator/queries/update.rs index 2caf812..79c14ae 100644 --- a/codegen/src/worktable/generator/queries/update.rs +++ b/codegen/src/worktable/generator/queries/update.rs @@ -246,7 +246,7 @@ impl Generator { #full_row_lock }; - let row_old = self.select(pk.clone()).expect("should not be deleted by other thread"); + let row_old = self.0.select(pk.clone()).expect("should not be deleted by other thread"); let mut row_new = row_old.clone(); let pk = row_old.get_primary_key().clone(); #(#row_updates)* @@ -388,7 +388,10 @@ impl Generator { let custom_lock = self.gen_custom_lock_for_update(lock_ident); quote! { - pub async fn #method_ident(&self, row: #query_ident, pk: #pk_ident) -> core::result::Result<(), WorkTableError> { + pub async fn #method_ident(&self, row: #query_ident, pk: Pk) -> core::result::Result<(), WorkTableError> + where #pk_ident: From + { + let pk = pk.into(); let lock = { #custom_lock }; diff --git a/codegen/src/worktable/generator/table/impls.rs b/codegen/src/worktable/generator/table/impls.rs index 54018e1..2c18440 100644 --- a/codegen/src/worktable/generator/table/impls.rs +++ b/codegen/src/worktable/generator/table/impls.rs @@ -105,8 +105,9 @@ impl Generator { let primary_key_type = name_generator.get_primary_key_type_ident(); quote! { - pub fn select(&self, pk: #primary_key_type) -> Option<#row_type> { - self.0.select(pk) + pub fn select(&self, pk: Pk) -> Option<#row_type> + where #primary_key_type: From { + self.0.select(pk.into()) } } } diff --git a/src/persistence/task.rs b/src/persistence/task.rs index d7bead4..5dcddf9 100644 --- a/src/persistence/task.rs +++ b/src/persistence/task.rs @@ -242,7 +242,7 @@ where for (pos, id) in ops_pos_set { let mut row: BatchInnerRow = self .queue_inner_wt - .select(id.into()) + .select(id) .expect("exists as Id exists") .into(); let op = self diff --git a/tests/persistence/sync/mod.rs b/tests/persistence/sync/mod.rs index 49ae2ba..ba20696 100644 --- a/tests/persistence/sync/mod.rs +++ b/tests/persistence/sync/mod.rs @@ -86,7 +86,7 @@ fn test_space_insert_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -132,7 +132,7 @@ fn test_space_insert_many_sync() { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); let last = *pks.last().unwrap(); for pk in pks { - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); } assert_eq!(table.0.pk_gen.get_state(), last + 1) } @@ -179,8 +179,8 @@ fn test_space_update_full_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().another, 13); + assert!(table.select(pk).is_some()); + assert_eq!(table.select(pk).unwrap().another, 13); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -215,7 +215,7 @@ fn test_space_update_query_pk_sync() { }; table.insert(row.clone()).unwrap(); table - .update_another_by_id(AnotherByIdQuery { another: 13 }, row.id.into()) + .update_another_by_id(AnotherByIdQuery { another: 13 }, row.id) .await .unwrap(); table.wait_for_ops().await; @@ -223,8 +223,8 @@ fn test_space_update_query_pk_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().another, 13); + assert!(table.select(pk).is_some()); + assert_eq!(table.select(pk).unwrap().another, 13); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -267,8 +267,8 @@ fn test_space_update_query_unique_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().field, 1.0); + assert!(table.select(pk).is_some()); + assert_eq!(table.select(pk).unwrap().field, 1.0); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -311,8 +311,8 @@ fn test_space_update_query_non_unique_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().another, 13); + assert!(table.select(pk).is_some()); + assert_eq!(table.select(pk).unwrap().another, 13); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -349,7 +349,7 @@ fn test_space_delete_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_none()); + assert!(table.select(pk).is_none()); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -389,7 +389,7 @@ fn test_space_delete_query_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_none()); + assert!(table.select(pk).is_none()); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); diff --git a/tests/persistence/sync/string_primary_index.rs b/tests/persistence/sync/string_primary_index.rs index d40110f..4fe857c 100644 --- a/tests/persistence/sync/string_primary_index.rs +++ b/tests/persistence/sync/string_primary_index.rs @@ -61,7 +61,7 @@ fn test_space_insert_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); } }); } @@ -107,7 +107,7 @@ fn test_space_insert_many_sync() { { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); for pk in pks { - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); } } }); @@ -155,8 +155,8 @@ fn test_space_update_full_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.clone().into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().another, 13); + assert!(table.select(pk.clone()).is_some()); + assert_eq!(table.select(pk).unwrap().another, 13); } }); } @@ -190,7 +190,7 @@ fn test_space_update_query_pk_sync() { }; table.insert(row.clone()).unwrap(); table - .update_another_by_id(AnotherByIdQuery { another: 13 }, row.id.clone().into()) + .update_another_by_id(AnotherByIdQuery { another: 13 }, row.id.clone()) .await .unwrap(); table.wait_for_ops().await; @@ -198,8 +198,8 @@ fn test_space_update_query_pk_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.clone().into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().another, 13); + assert!(table.select(pk.clone()).is_some()); + assert_eq!(table.select(pk).unwrap().another, 13); } }); } @@ -242,8 +242,8 @@ fn test_space_update_query_unique_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.clone().into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().field, 1.0); + assert!(table.select(pk.clone()).is_some()); + assert_eq!(table.select(pk).unwrap().field, 1.0); } }); } @@ -286,8 +286,8 @@ fn test_space_update_query_non_unique_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.clone().into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().another, 13); + assert!(table.select(pk.clone()).is_some()); + assert_eq!(table.select(pk).unwrap().another, 13); } }); } @@ -333,7 +333,7 @@ fn test_space_delete_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_none()); + assert!(table.select(pk).is_none()); } }); } @@ -372,7 +372,7 @@ fn test_space_delete_query_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_none()); + assert!(table.select(pk).is_none()); } }); } diff --git a/tests/persistence/sync/string_secondary_index.rs b/tests/persistence/sync/string_secondary_index.rs index 130f51f..ae7d458 100644 --- a/tests/persistence/sync/string_secondary_index.rs +++ b/tests/persistence/sync/string_secondary_index.rs @@ -61,7 +61,7 @@ fn test_space_insert_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -109,7 +109,7 @@ fn test_space_insert_many_sync() { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); let last = *pks.last().unwrap(); for pk in pks { - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); } assert_eq!(table.0.pk_gen.get_state(), last + 1) } @@ -155,16 +155,16 @@ fn test_space_update_full_sync() { .unwrap(); table.wait_for_ops().await; assert_eq!( - table.select(row.id.into()).unwrap().another, + table.select(row.id).unwrap().another, "Some string to test updated".to_string() ); row.id }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); assert_eq!( - table.select(pk.into()).unwrap().another, + table.select(pk).unwrap().another, "Some string to test updated".to_string() ); assert_eq!(table.0.pk_gen.get_state(), pk + 1) @@ -205,7 +205,7 @@ fn test_space_update_query_pk_sync() { AnotherByIdQuery { another: "Some string to test updated".to_string(), }, - row.id.into(), + row.id, ) .await .unwrap(); @@ -214,9 +214,9 @@ fn test_space_update_query_pk_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); assert_eq!( - table.select(pk.into()).unwrap().another, + table.select(pk).unwrap().another, "Some string to test updated".to_string() ); assert_eq!(table.0.pk_gen.get_state(), pk + 1) @@ -265,8 +265,8 @@ fn test_space_update_query_unique_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); - assert_eq!(table.select(pk.into()).unwrap().field, 1.0); + assert!(table.select(pk).is_some()); + assert_eq!(table.select(pk).unwrap().field, 1.0); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -317,9 +317,9 @@ fn test_space_update_query_non_unique_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_some()); + assert!(table.select(pk).is_some()); assert_eq!( - table.select(pk.into()).unwrap().another, + table.select(pk).unwrap().another, "Some string to test updated".to_string() ); assert_eq!(table.0.pk_gen.get_state(), pk + 1) @@ -361,7 +361,7 @@ fn test_space_delete_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_none()); + assert!(table.select(pk).is_none()); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); @@ -401,7 +401,7 @@ fn test_space_delete_query_sync() { }; { let table = TestSyncWorkTable::load_from_file(config).await.unwrap(); - assert!(table.select(pk.into()).is_none()); + assert!(table.select(pk).is_none()); assert_eq!(table.0.pk_gen.get_state(), pk + 1) } }); diff --git a/tests/worktable/array.rs b/tests/worktable/array.rs index 1cf3709..0e61214 100644 --- a/tests/worktable/array.rs +++ b/tests/worktable/array.rs @@ -27,7 +27,7 @@ fn insert() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, row); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test] @@ -46,7 +46,7 @@ async fn update() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, new_row); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test] @@ -64,7 +64,7 @@ async fn update_in_a_middle() { test: [1; 20], }; table.update(new_row.clone()).await.unwrap(); - let selected_row = table.select(3.into()).unwrap(); + let selected_row = table.select(3).unwrap(); assert_eq!(selected_row, new_row); } @@ -85,7 +85,7 @@ async fn update_query() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row.test, q.test); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } type ArrI = [i64; 20]; @@ -114,7 +114,7 @@ fn insert_i() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, row); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test] @@ -133,7 +133,7 @@ async fn update_i() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, new_row); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test] @@ -151,7 +151,7 @@ async fn update_in_a_middle_i() { test: [1; 20], }; table.update(new_row.clone()).await.unwrap(); - let selected_row = table.select(3.into()).unwrap(); + let selected_row = table.select(3).unwrap(); assert_eq!(selected_row, new_row); } @@ -172,5 +172,5 @@ async fn update_query_i() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row.test, q.test); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } diff --git a/tests/worktable/base.rs b/tests/worktable/base.rs index 98915a6..c8574c6 100644 --- a/tests/worktable/base.rs +++ b/tests/worktable/base.rs @@ -124,7 +124,7 @@ async fn update_spawn() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, updated); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test] @@ -152,7 +152,7 @@ async fn upsert_spawn() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, updated); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test] @@ -175,7 +175,7 @@ async fn update() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, updated); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test] @@ -200,7 +200,7 @@ async fn update_string() { assert_eq!(selected_row, updated); assert_eq!(table.0.data.get_empty_links().first().unwrap(), &first_link); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] @@ -241,7 +241,7 @@ async fn update_parallel() { let val = fastrand::u64(..); let id_to_update = fastrand::u64(0..=99); table - .update_another_by_id(AnotherByIdQuery { another: val }, id_to_update.into()) + .update_another_by_id(AnotherByIdQuery { another: val }, id_to_update) .await .unwrap(); { @@ -440,10 +440,10 @@ async fn upsert() { exchange: "test".to_string(), }; table.upsert(updated.clone()).await.unwrap(); - let selected_row = table.select(row.id.into()).unwrap(); + let selected_row = table.select(row.id).unwrap(); assert_eq!(selected_row, updated); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[test] diff --git a/tests/worktable/bench.rs b/tests/worktable/bench.rs index 003b00d..217af7c 100644 --- a/tests/worktable/bench.rs +++ b/tests/worktable/bench.rs @@ -66,18 +66,13 @@ async fn _rw_lock_hash_map_vs_wt() { for i in 0..100000u64 { let s: String = Alphanumeric.sample_string(&mut rand::rng(), 8); let q = ValueByIdQuery { value: s }; - task_wt - .update_value_by_id(q, ((i % 50) * 2).into()) - .await - .unwrap(); + task_wt.update_value_by_id(q, (i % 50) * 2).await.unwrap(); } }); for i in 0..100000u64 { let s: String = Alphanumeric.sample_string(&mut rand::rng(), 8); let q = ValueByIdQuery { value: s }; - wt.update_value_by_id(q, ((i % 50) * 2 + 1).into()) - .await - .unwrap(); + wt.update_value_by_id(q, (i % 50) * 2 + 1).await.unwrap(); } h.await.unwrap(); println!("wt update in {} μs", wt_start.elapsed().as_micros()); diff --git a/tests/worktable/in_place.rs b/tests/worktable/in_place.rs index b0e51fa..28f536f 100644 --- a/tests/worktable/in_place.rs +++ b/tests/worktable/in_place.rs @@ -269,7 +269,7 @@ async fn test_update_in_place_and_update_sized_multithread() -> eyre::Result<()> let val = fastrand::u64(..); let id_to_update = fastrand::u64(0..=99); table - .update_something_by_id(SomethingByIdQuery { something: val }, id_to_update.into()) + .update_something_by_id(SomethingByIdQuery { something: val }, id_to_update) .await?; { let mut guard = i_state.lock(); @@ -283,15 +283,15 @@ async fn test_update_in_place_and_update_sized_multithread() -> eyre::Result<()> h2.await?; for (id, smth) in i_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.something, smth); } for (id, val) in val2_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.val2, val); } for (id, val) in val_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.val, val); } Ok(()) @@ -361,7 +361,7 @@ async fn test_update_in_place_and_update_unsized_multithread() -> eyre::Result<( AnotherByIdQuery { another: format!("another_{val}"), }, - id_to_update.into(), + id_to_update, ) .await?; { @@ -376,12 +376,12 @@ async fn test_update_in_place_and_update_unsized_multithread() -> eyre::Result<( h2.await?; for (id, smth) in i_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.another, smth); } let mut errors = 0; for (id, val) in val2_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); if &row.val2 != val { errors += 1; } @@ -389,7 +389,7 @@ async fn test_update_in_place_and_update_unsized_multithread() -> eyre::Result<( assert_eq!(errors, 0); let mut errors = 0; for (id, val) in val_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); if &row.val != val { errors += 1; } diff --git a/tests/worktable/index/insert.rs b/tests/worktable/index/insert.rs index 748a4d0..a3ac487 100644 --- a/tests/worktable/index/insert.rs +++ b/tests/worktable/index/insert.rs @@ -30,7 +30,7 @@ fn insert() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, row); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[test] diff --git a/tests/worktable/tuple_primary_key.rs b/tests/worktable/tuple_primary_key.rs index e7f755c..49c98b1 100644 --- a/tests/worktable/tuple_primary_key.rs +++ b/tests/worktable/tuple_primary_key.rs @@ -22,5 +22,5 @@ fn insert() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, row); - assert!(table.select((1, 0).into()).is_none()) + assert!(table.select((1, 0)).is_none()) } diff --git a/tests/worktable/unsized_.rs b/tests/worktable/unsized_.rs index f0e01c2..834b0de 100644 --- a/tests/worktable/unsized_.rs +++ b/tests/worktable/unsized_.rs @@ -200,7 +200,7 @@ async fn update_many_times() { ExchangeByIdQuery { exchange: format!("test_{val}"), }, - id_to_update.into(), + id_to_update, ) .await .unwrap(); @@ -265,7 +265,7 @@ async fn update_parallel() { ExchangeByIdQuery { exchange: format!("test_{val}"), }, - id_to_update.into(), + id_to_update, ) .await .unwrap(); @@ -544,7 +544,7 @@ async fn update_parallel_more_strings() { ExchangeAgainByIdQuery { exchange: format!("test_{val}"), }, - id_to_update.into(), + id_to_update, ) .await .unwrap(); @@ -565,7 +565,7 @@ async fn update_parallel_more_strings() { SomeByIdQuery { some_string: format!("some_{val}"), }, - id_to_update.into(), + id_to_update, ) .await .unwrap(); @@ -580,11 +580,11 @@ async fn update_parallel_more_strings() { h.await.unwrap(); for (id, e) in e_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.exchange, e) } for (id, s) in s_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.some_string, s) } } @@ -617,7 +617,7 @@ async fn update_parallel_more_strings_more_threads() { ExchangeAgainByIdQuery { exchange: format!("test_{val}"), }, - id_to_update.into(), + id_to_update, ) .await .unwrap(); @@ -637,7 +637,7 @@ async fn update_parallel_more_strings_more_threads() { let val = fastrand::u64(..); let id_to_update = fastrand::u64(0..=99); shared - .update_another_by_id(AnotherByIdQuery { another: val }, id_to_update.into()) + .update_another_by_id(AnotherByIdQuery { another: val }, id_to_update) .await .unwrap(); { @@ -657,7 +657,7 @@ async fn update_parallel_more_strings_more_threads() { SomeByIdQuery { some_string: format!("some_{val}"), }, - id_to_update.into(), + id_to_update, ) .await .unwrap(); @@ -673,15 +673,15 @@ async fn update_parallel_more_strings_more_threads() { h2.await.unwrap(); for (id, e) in e_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.exchange, e) } for (id, s) in s_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.some_string, s) } for (id, a) in a_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.another, a) } } @@ -715,7 +715,7 @@ async fn update_parallel_more_strings_with_select_non_unique() { ExchangeAgainByIdQuery { exchange: format!("test_{val}"), }, - id_to_update.into(), + id_to_update, ) .await .unwrap(); @@ -735,7 +735,7 @@ async fn update_parallel_more_strings_with_select_non_unique() { let val = fastrand::u64(..); let id_to_update = fastrand::u64(0..1000); shared - .update_another_by_id(AnotherByIdQuery { another: val }, id_to_update.into()) + .update_another_by_id(AnotherByIdQuery { another: val }, id_to_update) .await .unwrap(); { @@ -761,11 +761,11 @@ async fn update_parallel_more_strings_with_select_non_unique() { h2.await.unwrap(); for (id, e) in e_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.exchange, e) } for (id, a) in a_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.another, a) } } @@ -799,7 +799,7 @@ async fn update_parallel_more_strings_with_select_unique() { ExchangeAgainByIdQuery { exchange: format!("test_{val}"), }, - id_to_update.into(), + id_to_update, ) .await .unwrap(); @@ -819,7 +819,7 @@ async fn update_parallel_more_strings_with_select_unique() { let val = fastrand::u64(..); let id_to_update = fastrand::u64(0..1000); shared - .update_another_by_id(AnotherByIdQuery { another: val }, id_to_update.into()) + .update_another_by_id(AnotherByIdQuery { another: val }, id_to_update) .await .unwrap(); { @@ -840,11 +840,11 @@ async fn update_parallel_more_strings_with_select_unique() { h2.await.unwrap(); for (id, e) in e_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.exchange, e) } for (id, a) in a_state.lock_arc().iter() { - let row = table.select((*id).into()).unwrap(); + let row = table.select(*id).unwrap(); assert_eq!(&row.another, a) } } diff --git a/tests/worktable/uuid.rs b/tests/worktable/uuid.rs index 1ddbc53..822d7e9 100644 --- a/tests/worktable/uuid.rs +++ b/tests/worktable/uuid.rs @@ -21,5 +21,5 @@ fn insert() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, row); - assert!(table.select(Uuid::new_v4().into()).is_none()) + assert!(table.select(Uuid::new_v4()).is_none()) } diff --git a/tests/worktable/with_enum.rs b/tests/worktable/with_enum.rs index 95c4db0..9ee9916 100644 --- a/tests/worktable/with_enum.rs +++ b/tests/worktable/with_enum.rs @@ -34,7 +34,7 @@ fn insert() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, row); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) } #[tokio::test] @@ -53,5 +53,5 @@ async fn update() { let selected_row = table.select(pk).unwrap(); assert_eq!(selected_row, updated); - assert!(table.select(2.into()).is_none()) + assert!(table.select(2).is_none()) }