@@ -287,18 +287,17 @@ impl Database {
287287 /// Insert `entry` under `id` into the database and optionally set owner to `uid`.
288288 pub async fn insert ( & self , id : Id , entry : write:: Entry ) -> Result < ( ) , Error > {
289289 let conn = self . conn . clone ( ) ;
290- let id = id. to_i64 ( ) ;
291290 let write:: DatabaseEntry { entry, data, nonce } = entry. compress ( ) . await ?. encrypt ( ) . await ?;
292291
293292 spawn_blocking ( move || match entry. expires {
294293 None => conn. lock ( ) . execute (
295294 "INSERT INTO entries (id, uid, data, burn_after_reading, nonce, title) VALUES (?1, ?2, ?3, ?4, ?5, ?6)" ,
296- params ! [ id, entry. uid, data, entry. burn_after_reading, nonce, entry. title] ,
295+ params ! [ id. to_i64 ( ) , entry. uid, data, entry. burn_after_reading, nonce, entry. title] ,
297296 ) ,
298297 Some ( expires) => conn. lock ( ) . execute (
299298 "INSERT INTO entries (id, uid, data, burn_after_reading, nonce, expires, title) VALUES (?1, ?2, ?3, ?4, ?5, datetime('now', ?6), ?7)" ,
300299 params ! [
301- id,
300+ id. to_i64 ( ) ,
302301 entry. uid,
303302 data,
304303 entry. burn_after_reading,
@@ -316,12 +315,11 @@ impl Database {
316315 /// Get entire entry for `id`.
317316 pub async fn get ( & self , id : Id , password : Option < Password > ) -> Result < read:: Entry , Error > {
318317 let conn = self . conn . clone ( ) ;
319- let id_as_u32 = id. to_i64 ( ) ;
320318
321319 let entry = spawn_blocking ( move || {
322320 conn. lock ( ) . query_row (
323321 "SELECT data, burn_after_reading, uid, nonce, expires < datetime('now'), title FROM entries WHERE id=?1" ,
324- params ! [ id_as_u32 ] ,
322+ params ! [ id . to_i64 ( ) ] ,
325323 |row| {
326324 Ok ( read:: DatabaseEntry {
327325 data : row. get ( 0 ) ?,
@@ -361,12 +359,11 @@ impl Database {
361359 /// expired or does not exist.
362360 pub async fn get_uid ( & self , id : Id ) -> Result < Option < i64 > , Error > {
363361 let conn = self . conn . clone ( ) ;
364- let id_as_u32 = id. to_i64 ( ) ;
365362
366363 let ( uid, expired) = spawn_blocking ( move || {
367364 conn. lock ( ) . query_row (
368365 "SELECT uid, expires < datetime('now') FROM entries WHERE id=?1" ,
369- params ! [ id_as_u32 ] ,
366+ params ! [ id . to_i64 ( ) ] ,
370367 |row| {
371368 let uid: Option < i64 > = row. get ( 0 ) ?;
372369 let expired: Option < bool > = row. get ( 1 ) ?;
@@ -387,12 +384,11 @@ impl Database {
387384 /// Get title of a paste.
388385 pub async fn get_title ( & self , id : Id ) -> Result < Option < String > , Error > {
389386 let conn = self . conn . clone ( ) ;
390- let id = id. to_i64 ( ) ;
391387
392388 let title = spawn_blocking ( move || {
393389 conn. lock ( ) . query_row (
394390 "SELECT title FROM entries WHERE id=?1" ,
395- params ! [ id] ,
391+ params ! [ id. to_i64 ( ) ] ,
396392 |row| row. get ( 0 ) ,
397393 )
398394 } )
@@ -404,11 +400,10 @@ impl Database {
404400 /// Delete `id`.
405401 pub async fn delete ( & self , id : Id ) -> Result < ( ) , Error > {
406402 let conn = self . conn . clone ( ) ;
407- let id = id. to_i64 ( ) ;
408403
409404 spawn_blocking ( move || {
410405 conn. lock ( )
411- . execute ( "DELETE FROM entries WHERE id=?1" , params ! [ id] )
406+ . execute ( "DELETE FROM entries WHERE id=?1" , params ! [ id. to_i64 ( ) ] )
412407 } )
413408 . await ??;
414409
0 commit comments