Skip to content

Commit 1097a01

Browse files
upgrading to rusqlite 0.20.0. was kind of a doosy, especially with the new version of rustc i am using. the idea here is to be able to build sqlite3 with SQLITE_MAX_VARIABLE_NUMBER set to a much higher numbers than the default (999 -> 9999) so we avoid any TOO MANY VARIABLES errors. this is due to an error reported by a user that was exceedingly hard to track down.
1 parent 51d6f7b commit 1097a01

File tree

19 files changed

+88
-58
lines changed

19 files changed

+88
-58
lines changed

Cargo.lock

Lines changed: 31 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected_derive = { path = "protected_derive" }
4646
quick-error = "1.2.2"
4747
regex = "0.1.77"
4848
reqwest = "0.9.3"
49-
rusqlite = "0.13.0"
49+
rusqlite = "0.20.0"
5050
serde = "1.0.8"
5151
serde_derive = "1.0.8"
5252
serde_json = "1.0.2"

clouseau/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ authors = ["Andrew Danger Lyon <orthecreedence@gmail.com>"]
55

66
[dependencies]
77
quick-error = "1.2.2"
8-
rusqlite = "0.13.0"
8+
rusqlite = "0.20.0"
99

clouseau/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern crate rusqlite;
1111
use ::std::error::Error;
1212
use ::std::mem;
1313

14-
use ::rusqlite::Connection;
14+
use ::rusqlite::{Connection, NO_PARAMS};
1515

