From 11ed4c1e489317d1f2e15e13e789eefebd6ed76b Mon Sep 17 00:00:00 2001 From: silverpill Date: Sat, 3 Dec 2022 21:11:28 +0000 Subject: [PATCH] Remove unnecessary as_str() conversions --- src/database/test_utils.rs | 4 ++-- src/models/notifications/queries.rs | 2 +- src/models/posts/queries.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/database/test_utils.rs b/src/database/test_utils.rs index 9829e38..8de94ce 100644 --- a/src/database/test_utils.rs +++ b/src/database/test_utils.rs @@ -21,13 +21,13 @@ pub async fn create_test_database() -> Client { "DROP DATABASE IF EXISTS {db_name:?}", db_name=db_name, ); - db_client.execute(drop_db_statement.as_str(), &[]).await.unwrap(); + db_client.execute(&drop_db_statement, &[]).await.unwrap(); let create_db_statement = format!( "CREATE DATABASE {db_name:?} WITH OWNER={owner:?};", db_name=db_name, owner=db_config.get_user().unwrap(), ); - db_client.execute(create_db_statement.as_str(), &[]).await.unwrap(); + db_client.execute(&create_db_statement, &[]).await.unwrap(); // Create new connection to database db_config.dbname(&db_name); diff --git a/src/models/notifications/queries.rs b/src/models/notifications/queries.rs index 6985c90..24aef77 100644 --- a/src/models/notifications/queries.rs +++ b/src/models/notifications/queries.rs @@ -160,7 +160,7 @@ pub async fn get_notifications( related_links=RELATED_LINKS, ); let rows = db_client.query( - statement.as_str(), + &statement, &[&recipient_id, &max_id, &i64::from(limit)], ).await?; let mut notifications: Vec = rows.iter() diff --git a/src/models/posts/queries.rs b/src/models/posts/queries.rs index b0f292e..46f237c 100644 --- a/src/models/posts/queries.rs +++ b/src/models/posts/queries.rs @@ -68,7 +68,7 @@ pub async fn create_post( visibility_public=i16::from(&Visibility::Public), ); let maybe_post_row = transaction.query_opt( - insert_statement.as_str(), + &insert_statement, &[ &post_id, &author_id, @@ -586,7 +586,7 @@ pub async fn get_post_by_id( related_links=RELATED_LINKS, ); let maybe_row = db_client.query_opt( - statement.as_str(), + &statement, &[&post_id], ).await?; let post = match maybe_row { @@ -678,7 +678,7 @@ pub async fn get_post_by_remote_object_id( related_links=RELATED_LINKS, ); let maybe_row = db_client.query_opt( - statement.as_str(), + &statement, &[&object_id], ).await?; let row = maybe_row.ok_or(DatabaseError::NotFound("post"))?; @@ -708,7 +708,7 @@ pub async fn get_post_by_ipfs_cid( related_links=RELATED_LINKS, ); let result = db_client.query_opt( - statement.as_str(), + &statement, &[&ipfs_cid], ).await?; let post = match result {