mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-29 03:34:44 +01:00
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] <support@github.com> * 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 <e@elm.sh>
This commit is contained in:
parent
c586cf5f51
commit
b5845bc3a1
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -926,9 +926,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.20.1"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "64d31059f22935e6c31830db5249ba2b7ecd54fd73a9909286f0a67aa55c2fbd"
|
checksum = "2f6332d94daa84478d55a6aa9dbb3b305ed6500fb0cb9400cb9e1525d0e0e188"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
@ -1518,9 +1518,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusqlite"
|
name = "rusqlite"
|
||||||
version = "0.24.2"
|
version = "0.25.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d5f38ee71cbab2c827ec0ac24e76f82eca723cee92c509a65f67dee393c25112"
|
checksum = "48381bf52627e7b0e02c4c0e4c0c88fc1cf2228a2eb7461d9499b1372399f1da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"fallible-iterator",
|
"fallible-iterator",
|
||||||
|
@ -33,7 +33,7 @@ dotenv = "0.15.0"
|
|||||||
sodiumoxide = "0.2.6"
|
sodiumoxide = "0.2.6"
|
||||||
|
|
||||||
[dependencies.rusqlite]
|
[dependencies.rusqlite]
|
||||||
version = "0.24"
|
version = "0.25"
|
||||||
features = ["bundled"]
|
features = ["bundled"]
|
||||||
|
|
||||||
[dependencies.rocket_contrib]
|
[dependencies.rocket_contrib]
|
||||||
|
@ -3,7 +3,7 @@ use std::env;
|
|||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
use crate::local::database::{Database, QueryParam};
|
use crate::local::database::Database;
|
||||||
use crate::local::history::History;
|
use crate::local::history::History;
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
@ -96,12 +96,11 @@ impl Cmd {
|
|||||||
|
|
||||||
let history = match params {
|
let history = match params {
|
||||||
(false, false) => db.list()?,
|
(false, false) => db.list()?,
|
||||||
(true, false) => db.query(QUERY_SESSION, &[QueryParam::Text(session)])?,
|
(true, false) => db.query(QUERY_SESSION, &[session.as_str()])?,
|
||||||
(false, true) => db.query(QUERY_DIR, &[QueryParam::Text(cwd)])?,
|
(false, true) => db.query(QUERY_DIR, &[cwd.as_str()])?,
|
||||||
(true, true) => db.query(
|
(true, true) => {
|
||||||
QUERY_SESSION_DIR,
|
db.query(QUERY_SESSION_DIR, &[cwd.as_str(), session.as_str()])?
|
||||||
&[QueryParam::Text(cwd), QueryParam::Text(session)],
|
}
|
||||||
)?,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
print_list(&history);
|
print_list(&history);
|
||||||
|
@ -4,14 +4,10 @@ use std::path::Path;
|
|||||||
use eyre::Result;
|
use eyre::Result;
|
||||||
|
|
||||||
use rusqlite::{params, Connection};
|
use rusqlite::{params, Connection};
|
||||||
use rusqlite::{Transaction, NO_PARAMS};
|
use rusqlite::{Params, Transaction};
|
||||||
|
|
||||||
use super::history::History;
|
use super::history::History;
|
||||||
|
|
||||||
pub enum QueryParam {
|
|
||||||
Text(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Database {
|
pub trait Database {
|
||||||
fn save(&mut self, h: &History) -> Result<()>;
|
fn save(&mut self, h: &History) -> Result<()>;
|
||||||
fn save_bulk(&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<Utc>, to: chrono::DateTime<Utc>)
|
fn range(&self, from: chrono::DateTime<Utc>, to: chrono::DateTime<Utc>)
|
||||||
-> Result<Vec<History>>;
|
-> Result<Vec<History>>;
|
||||||
|
|
||||||
fn query(&self, query: &str, params: &[QueryParam]) -> Result<Vec<History>>;
|
fn query(&self, query: &str, params: impl Params) -> Result<Vec<History>>;
|
||||||
fn update(&self, h: &History) -> Result<()>;
|
fn update(&self, h: &History) -> Result<()>;
|
||||||
fn history_count(&self) -> Result<i64>;
|
fn history_count(&self) -> Result<i64>;
|
||||||
|
|
||||||
@ -71,7 +67,7 @@ impl Sqlite {
|
|||||||
|
|
||||||
unique(timestamp, cwd, command)
|
unique(timestamp, cwd, command)
|
||||||
)",
|
)",
|
||||||
NO_PARAMS,
|
[],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -105,16 +101,6 @@ impl Sqlite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rusqlite::ToSql for QueryParam {
|
|
||||||
fn to_sql(&self) -> Result<rusqlite::types::ToSqlOutput<'_>, rusqlite::Error> {
|
|
||||||
use rusqlite::types::{ToSqlOutput, Value};
|
|
||||||
|
|
||||||
match self {
|
|
||||||
Self::Text(s) => Ok(ToSqlOutput::Owned(Value::Text(s.clone()))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Database for Sqlite {
|
impl Database for Sqlite {
|
||||||
fn save(&mut self, h: &History) -> Result<()> {
|
fn save(&mut self, h: &History) -> Result<()> {
|
||||||
debug!("saving history to sqlite");
|
debug!("saving history to sqlite");
|
||||||
@ -197,7 +183,7 @@ impl Database for Sqlite {
|
|||||||
Ok(history_iter.filter_map(Result::ok).collect())
|
Ok(history_iter.filter_map(Result::ok).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query(&self, query: &str, params: &[QueryParam]) -> Result<Vec<History>> {
|
fn query(&self, query: &str, params: impl Params) -> Result<Vec<History>> {
|
||||||
let mut stmt = self.conn.prepare(query)?;
|
let mut stmt = self.conn.prepare(query)?;
|
||||||
|
|
||||||
let history_iter = stmt.query_map(params, |row| history_from_sqlite_row(None, row))?;
|
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<Vec<History>> {
|
fn prefix_search(&self, query: &str) -> Result<Vec<History>> {
|
||||||
self.query(
|
self.query(
|
||||||
"select * from history where command like ?1 || '%' order by timestamp asc",
|
"select * from history where command like ?1 || '%' order by timestamp asc",
|
||||||
&[QueryParam::Text(query.to_string())],
|
&[query],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user