1616
// ....~?=:::~M8.+$??Z$DON??=Z+,+=~.....
1717
// ... ....~?IZO==+:=$+:+:?.$8=I.$~::+:=~....
@@ -68,7 +68,7 @@ use ::rusqlite::Connection;
6868
quick_error! {
6969
#[derive(Debug)]
7070
pub enum CError {
71-
Boxed(err: Box<Error + Send + Sync>) {
71+
Boxed(err: Box<dyn Error + Send + Sync>) {
7272
description(err.description())
7373
display("error: {}", err)
7474
}
@@ -104,7 +104,7 @@ impl Clouseau {
104104
/// Very clever. Very clever indeed!
105105
pub fn new() -> CResult<Clouseau> {
106106
let conn = Connection::open_in_memory()?;
107-
conn.execute("CREATE VIRTUAL TABLE objects USING fts4 (id VARCHAR(64) PRIMARY KEY, content TEXT)", &[])?;
107+
conn.execute("CREATE VIRTUAL TABLE objects USING fts4 (id VARCHAR(64) PRIMARY KEY, content TEXT)", NO_PARAMS)?;
108108
Ok(Clouseau {
109109
conn: conn,
110110
})

dumpy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["Andrew Danger Lyon <orthecreedence@gmail.com>"]
66
[dependencies]
77
jedi = { path = "../jedi" }
88
libc = "0.2.15"
9-
rusqlite = "0.13.0"
9+
rusqlite = "0.20.0"
1010
quick-error = "1.2.2"
1111
serde = "1.0.8"
1212
serde_json = "1.0.2"

dumpy/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ quick_error! {
1414
description(str)
1515
display("error: {}", str)
1616
}
17-
Boxed(err: Box<Error + Send + Sync>) {
17+
Boxed(err: Box<dyn Error + Send + Sync>) {
1818
description(err.description())
1919
display("error: {}", err.description())
2020
}

dumpy/src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern crate quick_error;
2626
extern crate rusqlite;
2727
extern crate serde_json;
2828

29-
use ::rusqlite::Connection;
29+
use ::rusqlite::{Connection, NO_PARAMS};
3030
use ::rusqlite::types::Value as SqlValue;
3131
use ::rusqlite::types::{ToSql, ToSqlOutput};
3232
use ::rusqlite::Error as SqlError;
@@ -78,13 +78,13 @@ impl Dumpy {
7878

7979
/// Init our dumpy store on an existing connection.
8080
pub fn init(&self, conn: &Connection) -> DResult<()> {
81-
conn.execute("CREATE TABLE IF NOT EXISTS dumpy_objects (id VARCHAR(64) PRIMARY KEY, table_name VARCHAR(32), data TEXT)", &[])?;
82-
conn.execute("CREATE TABLE IF NOT EXISTS dumpy_index (id INTEGER PRIMARY KEY, table_name VARCHAR(32), index_name VARCHAR(32), vals VARCHAR(256), object_id VARCHAR(64))", &[])?;
83-
conn.execute("CREATE TABLE IF NOT EXISTS dumpy_kv (key VARCHAR(32) PRIMARY KEY, value TEXT)", &[])?;
81+
conn.execute("CREATE TABLE IF NOT EXISTS dumpy_objects (id VARCHAR(64) PRIMARY KEY, table_name VARCHAR(32), data TEXT)", NO_PARAMS)?;
82+
conn.execute("CREATE TABLE IF NOT EXISTS dumpy_index (id INTEGER PRIMARY KEY, table_name VARCHAR(32), index_name VARCHAR(32), vals VARCHAR(256), object_id VARCHAR(64))", NO_PARAMS)?;
83+
conn.execute("CREATE TABLE IF NOT EXISTS dumpy_kv (key VARCHAR(32) PRIMARY KEY, value TEXT)", NO_PARAMS)?;
8484

85-
conn.execute("CREATE INDEX IF NOT EXISTS dumpy_idx_index ON dumpy_index (table_name, index_name, vals)", &[])?;
86-
conn.execute("CREATE INDEX IF NOT EXISTS dumpy_idx_index_obj ON dumpy_index (table_name, object_id)", &[])?;
87-
conn.execute("CREATE UNIQUE INDEX IF NOT EXISTS dumpy_idx_kv ON dumpy_kv (key)", &[])?;
85+
conn.execute("CREATE INDEX IF NOT EXISTS dumpy_idx_index ON dumpy_index (table_name, index_name, vals)", NO_PARAMS)?;
86+
conn.execute("CREATE INDEX IF NOT EXISTS dumpy_idx_index_obj ON dumpy_index (table_name, object_id)", NO_PARAMS)?;
87+
conn.execute("CREATE UNIQUE INDEX IF NOT EXISTS dumpy_idx_kv ON dumpy_kv (key)", NO_PARAMS)?;
8888
Ok(())
8989
}
9090

@@ -215,7 +215,7 @@ impl Dumpy {
215215
pub fn get(&self, conn: &Connection, table: &String, id: &String) -> DResult<Option<Value>> {
216216
let query = "SELECT data FROM dumpy_objects WHERE id = $1 AND table_name = $2";
217217
let res = conn.query_row_and_then(query, &[id, table], |row| -> DResult<Value> {
218-
let data: SqlValue = row.get_checked("data")?;
218+
let data: SqlValue = row.get("data")?;
219219
match data {
220220
SqlValue::Text(ref x) => {
221221
Ok(jedi::parse(x)?)
@@ -265,7 +265,7 @@ impl Dumpy {
265265
});
266266
let query = format!("SELECT data FROM dumpy_objects WHERE id IN ({}) ORDER BY id ASC", oids);
267267
let mut query = conn.prepare(&query[..])?;
268-
let rows = query.query_map(&[], |row| {
268+
let rows = query.query_map(NO_PARAMS, |row| {
269269
row.get("data")
270270
})?;
271271
let mut objects: Vec<Value> = Vec::new();
@@ -288,9 +288,9 @@ impl Dumpy {
288288
let merged_qry = qry_parts.as_slice().join("");
289289
let mut query = conn.prepare(merged_qry.as_str())?;
290290

291-
let values: Vec<&ToSql> = qry_vals.iter()
291+
let values: Vec<&dyn ToSql> = qry_vals.iter()
292292
.map(|x| {
293-
let ts: &ToSql = x;
293+
let ts: &dyn ToSql = x;
294294
ts
295295
})
296296
.collect::<Vec<_>>();
@@ -325,10 +325,10 @@ impl Dumpy {
325325
qry_parts.push(") ORDER BY id ASC");
326326
let final_query = qry_parts.as_slice().join("");
327327
let mut prepared_qry = conn.prepare(final_query.as_str())?;
328-
let mut values: Vec<&ToSql> = Vec::with_capacity(qry_vals.len());
328+
let mut values: Vec<&dyn ToSql> = Vec::with_capacity(qry_vals.len());
329329
for val in &qry_vals {
330-
let ts: &ToSql = val;
331-
values.push(ts);
330+
//let ts: dyn ToSql = val;
331+
values.push(val as &dyn ToSql);
332332
}
333333
let rows = prepared_qry.query_map(values.as_slice(), |row| row.get("data"))?;
334334
let mut objects: Vec<Value> = Vec::new();
@@ -340,15 +340,15 @@ impl Dumpy {
340340

341341
/// Set a value into the key/val store
342342
pub fn kv_set(&self, conn: &Connection, key: &str, val: &String) -> DResult<()> {
343-
conn.execute("INSERT OR REPLACE INTO dumpy_kv (key, value) VALUES ($1, $2)", &[&key, val])?;
343+
conn.execute("INSERT OR REPLACE INTO dumpy_kv (key, value) VALUES ($1, $2)", &[&key, val.as_str()])?;
344344
Ok(())
345345
}
346346

347347
/// Get a value from the key/val store
348348
pub fn kv_get(&self, conn: &Connection, key: &str) -> DResult<Option<String>> {
349349
let query = "SELECT value FROM dumpy_kv WHERE key = $1";
350350
let res = conn.query_row_and_then(query, &[&key], |row| -> DResult<String> {
351-
let data: SqlValue = row.get_checked("value")?;
351+
let data: SqlValue = row.get("value")?;
352352
match data {
353353
SqlValue::Text(x) => {
354354
Ok(x)
@@ -393,7 +393,7 @@ mod tests {
393393

394394
fn index_count(conn: &Connection) -> i64 {
395395
conn.query_row_and_then("SELECT COUNT(*) AS count FROM dumpy_index", &[], |row| -> DResult<i64> {
396-
let data: SqlValue = row.get_checked("count")?;
396+
let data: SqlValue = row.get("count")?;
397397
match data {
398398
SqlValue::Integer(ref x) => Ok(x.clone()),
399399
_ => Err(DError::Msg(format!("error grabbing count"))),

integration-tests/Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sock/Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/crypto/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ quick_error! {
44
/// Define a type for cryptography errors.
55
#[derive(Debug)]
66
pub enum CryptoError {
7-
Boxed(err: Box<Error + Send + Sync>) {
7+
Boxed(err: Box<dyn Error + Send + Sync>) {
88
description(err.description())
99
display("crypto: error: {}", err.description())
1010
}

0 commit comments

Comments
 (0)