From f81e496fa4bcbda05a0cbedd80aacc473b2b0d15 Mon Sep 17 00:00:00 2001
From: yggverse <yggverse@project>
Date: Thu, 14 Nov 2024 04:24:32 +0200
Subject: [PATCH] change argument data type

---
 src/profile/database.rs | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/profile/database.rs b/src/profile/database.rs
index 05b52a0e..83d8b7e4 100644
--- a/src/profile/database.rs
+++ b/src/profile/database.rs
@@ -43,7 +43,7 @@ impl Database {
     // Setters
 
     /// Create new record in `Self` database connected
-    pub fn add(&self, is_active: bool, time: DateTime, name: Option<&str>) -> Result<i64, ()> {
+    pub fn add(&self, is_active: bool, time: DateTime, name: Option<String>) -> Result<i64, ()> {
         // Begin new transaction
         let mut writable = self.connection.write().unwrap();
         let tx = writable.transaction().unwrap();
@@ -52,13 +52,7 @@ impl Database {
         if is_active {
             // Deactivate other records as only one profile should be active
             for record in select(&tx).unwrap() {
-                let _ = update(
-                    &tx,
-                    record.id,
-                    false,
-                    record.time,
-                    record.name.as_ref().map(|x| x.as_str()),
-                );
+                let _ = update(&tx, record.id, false, record.time, record.name);
             }
         }
 
@@ -89,7 +83,7 @@ impl Database {
                 record.id,
                 if record.id == id { true } else { false },
                 record.time,
-                record.name.as_ref().map(|x| x.as_str()),
+                record.name,
             );
         }
 
@@ -120,7 +114,7 @@ pub fn insert(
     tx: &Transaction,
     is_active: bool,
     time: DateTime,
-    name: Option<&str>,
+    name: Option<String>,
 ) -> Result<usize, Error> {
     tx.execute(
         "INSERT INTO `profile` (
@@ -137,7 +131,7 @@ pub fn update(
     id: i64,
     is_active: bool,
     time: DateTime,
-    name: Option<&str>,
+    name: Option<String>,
 ) -> Result<usize, Error> {
     tx.execute(
         "UPDATE `profile` SET `is_active` = ?, `time` = ?, `name` = ? WHERE `id` = ?",