diff --git a/migration/src/m20240603_162500_make_title_optional.rs b/migration/src/m20240603_162500_make_title_optional.rs index 8e8d45e..4b32b80 100644 --- a/migration/src/m20240603_162500_make_title_optional.rs +++ b/migration/src/m20240603_162500_make_title_optional.rs @@ -6,37 +6,51 @@ pub struct Migration; #[async_trait::async_trait] impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager.alter_table( - TableAlterStatement::new() - .table(Transaction::Table) - .modify_column(ColumnDef::new(Transaction::Title).string().null()) - .to_owned() - ).await?; + manager + .alter_table( + TableAlterStatement::new() + .table(Transaction::Table) + .modify_column(ColumnDef::new(Transaction::Title).string().null()) + .to_owned(), + ) + .await?; // Set all empty string titles to null - manager.get_connection().execute_unprepared(r#" + manager + .get_connection() + .execute_unprepared( + r#" update transaction set title = null where title = '' - "#).await?; + "#, + ) + .await?; Ok(()) } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { // Set all null titles to empty string when reverting - manager.get_connection().execute_unprepared(r#" + manager + .get_connection() + .execute_unprepared( + r#" update transaction set title = '' where title is null - "#).await?; + "#, + ) + .await?; - manager.alter_table( - TableAlterStatement::new() - .table(Transaction::Table) - .modify_column(ColumnDef::new(Transaction::Title).string().not_null()) - .to_owned() - ).await + manager + .alter_table( + TableAlterStatement::new() + .table(Transaction::Table) + .modify_column(ColumnDef::new(Transaction::Title).string().not_null()) + .to_owned(), + ) + .await } } diff --git a/src/ingestion/ingestion_logic.rs b/src/ingestion/ingestion_logic.rs index aa77674..4ad534e 100644 --- a/src/ingestion/ingestion_logic.rs +++ b/src/ingestion/ingestion_logic.rs @@ -174,12 +174,14 @@ fn test_json() { let json: Vec> = serde_json::from_str(json).unwrap(); let mut csv_reader = csv::Reader::from_reader(csv.as_bytes()); - let json_rows = json.iter() + let json_rows = json + .iter() .map(|row| from_json_row(row.clone())) .collect::, anyhow::Error>>() .unwrap(); - let csv_rows = csv_reader.records() + let csv_rows = csv_reader + .records() .map(|record| from_csv_row(record.unwrap())) .collect::, anyhow::Error>>() .unwrap(); @@ -188,7 +190,12 @@ fn test_json() { for (i, (json_row, csv_row)) in json_rows.iter().zip(csv_rows.iter()).enumerate() { assert_eq!(json_row, csv_row, "Row {} is different", i); - assert_eq!(json_row.compute_hash(), csv_row.compute_hash(), "Row {} hash are different", i); + assert_eq!( + json_row.compute_hash(), + csv_row.compute_hash(), + "Row {} hash are different", + i + ); } }