From b5845bc3a1e9869389414f13a6dee2acd8cb0c2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Apr 2021 10:59:07 +0000 Subject: Bump rusqlite from 0.24.2 to 0.25.0 (#30) * Bump rusqlite from 0.24.2 to 0.25.0 Bumps [rusqlite](https://github.com/rusqlite/rusqlite) from 0.24.2 to 0.25.0. - [Release notes](https://github.com/rusqlite/rusqlite/releases) - [Changelog](https://github.com/rusqlite/rusqlite/blob/master/Changelog.md) - [Commits](https://github.com/rusqlite/rusqlite/compare/v0.24.2...v0.25.0) Signed-off-by: dependabot[bot] * Fixes for new rusqlite (mostly the new Params trait) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ellie Huxtable --- src/local/database.rs | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src/local/database.rs') diff --git a/src/local/database.rs b/src/local/database.rs index cba7142c..ad7078e5 100644 --- a/src/local/database.rs +++ b/src/local/database.rs @@ -4,14 +4,10 @@ use std::path::Path; use eyre::Result; use rusqlite::{params, Connection}; -use rusqlite::{Transaction, NO_PARAMS}; +use rusqlite::{Params, Transaction}; use super::history::History; -pub enum QueryParam { - Text(String), -} - pub trait Database { fn save(&mut self, h: &History) -> Result<()>; fn save_bulk(&mut self, h: &[History]) -> Result<()>; @@ -21,7 +17,7 @@ pub trait Database { fn range(&self, from: chrono::DateTime, to: chrono::DateTime) -> Result>; - fn query(&self, query: &str, params: &[QueryParam]) -> Result>; + fn query(&self, query: &str, params: impl Params) -> Result>; fn update(&self, h: &History) -> Result<()>; fn history_count(&self) -> Result; @@ -71,7 +67,7 @@ impl Sqlite { unique(timestamp, cwd, command) )", - NO_PARAMS, + [], )?; Ok(()) @@ -105,16 +101,6 @@ impl Sqlite { } } -impl rusqlite::ToSql for QueryParam { - fn to_sql(&self) -> Result, rusqlite::Error> { - use rusqlite::types::{ToSqlOutput, Value}; - - match self { - Self::Text(s) => Ok(ToSqlOutput::Owned(Value::Text(s.clone()))), - } - } -} - impl Database for Sqlite { fn save(&mut self, h: &History) -> Result<()> { debug!("saving history to sqlite"); @@ -197,7 +183,7 @@ impl Database for Sqlite { Ok(history_iter.filter_map(Result::ok).collect()) } - fn query(&self, query: &str, params: &[QueryParam]) -> Result> { + fn query(&self, query: &str, params: impl Params) -> Result> { let mut stmt = self.conn.prepare(query)?; let history_iter = stmt.query_map(params, |row| history_from_sqlite_row(None, row))?; @@ -208,7 +194,7 @@ impl Database for Sqlite { fn prefix_search(&self, query: &str) -> Result> { self.query( "select * from history where command like ?1 || '%' order by timestamp asc", - &[QueryParam::Text(query.to_string())], + &[query], ) } -- cgit v1.3.1