diff --git a/src/database.rs b/src/database.rs index 44abc99..1361a2c 100644 --- a/src/database.rs +++ b/src/database.rs @@ -80,7 +80,7 @@ pub fn return_all_data(connection: &Connection) -> Result> { pub fn return_only_x_items(connection: &Connection, args: &Args) -> Result> { let mut snapshots_data: Vec = Vec::new(); - let mut statement = connection.prepare(&format!("SELECT name,snap_id,source,destination,date FROM (SELECT row_number() over(ORDER BY date DESC) n,* from snapshots) WHERE n > {} AND name LIKE '{}%'", args.keep_only, args.snapshot_prefix))?; + let mut statement = connection.prepare(&format!("SELECT name,snap_id,source,destination,date FROM (SELECT row_number() over(ORDER BY date DESC) n,* from snapshots WHERE name like '{}%') WHERE n > {}", args.snapshot_prefix, args.keep_only))?; while let State::Row = statement.next()? { let mut db_struct = Database::default();