@@ -158,7 +158,7 @@ pub async fn init_db() {
158158}
159159
160160#[ inline]
161- pub async fn random_world_row ( db_pool : & DbPoolConnection ) -> Result < QueryRow , Box < dyn Error > > {
161+ pub async fn random_world_row ( db_pool : & DbPoolConnection ) -> QueryRow {
162162 let random_id: i32 = rand:: rng ( ) . random_range ( 1 ..=RANDOM_MAX ) ;
163163 let sql: String = format ! (
164164 "SELECT id, randomNumber FROM {} WHERE id = {}" ,
@@ -167,19 +167,19 @@ pub async fn random_world_row(db_pool: &DbPoolConnection) -> Result<QueryRow, Bo
167167 if let Ok ( rows) = sqlx:: query ( & sql) . fetch_one ( db_pool) . await {
168168 let id: i32 = rows. get ( KEY_ID ) ;
169169 let random_number: i32 = rows. get ( KEY_RANDOM_NUMBER ) ;
170- return Ok ( QueryRow :: new ( id, random_number) ) ;
170+ return QueryRow :: new ( id, random_number) ;
171171 }
172- return Ok ( QueryRow :: new ( 1 , 1 ) ) ;
172+ QueryRow :: new ( 1 , 1 )
173173}
174174
175175#[ inline]
176- pub async fn update_world_rows ( limit : Queries ) -> Result < Vec < QueryRow > , Box < dyn Error > > {
176+ pub async fn update_world_rows ( limit : Queries ) -> Vec < QueryRow > {
177177 let db_pool: DbPoolConnection = get_db_connection ( ) . await ;
178178 let ( sql, data) = get_update_data ( limit) . await ;
179179 spawn ( async move {
180180 let _ = sqlx:: query ( & sql) . execute ( & db_pool) . await ;
181181 } ) ;
182- Ok ( data)
182+ data
183183}
184184
185185#[ inline]
@@ -197,7 +197,7 @@ pub async fn all_world_row() -> Vec<PgRow> {
197197pub async fn get_some_row_id ( limit : Queries , db_pool : & DbPoolConnection ) -> Vec < QueryRow > {
198198 let mut res: Vec < QueryRow > = Vec :: with_capacity ( limit as usize ) ;
199199 for _ in 0 ..limit {
200- let tem: QueryRow = random_world_row ( db_pool) . await . unwrap_or_default ( ) ;
200+ let tem: QueryRow = random_world_row ( db_pool) . await ;
201201 res. push ( tem) ;
202202 }
203203 res
0 commit comments