Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
trevyn committed Jan 6, 2022
1 parent 6470840 commit cf7c715
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
Cargo.lock
Cargo.lock
.DS_Store
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"rust-analyzer.checkOnSave.features": ["test"],
"rust-analyzer.cargo.features": ["test"]
"rust-analyzer.cargo.features": ["test"],
"rust-analyzer.checkOnSave.command": "clippy"
}
10 changes: 5 additions & 5 deletions turbosql-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ fn migrations_to_schema(migrations: &[String]) -> Result<String, rusqlite::Error
Ok(
migrations_to_tempdb(migrations)
.prepare("SELECT sql FROM sqlite_master WHERE type='table' ORDER BY sql")?
.query_map(params![], |row| Ok(row.get(0)?))?
.query_map(params![], |row| row.get(0))?
.collect::<Result<Vec<String>, _>>()?
.join("\n"),
)
Expand Down Expand Up @@ -606,7 +606,7 @@ fn do_parse_tokens(
// Primitive type
Some(ResultType { container: None, contents: Some(contents) })
if ["f32", "f64", "i8", "u8", "i16", "u16", "i32", "u32", "i64", "String", "bool"]
.contains(&&contents.to_string().as_str()) =>
.contains(&contents.to_string().as_str()) =>
{
quote! {
{
Expand All @@ -615,7 +615,7 @@ fn do_parse_tokens(
let db = db.borrow_mut();
let mut stmt = db.prepare_cached(#sql)?;
let result = stmt.query_row(::turbosql::params![#params], |row| -> ::turbosql::Result<#contents> {
Ok(row.get(0)?)
row.get(0)
})?;
Ok(result)
})
Expand Down Expand Up @@ -848,13 +848,13 @@ use std::fs;
fn create(table: &Table) {
// create the migrations

let sql = makesql_create(&table);
let sql = makesql_create(table);

rusqlite::Connection::open_in_memory().unwrap().execute(&sql, params![]).unwrap_or_else(|e| {
abort_call_site!("Error validating auto-generated CREATE TABLE statement: {} {:#?}", sql, e)
});

let target_migrations = make_migrations(&table);
let target_migrations = make_migrations(table);

// read in the existing migrations from toml

Expand Down
2 changes: 1 addition & 1 deletion turbosql/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
path2.push("migrations.toml");

// docs.rs is a largely read-only filesystem
if let Ok(_) = std::env::var("DOCS_RS") {
if std::env::var("DOCS_RS").is_ok() {
std::fs::write(&path2, "").unwrap();
return;
}
Expand Down
20 changes: 11 additions & 9 deletions turbosql/tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// cargo test --features test --manifest-path turbosql/Cargo.toml -- --nocapture

#![allow(clippy::bool_assert_comparison)]

#[cfg(not(feature = "test"))]
compile_error!("turbosql must be tested with '--features test'");
#[cfg(not(test))]
Expand Down Expand Up @@ -121,25 +123,25 @@ fn integration_test() {
select!(i64 "field_u8 FROM personintegrationtest").unwrap() == row.field_u8.unwrap().into()
);

assert!(
select!(bool "field_string = ? FROM personintegrationtest", "Arthur Schopenhauer").unwrap()
== false
assert_eq!(
select!(bool "field_string = ? FROM personintegrationtest", "Arthur Schopenhauer").unwrap(),
false
);
let new_row = row.clone();
assert!(
assert_eq!(
select!(bool "field_string = ? FROM personintegrationtest", new_row.field_string.unwrap())
.unwrap()
== true
.unwrap(),
true
);
// this incorrectly consumes row:
// assert!(select!(bool "field_string = ? FROM personintegrationtest", row.field_string.unwrap()).unwrap() == true);

// select!(PersonIntegrationTest "WHERE field_string = ?", row.field_string.unwrap());

assert!(
assert_eq!(
select!(bool "field_string = ? FROM personintegrationtest", row.clone().field_string.unwrap())
.unwrap()
== true
.unwrap(),
true
);

assert!(
Expand Down

0 comments on commit cf7c715

Please sign in to comment.